akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
  private static int countReplace(char[] cs, int first) {
    int current = first;
    int count = 0;
    for (char c : cs) {
      if (c - '0' != current) {
        count++;
      }
      current = 1 - current;
    }
    return count;
  }
  
  private static int solve(char[] cs) {
    return Math.min(countReplace(cs, 0), countReplace(cs, 1));
  }
  
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    
    String input = s.next();
    char[] cs = input.toCharArray();
    
    System.out.println(solve(cs));
  }
}


Measured memory_bytes: 29140
n = int(input())
t = [int(input()) for i in range(n)]

#最大公約数
def gcd(a, b):
    while b!=0:
        a,b=b,a%b
    return a

#最小公倍数
def lcm(a,b):
    return a * b // gcd(a, b)

ans = t[0]
for i in range(1,n):
    ans = lcm(ans, t[i])

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;

int Item[3005][3005];
ll DP[3005][3005][4];

int main(){
    int R,C,k;cin>>R>>C>>k;
    rep(i,k){
        int r,c,v;
        scanf("%d %d %d",&r,&c,&v);
        r--;c--;
        Item[r][c]=v;
    }
    rep(i,R)rep(j,C){
        for(int k=2;k>=0;k--){
            DP[i][j][k+1]=max(DP[i][j][k+1],DP[i][j][k]+Item[i][j]);
        }
        rep(k,4){
            DP[i+1][j][0]=max(DP[i+1][j][0],DP[i][j][k]);
            DP[i][j+1][k]=max(DP[i][j+1][k],DP[i][j][k]);
        }
    }

    ll ans=0;
    rep(k,4)ans=max(ans,DP[R-1][C-1][k]);
    cout<<ans<<endl;
}

Measured memory_bytes: 320688
# -*- coding: utf-8 -*-

def div(n):
    return int(n / 2)

N = int(input())
A = list(map(int, input().split()))

r = 0
flag = False
while (True):
    for x in A:
        if x % 2 == 1:
            flag = True
            break

    if (flag):
        break

    r += 1
    A = list(map(div, A))    
    
print(r)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define int long long
using namespace std;

signed main(){
    constexpr int mod=1e9+7;
    string s;cin>>s;
    int n=s.size();
    int x[7]={0,1,10,9,12,3,4};
    vector<vector<int>> dp(n+1,vector<int>(13,0));
    dp[0][0]=1;
    REP(i,n) REP(j,13){
        int d=(n-i)%6;
        d=d?d:6;
        if(s[i]=='?'){
            REP(k,10){
                (dp[i+1][(j+k*x[d])%13]+=dp[i][j])%=mod;
            }
        }
        else{
            int k=s[i]-'0'; 
            (dp[i+1][(j+k*x[d])%13]+=dp[i][j])%=mod;
        }
    }
    cout<<dp[n][5]<<endl;
}

Measured memory_bytes: 13696
#include<iostream>
using namespace std;

int main(){
  int K,S;
  cin >> K >>S;
  int res=0;
  int Z;
  for (int X=0;X<K+1; ++X){
    for(int Y=0;Y<K+1; ++Y){
      Z=S-X-Y;
      if(Z>=0 && Z<=K){
          ++res;
      }
    }
    }
  cout <<res<<endl;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=805;
//i_am_noob
int cnt=0;
string str;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> str;
	rep(sz(str)) if((str[i]-'0')!=i%2) cnt++;
	print1(min(sz(str)-cnt,cnt));
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, m, t;
    cin >> n >> m >> t;
    int a[105];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int ans = a[0]-m;
    for(int i=0;i<n-1;i++){
        ans += max(0, a[i+1]-a[i]-m*2);
    }
    ans += max(0, t-a[n-1]-m);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;

int N, X, sum, tmp, i;

int main() {
  ios::sync_with_stdio(false);
  cin >> N >> X;
  for(i = 1; i <= N; i++) {
    cin >> tmp;
    sum += tmp;
    if (sum > X) break;
  }
  cout << i;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	ll h,w;
	cin>>h>>w;
	ll num=h*w;
	if(h==1||w==1){
		cout<<1;
		re 0;
	}
	if(num%2==0){
		cout<<num/2;
	}
	else{
		cout<<num/2+1;
	} 
	re 0;
}

Measured memory_bytes: 256
from bisect import bisect_left
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()


def get_count(tot):
    '''
    tot以上を満たす幸福度の握手の個数を数える
    '''
    ret = 0
    for i in range(N):
        cnt = bisect_left(A, tot-A[i])
        ret += N - cnt
    return ret


# 右からの累積和
Asum = A[:]
for i in range(N-2, -1, -1):
    Asum[i] += Asum[i+1]


def get_sum(tot):
    '''
    左端を固定した時の右端の個数分だけ左端を足し、右端の区間和（累積和）も足す。
    '''
    ret = 0
    for i in range(N):
        idx = bisect_left(A, tot-A[i])
        cnt = N - idx
        ret += A[i]*cnt
        # print(idx)
        if idx == N:
            continue
        ret += Asum[idx]
        # print(f'ret = {ret}')
    return ret


# M回握手できる上限を求める
ok = 0
ng = 10**12
while ok + 1 != ng:
    md = (ok + ng)//2
    if M <= get_count(md):
        ok = md
    else:
        ng = md
# print(ok)
# print(get_sum(ok+1))
# print(M - get_count(ok+1))
# print(Asum)
ans = get_sum(ok+1) + (M - get_count(ok+1))*ok

print(ans)


Measured memory_bytes: 20768
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = Integer.parseInt(scan.next());
        int D = Integer.parseInt(scan.next());
        int X = Integer.parseInt(scan.next());
        int[] A = new int[N];
        int[] cou = new int[N];
        for(int i = 0;i<N;i++){
            A[i] = Integer.parseInt(scan.next());
            cou[i]++;
            continue;
        }
        for(int i = 0;i<N;i++){
            for(int k = 0;k<D;k++){
                if (A[i]*(k+1)+1<=D) {
                    cou[i] ++;
                }else{
                    break;
                }
            }
        }
        int out=0;
        for(int i = 0;i<N;i++){
            out += cou[i];
        }
        System.out.println(out+X);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;

using P = pair<int, int>;

int main() {
  int n,q;
  cin>>n>>q;

  vector<vector<int>> G(n);
  for(int i=0; i<n-1; i++) {
    int a,b;
    cin>>a>>b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }

  vector<int> count(n);
  for(int i=0; i<n; i++) count[i] = 0;
  for(int i=0; i<q; i++) {
    int p,x;
    cin>>p>>x;
    count[p-1] += x;
  }

  int ans[n];
  for(int i=0; i<n; i++) ans[i] = -1;
  queue<P> todo;
  P p;
  p.first = 0;
  p.second = 0;
  todo.push(p);
  while(!todo.empty()) {
    P now = todo.front();
    now.second += count[now.first];
    ans[now.first] = now.second;
    todo.pop();
    for(int next : G[now.first]) {
      if(ans[next]!=-1) continue;
      P next_pair;
      next_pair.first = next;
      next_pair.second = ans[now.first];
      todo.push(next_pair);
    }
  }


  // int dist[n];
  // dist[0] = 0;
  // for(int i=1; i<n; i++) dist[i] = -1;
  // queue<int> todo;
  // todo.push(0);
  // while(!todo.empty()) {
  //   int now = todo.front();
  //   todo.pop();
  //   for(int next : G[now]) {
  //     if(dist[next]!=-1) continue;
  //     dist[next] = dist[now] +1;
  //     todo.push(next);
  //   }
  // }

  // for(int i=0; i<q; i++) {
  //   int p,x;
  //   cin>>p>>x;

  //   queue<int> todo2;
  //   todo2.push(p-1);
  //   while(!todo2.empty()) {
  //     int now = todo2.front();
  //     count[now] += x;
  //     todo2.pop();
  //     for(int next : G[now]) {
  //       if(dist[next]<dist[now]) continue;
  //       todo2.push(next);
  //     }
  //   }
  // }

  for(int i=0; i<n-1; i++) {
    cout<<ans[i]<<' ';
  }
  cout<<ans[n-1]<<endl;

  return 0;
}

Measured memory_bytes: 17140
//https://atcoder.jp/contests/abc170/tasks/abc170_c
#include <bits/stdc++.h>

using namespace std;

int X, N;

int main() {
    cin >> X >> N;
    vector<bool> table(101);
    for (int i = 0; i < N; i++) {
        int temp; cin >> temp;
        table[temp] = 1;
    }
    vector<int> numtable;
    for (int i = 0; i <= 101; i++) {
        if (!table[i]) {
            numtable.push_back(i);
        }
    }
    auto iter = lower_bound(numtable.begin(), numtable.end(), X);
    int ans;
    if (iter == numtable.begin()) ans = *iter;
    else if (abs(X-*iter) < abs(X-*(iter-1))) ans = *iter;
    else ans = *(iter-1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
import java.util.*; 

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();

		if(a==0){
			System.out.println(1);
		} else if(b==0){
			System.out.println(2);
		} else if(c==0){
			System.out.println(3);
		} else if(d==0){
			System.out.println(4);
		} else if(e==0){
			System.out.println(5);
		}
	  }
	}

Measured memory_bytes: 35688
using System;

namespace prime
{
    class Program
    {
        static void Main()
        {
            while (true)
            {
                int n, ans = 0;

                if (int.TryParse(Console.ReadLine(), out n))
                {
                    for (int i = 2; i <= n; ++i)
                    {
                        if (IsPrime(i))
                            ++ans;
                    }
                    Console.WriteLine(ans);
                }
                else
                    break;
            }
        }

        public static bool IsPrime(int a)
        {
            if (a == 1)
                return false;
            else if (a < 4)
                return true;
            else
            {
                bool prime = true;
                int ma = (int)Math.Sqrt(a + 1);
                int i = 3;
                if (a % 2 == 0)
                    prime = false;
                else
                {
                    for (; i <= ma; i += 2)
                    {
                        if (a % i == 0)
                        {
                            prime = false;
                            break;
                        }
                    }
                }
                return prime;
            }
        }
    }
}

Measured memory_bytes: 5616
#include<stdio.h>
 
#define N 100000
 
int  s[N]={0};
 
void def(){
    int i;
    for (i = 0; i < N; i++) {
         s[i] = i;
    }
}

int find(int a){
    if (a ==  s[a]) {
        return a;
    }
    return  s[a] = find( s[a]);
}
 
int Judge(int a, int b){
    if (find(a) == find(b)) {
        return 1;
    }
    else return 0;
}
 
void unite(int a, int b){
    a = find(a);
    b = find(b);
     
    if (a == b) {
        return;
    }
     s[b] = a;
}
 
int main(){
    int n, m, q, i, s, t;
    def();
    scanf ("%d %d\n", &n, &m);
    for (i = 0; i < m; i++){
        scanf("%d %d\n", &s, &t);
        unite(s,t);
    }
    scanf("%d\n",&q);
     
    for (i = 0; i < q; i++){
        scanf("%d %d\n", &s, &t);
        if  (Judge(s,t) == 1) {
            printf("yes\n");
        }
        else {
            printf("no\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2140
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-100
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}

int main() {
//	file();
	fast();
	int n; cin >> n;
	cout << fixed << setprecision(12);
	cout << 2 * PI * n << endl;
	return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    string ans="NO";
    rep(i,b) if(i*a%b==c) ans="YES";
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  
int main() {
  string s;
  cin >> s;
  ll k=s.size();
  bool a=true;
  if(s[0]!='A'){
    a=false;
  }
  if(s[1]=='C'||s[k-1]=='C'){
    a=false;
  }
  ll cnt=0;
  ll x=0;
  rep(i,k){
    if(s[i]=='C'){
      x=i;
      cnt++;
    }
  }
  if(cnt!=1){
    a=false;
  }
  rep(i,k){
    ll c=0;
    rep(j,26){
      if(s[i]==abc[j]){
        c++;
      }
    }
    if(c==0&&(i!=0&&i!=x)){
      a=false;
    }
  }
  if(a)
    cout << "AC" << endl;
  else
    cout << "WA" << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;

int main() {
	string S;
	cin >> S;
	for (int i = 0;i < S.size() - 1;++i) {
		if (S[i] == 'A' && S[i + 1] == 'C') {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
n = int(input())
task_time = {}
task_limit = {}
for i in range(1,n+1):
    a,b = map(int,input().split())
    task_time[i] = a
    task_limit[i] = b

task_limit_sorted = sorted(task_limit.items(), key=lambda x:x[1])

time = 0
for i in task_limit_sorted:
    time += task_time[i[0]]
    if task_limit[i[0]] < time:
        print ("No")
        exit ()

print ("Yes")


Measured memory_bytes: 64276
K=input()

def find(A):
    n=0
    for letter in A:
        n+=1
        if n%2==0:
            if A[n-1]=="R":
                return True
        if n%2==1:
            if A[n-1]=="L":
                return True

if find(K) ==True:
    print("No")
else :
    print("Yes")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl;
using namespace std;
vector<int>e[100005];
int memo[100005];
int dfs(int src)
{
    if(memo[src]!=-1)
    {
        return memo[src];
    }
    int Size=e[src].size();
    int Max=INT_MIN;
    for(int i=0;i<Size;++i)
    {
        int v=e[src][i];
        Max=max(Max,dfs(v));
    }
    if(!Size)
    {
        return memo[src]=0;
    }
    else
    {
        return memo[src]=1+Max;
    }
}
int main()
{
    int n,m,ans=INT_MIN;
    scanf("%d%d",&n,&m);
    while(m--)
    {
        int n1,n2;
        scanf("%d%d",&n1,&n2);
        e[n1].push_back(n2);
    }
    memset(memo,-1,sizeof memo);
    for(int i=1;i<=n;++i)
    {
        if(memo[i]==-1)
        {
            ans=max(ans,dfs(i));
        }
    }
    printf("%d",ans);
    return 0;
}




Measured memory_bytes: 8192
#include <iostream>
using namespace std;
typedef long long ll;

ll max(ll a, ll b){
    return a > b ? a :b;
}

int N, W;

int main(void){
    // Your code here!
    cin >> N >> W;
    ll w[N];
    ll v[N];
    for(int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }
    
    ll dp[N+1][W+1];
    
    dp[0][0] = 0;
    for(int i = 0; i < N; i++){
        dp[i+1][0] = 0;
    }
    for(int j = 1; j <= W; j++){
        dp[0][j] = 0;
    }
    
    

    for(int i = 0; i < N; i++){
        for(int j = 1; j <= W; j++){
            if(j-w[i] >= 0){
                dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
            } else {
                dp[i+1][j] = dp[i][j];
            } 
            
        }
    }
    
    cout << dp[N][W] << endl;
    
    
    return 0;
}


Measured memory_bytes: 79104
#include <stdio.h>
#include <string.h>
 
int main(void){
  int t,x,i;
  char s[20];
  char a[20];
  scanf("%s",s);
  
  strncpy(a,s+5,2);
  
  x = atoi(a);
  //printf("%d",x);
  if(x<=4){
    printf("Heisei");
  }else{
    printf("TBD");
  }
 
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int>s(n);
	for(int i=0;i<n;i++){
		cin>>s.at(i);
	}
	int m,l;
	m=s.at(0);
	l=s.at(1)-s.at(0);
	for(int i=1;i<n;i++){
		if(s.at(i)<m)m=s.at(i);
		else{
		if(s.at(i)-m>l)l=s.at(i)-m;
		}
	}
	cout<<l<<endl;

}


Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main()
{
	string a,b;
	cin >> a >> b;
	bool flag=true;
	for(int i=0;i<3;i++)
	{
		if(a[i]!=b[3-i-1])
			flag=false;
	}
	cout << (flag ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

def main():
    N = int(input())
    A = list(map(int, input().split()))
    A_sorted = sorted(A)
    A_max = A_sorted[-1]
    A = A_sorted[:-1]
    tansaku = (A_max + 1) // 2
    ok = 0
    ng = len(A) - 1
    if A[ok] > tansaku:
        print(A_max, A[ok])
        exit()
    if A[ng] <= tansaku:
        print(A_max, A[ng])
        exit()
    while ok + 1 < ng:
        center = (ok + ng) // 2
        if A[center] <= tansaku:
            ok = center
        else:
            ng = center
    if tansaku - A[ok] <= A[ng] - tansaku:
        print(A_max, A[ok])
    else:
        print(A_max, A[ng])

if __name__ == "__main__":
    main()

Measured memory_bytes: 14428
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int mnus=0;
    for(int i=0; i<n; i++){
        if(a[i]<0){
            mnus++;
        }
    }
    ll ans=0;
    if(mnus%2){
        int mina=1e9;
        for(int i=0; i<n; i++){
            ans += abs(a[i]);
            if(abs(a[i])<mina){
                mina=abs(a[i]);
            }
        }
        ans = ans - 2*mina;
    }else{
        for(int i=0; i<n; i++){
            ans += abs(a[i]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.*;
        import java.io.*;
        import java.lang.*;
public class Main{
    private static void Solve(){
        Scanner in = new Scanner(System.in);
        int n; n = in.nextInt();
        int []arr = new int[n];
        for(int i=0;i<n;i++) arr[i] = in.nextInt();
        int sum = 0;
        for(int i=0;i<n;i++){
            for(int j=i;j<n;j++){
                if(i!=j)
                    sum += (arr[i]*arr[j]);
            }
        }
        System.out.println(sum);
    }
    public static void main(String []args){
        Solve();
    }
}

Measured memory_bytes: 23764
#include<cstdio>
#include<iostream>
#include<cstring>
#define RI register int
#define CI const int&
using namespace std;
const int N=105;
int n,m,f[N][N][2]; char a[N][N];
int main()
{
	RI i,j; for (scanf("%d%d",&n,&m),i=1;i<=n;++i) scanf("%s",a[i]+1);
	memset(f,127,sizeof(f)); if (a[1][1]=='.') f[1][1][0]=0; else f[1][1][1]=1;
	for (i=1;i<=n;++i) for (j=1;j<=m;++j) if (i!=1||j!=1)
	if (a[i][j]=='.') f[i][j][0]=min(min(f[i-1][j][0],f[i-1][j][1]),min(f[i][j-1][0],f[i][j-1][1]));
	else f[i][j][1]=min(min(f[i-1][j][0]+1,f[i-1][j][1]),min(f[i][j-1][0]+1,f[i][j-1][1]));
	return printf("%d",a[n][m]=='.'?f[n][m][0]:f[n][m][1]),0;
}

Measured memory_bytes: 384
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii;
import std.typecons, std.functional;
import std.algorithm, std.container;

struct Cake
{
    long x, y, z;
}
void main()
{
    long N = scanElem;
    long M = scanElem;
    if(M==0){
        writeln(0);
        return;
    }
    Cake[] cakes;
    scanStructs(cakes, N);
    long res;
    foreach(i; 0..1<<4)
    {
        long xSig = (((i>>1)&1)==1?1:-1);
        long ySig = (((i>>2)&1)==1?1:-1);
        long zSig = (((i>>3)&1)==1?1:-1);
        long n = cakes.map!(a=>a.x*xSig+a.y*ySig+a.z*zSig).array.sort!"a>b".take(M).fold!"a+b";
        res = max(res, n);
    }
    writeln(res);
}

void scanValues(TList...)(ref TList list)
{
    auto lit = readln.splitter;
    foreach (ref e; list)
    {
        e = lit.fornt.to!(typeof(e));
        lit.popFront;
    }
}

T[] scanArray(T = long)()
{
    return readln.split.to!(long[]);
}

void scanStructs(T)(ref T[] t, size_t n)
{
    t.length = n;
    foreach (ref e; t)
    {
        auto line = readln.split;
        foreach (i, ref v; e.tupleof)
        {
            v = line[i].to!(typeof(v));
        }
    }
}

T scanElem(T = long)()
{
    string res;
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        res ~= cast(char) c;
        c = getchar;
    }
    return res.strip.to!T;
}

template fold(fun...) if (fun.length >= 1)
{
    auto fold(R, S...)(R r, S seed)
    {
        static if (S.length < 2)
        {
            return reduce!fun(seed, r);
        }
        else
        {
            import std.typecons : tuple;

            return reduce!fun(tuple(seed), r);
        }
    }
}

struct Factor
{
    long n;
    long c;
}

Factor[] factors(long n)
{
    Factor[] res;
    for (long i = 2; i ^^ 2 <= n; i++)
    {
        if (n % i != 0)
            continue;

        int c;
        while (n % i == 0)
        {
            n = n / i;
            c++;
        }
        res ~= Factor(i, c);
    }
    if (n != 1)
        res ~= Factor(n, 1);

    return res;
}

bool isPrime(long n)
{
    if (n <= 1)
        return false;
    if (n == 2)
        return true;
    if (n % 2 == 0)
        return false;
    for (long i = 3; i ^^ 2 <= n; i += 2)
        if (n % i == 0)
            return false;
    return true;
}

Measured memory_bytes: 2556
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, long long> pdl;

const long double pi = 3.141592653589793;

#define debug(x) cerr << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

ll X[1<<20];
ll Y[1<<20];

int main() {
  	//freopen("input.in","r",stdin);
  	//freopen("output.out","w",stdout);

	int n, m; cin>>n>>m;
	rep(i, n) cin>>X[i+1];
	rep(i, m) cin>>Y[i+1];

	ll sumx = 0, sumy = 0;
	for(ll i = 1;i < m;i++) {
		sumy = sumy + (((((i*(m-i))%mod)*((Y[i+1]-Y[i])%mod)))%mod);
		sumy %= mod;
	}

	for(ll i = 1;i < n;i++) {
		sumx = sumx + (((((i*(n-i))%mod)*((X[i+1]-X[i])%mod)))%mod);
		sumx %= mod;
	}

	cout<<(sumx*sumy)%mod<<endl;

	return 0;
}


Measured memory_bytes: 3072
n = int(input())
abc = [list(map(int, input().split())) for _ in range(n)]
dp = [[None]*3 for _ in range(n)]
dp[0] = abc[0]
m = [[0, [1, 2]], [1, [0, 2]], [2, [0, 1]]]
for i in range(1, n):
    abci = abc[i]
    for j, k in m:
        dp[i][j] = max(dp[i-1][k[0]]+abci[j], dp[i-1][k[1]]+abci[j])
print(max(dp[-1]))

Measured memory_bytes: 47348
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for(int i=0; i<(int)(N); i++)

int N;

int main(){
  cin>>N;
  int H[N+1];
  rep(i, N) cin>>H[i];
  bool flg=true;
  for(int i=N-2; i>=0; i--) {
    if (H[i]==H[i+1]+1) H[i]=H[i]-1;
    if(H[i]>H[i+1]+1) {
      flg = false;
      break;
    }
  }
  cout<<((flg==true) ? "Yes":"No")<<endl;
}


Measured memory_bytes: 640
S=input()
N=int(input())

from collections import*
D=deque(S)
count=0
for _ in range(N):
    *Q,=input().split()
    if len(Q)==1:
        count+=1
    else:
        if (count+int(Q[1]))%2:
            D.appendleft(Q[2])
        else:
            D.append(Q[2])
ans=''.join(D)
print(ans[::-1] if count%2 else ans)

Measured memory_bytes: 14492
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>


using namespace std;

typedef long long ll;

const ll INF = 1ll << 60;

int main(void){
	int p, q, r;

	cin >> p >> q >> r;

	int a[3] = { p, q, r };

	int ans = 1e9;
	for (int i = 0; i < 3; i++){
		for (int j = 0; j < 3; j++){
			if (i == j)continue;
			ans = min(ans, a[i] + a[j]);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n, y;
    cin >> n >> y;
    int m,f,s;
    bool find = false;
    REP(i,n+1) REP(j,n+1-i) {
        int k = n-i-j;
        if (10000*i + 5000*j + 1000*k == y) {
            find = true;
            m = i; f = j; s = k;
        }
    }
    if (find) cout << m << " " << f << " " << s << endl;
    else cout << "-1 -1 -1" << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,p;
    cin>>a>>b>>c>>d>>p;
    int x;
    int y;
    x=a*p;//x社の料金
    if(p<=c)    y=b;
    else    y=b+(p-c)*d;
    if(x<y) cout<<x;
    else    cout<<y;
    cout<<endl;
    
}



Measured memory_bytes: 3100
//tenka1_2019_b.cpp
//Tue Apr 30 16:41:59 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	int k;
	cin >> k;

	char substletter = s[k-1];

	for (int i=0;i<n;i++){
		if (s[i] != substletter){
			cout << "*";
		}else {
			cout << s[i];
		}
	}

	printf("\n");
//	cout << s << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    string s;
    cin >> s;

    int ans = 0;
    for(int in=0;in<s.size();in++) {
        ans += s.at(in)-'0';
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque


def main():
    N, M = map(int, input().split())
    prv = [0] * (N+1)
    nxt = [[] for _ in range(N+1)]
    path = [0] * (N+1)
    for _ in range(M):
        x, y = map(int, input().split())
        prv[y] += 1
        nxt[x].append(y)
    q = deque()
    for i in range(1, N+1):
        if prv[i] == 0:
            q.append(i)
    while len(q):
        cur = q.popleft()
        for adj in nxt[cur]:
            path[adj] = max(path[adj], path[cur] + 1)
            prv[adj] -= 1
            if prv[adj] == 0:
                q.append(adj)
    print(max(path))


if __name__ == "__main__":
    main()


Measured memory_bytes: 61472
#include <bits/stdc++.h>
using namespace std;
#define int                     long long   
#define double                  long double
#define endl                    "\n"
#define pb                      push_back
#define PI                      3.1415926535897932384626433832795l
#define F                       first
#define S                       second
#define mp                      make_pair
#define f(i,n)                  for(int i=0;i<n;i++)
#define fastio                  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)                  (v).begin(),(v).end()
#define rall(v)                 (v).rbegin(),(v).rend()
#define gcd(a,b)                __gcd((a),(b))
#define fill(a,value)           memset(a,value,sizeof(a));
#define minn(v)                 *min_element(v.begin(), v.end());
#define maxx(v)                 *max_element(v.begin(), v.end());
#define print(x)                cout<<(x)<<endl;
#define sum(v)+x                accumulate(v.begin(), v.end(),x);
#define debug(x)                cout<<#x<<'='<<(x)<<endl;
typedef pair<int,int>           pii;
typedef vector<int>             vi;

signed main() 
{
    fastio;
    cout << fixed << setprecision(12);
    int n,k;
    cin>>n>>k;
    vi a;
    f(i,n)
    {
        int x;
        cin>>x;
        a.pb(x);
    }
    sort(all(a));
    int minn=INT_MAX;
    for(int i=k-1;i<n;i++)
    {
        minn=min(a[i]-a[i-k+1],minn);
    }
    print(minn)
    return 0;
}


Measured memory_bytes: 4280
require 'pp'

# Nと空白区切の入力値を数値の配列で返却する
def gets_n_and_i_list()
  return gets.chomp.to_i, gets.chomp.split(" ").map(&:to_f)
end

N, v_list = gets_n_and_i_list

v_list.sort!

1.upto(v_list.size - 1) do |i|
  v_list[i] = (v_list[i] + v_list[i - 1]) / 2
end

puts v_list.last



Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;


int main(){
    int N, X; cin >> N >> X;
    vector<int> m(N);
    rep(i, N){
        cin >> m[i];
        X -= m[i];
    }
    sort(all(m));
    int ans = N;
    ans += X / m[0];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;
long long doforb(long long b,long long c){
    if(c>b){
        c-=b;
        b = 0;
    }else if(c==b){
        c-=b;
        b= 0;
    }else{
        b-=c;
        c= 0;
    }
    return b;
}
int main()
{
    long long a,b,c; cin>>a>>b>>c;
    if(c>a){
        c-=a;
        a = 0;
        b = doforb(b,c);
    }else if(c==a){
        c-=a;
        a= 0;
    }else{
        a-=c;
        c= 0;
    }
    cout<<a<<" "<<b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
using namespace std;

int main()
{
	string str;
	stack<string> s;
	int a, b;

	while (1)
	{
		cin >> str;
		if (cin.eof() == true){
			break;
		}
		else{
			s.push(str);
			if (s.top() == "+"){
				s.pop();
				a = stoi(s.top());
				s.pop();
				b = stoi(s.top());
				s.pop();
				s.push(to_string(b + a));
			}
			if (s.top() == "-"){
				s.pop();
				a = stoi(s.top());
				s.pop();
				b = stoi(s.top());
				s.pop();
				s.push(to_string(b - a));
			}
			if (s.top() == "*"){
				s.pop();
				a = stoi(s.top());
				s.pop();
				b = stoi(s.top());
				s.pop();
				s.push(to_string(b * a));
			}
		}
	}

	cout << s.top() << endl;

	return 0;
}

Measured memory_bytes: 3268
#include "bits/stdc++.h"
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i ++)

vector<int> g[101010];
int d[2][101010];

void dfs(int v, int p, int step, int w) {
        d[w][v] = step;
        for (auto u : g[v]) {
                if (u == p) continue;
                dfs(u, v, step + 1, w);
        }
}
int main() {
        int n;
        cin >> n;
        for (int i = 0; i < n - 1; i ++) {
                int a, b;
                cin >> a >> b;
                a --, b --;
                g[a].push_back(b);
                g[b].push_back(a);
        }
        dfs(0, -1, 0, 0);
        dfs(n - 1, -1, 0, 1);
        int cnt1 = 0, cnt2 = 0;
        for (int i = 0; i < n; i ++) {
                if (d[0][i] <= d[1][i]) cnt1 ++;
                else cnt2 ++;
        }
        cout << (cnt1 > cnt2 ? "Fennec" : "Snuke") << endl;
        return 0;
}



Measured memory_bytes: 12800
#include <algorithm>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
int N;
long long A[100010];
long long dp[100010][2];
int GCD(long long x, long long y) { return x ? GCD(y % x, x) : y; }
int main() {
    int N;
    cin >> N;
    rep(i, 0, N) cin >> A[i];
    int odd = 1;
    int zero = 0;
    rep(i, 0, N) {
        if(A[i] < 0) {
            odd *= -1;
        } else if(A[i] == 0) {
            zero = 1;
        }
    }
    long long res = 0;
    if(odd == 1 || zero == 1) {
        rep(i, 0, N) res += abs(A[i]);
    } else {
        long long min = INF;
        rep(i, 0, N) {
            if(abs(A[i]) < min) {
                min = abs(A[i]);
            }
        }
        rep(i, 0, N) res += abs(A[i]);
        res -= min;
        res -= min;
    }
    cout << res << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

#define MAX 500000
#define SEN 2000000000

void merge(int *,int,int,int);
void mergeSort(int *,int,int);


int L[MAX/2+2];
int R[MAX/2+2];
int count=0;


int main(){
  int A[MAX];
  int i;
  int n;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }


  mergeSort(A,0,n);

  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i!=n-1)printf(" ");
  }
  printf("\n");
  printf("%d\n",count);

  return 0;
}

void merge(int* A,int left,int mid,int right){
  int i,j=0,k=0;
  int nm1=mid-left;
  int nm2=right-mid;
  for(i=0;i<nm1;i++){
    L[i]=A[left+i];
  }
  for(i=0;i<nm2;i++){
    R[i]=A[mid+i];
  }
  L[nm1]=SEN;
  R[nm2]=SEN;
  i=0;
  for(k=left;k<right;k++){
    count++;
    if(L[i]<=R[j]){
      A[k]=L[i++];
    }else{
      A[k]=R[j++];
    }
  }
}

void mergeSort(int* A,int left,int right){
  int mid;
  if((left+1)<right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

Measured memory_bytes: 4508
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import Data.Bool
import Data.Maybe

main :: IO ()
main = do
  [x] <- readInts
  print . showAnswer $ solve x

type Input  = Int
type Output = Bool

solve :: Input -> Output
solve = flip elem [7,5,3]

showAnswer :: Output -> Answer
showAnswer = YESNO

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

data Answer
  = YesNo Bool
  | YESNO Bool
  | AB Bool
  | Number Int
  | String String
  | Compare Ordering
  | Compare2 Ordering

instance Show Answer where
  show (YesNo b)    = bool "No" "Yes" b
  show (YESNO b)    = bool "NO" "YES" b
  show (AB b)       = bool "B"  "A" b
  show (Number i)   = show i
  show (String s)   = s
  show (Compare o)  = ordering "<" "=" ">" o
  show (Compare2 o) = ordering "Right" "Balanced" "Left" o

ordering :: a -> a -> a -> Ordering -> a
ordering lt eq gt o = case o of
  LT -> lt
  EQ -> eq
  GT -> gt

Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) ;

int dx[4]{0, 1, 0, -1};
int dy[4]{1, 0, -1, 0};


int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll N, K; cin >> N >> K;
	vector<ll> A(N); REP(i, N) cin >> A[i], --A[i];
	DEBUG("pass23");

	ll logK{0};
	while ((1ll << logK) < K) ++logK;

	DEBUG("pass10");

	vector<vector<ll>> ding(logK, vector<ll>(N));
	REP(i, N)
		ding[0][i] = A[i];

	DEBUG("pass100");
	

	REP(k, logK-1)
	{
		REP(i, N)
		{
			DEBUG("pass2");
			// ll ne = ding[k][i];
			// ll ne2 = ding[k][ne];
			// ding[k+1][i] = ne2;
			ding[k+1][i] = ding[k][ding[k][i]];
		}
	}

	DEBUG("pass");
	ll now{0};
	for (ll bit = 0; ;++bit)
	{
		if (K & 1) now = ding[bit][now];
		K = K >> 1;
		if (K == 0) break;
	}

	std::cout << now + 1<< std::endl;
	return 0;
}


Measured memory_bytes: 100072
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
//#define N 100010
//#define M 61
//#define MOD 100003
//vector <pair<int,int> > edge[M];
//int d[N][N];
//priority_queue <pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> > >q;
//queue <int> q;
//ll cnte[N];
//int ans=0;
//vector <int> edge[N];
//int arr[N];
void solve()
{
	int n;
	cin>>n;
	int ac=0,wa=0,tle=0,re=0;
	for (int i=1;i<=n;i++)
	{
		string s;
		cin>>s;
		if (s=="AC")
			ac++;
		else if (s=="WA")
			wa++;
		else if (s=="TLE")
			tle++;
		else if (s=="RE")
			re++;
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
//	int t;
//	cin>>t;
//	while (t--)
		solve();
	return 0;
} 

Measured memory_bytes: 3672
#include <bits/stdc++.h>

using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (int i = (s); i < (int)(n+1); i++)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
int main() {
const ll INF = 100100100100100100;
int K;
string S;
cin>>K>>S;
if(S.size()<=K)cout<<S<<endl;
else cout<<S.substr(0,K)+"..."<<endl;

return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back

#define ll long long

const int MOD = 1e9+7;

int n,m;
const int N=1e5+5;
vector<int> adj[N];
int dp[N];
int maxans=0;
vector<int> vis(N,0);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,m;
    cin>>n>>m;
    int arr[n][m];
    char a;
    int dp[n][m];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>a;
            arr[i][j]=((a=='.')?1:0);
            dp[i][j]=0;
        }
    }

    dp[0][0]=1;

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(i==0&&j==0)
                continue;
            dp[i][j]=0;
            if(!arr[i][j])
                continue;
            if(i>0)
                dp[i][j] += dp[i-1][j];
            if(j>0)
                dp[i][j] += dp[i][j-1];
            dp[i][j]%=MOD;
        }
    }

    cout<<dp[n-1][m-1];
    return 0;
}

Measured memory_bytes: 10752
#include <iostream>
using namespace std;

#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

const double PI = 3.14;


int main()
{
	uint64_t a1;
	cin >> a1;

	vector< string > vec( a1 );

	for( int i=0 ; i<a1 ; i++ )
	{
		cin >> vec[ i ];
	}

	sort( vec.begin(), vec.end() );

	vector< string > diff;
	string now;
	int max = 0;
	int cnt = 0;


	for( auto &it : vec )
	{
		if( now.empty() )
		{
			now = it;
			cnt ++;
		}
		else if( now == it )
		{
			cnt ++;
		}
		else
		{
			if( cnt == max )
			{
				diff.emplace_back( now );
			}
			else if( cnt > max )
			{
				diff.clear();
				diff.emplace_back( now );
				max = cnt;
			}
			cnt = 1;
			now = it;
		}
	}


	if( cnt == max )
	{
		diff.emplace_back( now );
	}
	else if( cnt > max )
	{
		diff.clear();
		diff.emplace_back( now );
		max = cnt;
	}


	for( auto &it : diff )
	{
		cout << it << endl;
	}

	return 0;
}

Measured memory_bytes: 15988
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main(void) {
    string S;
    cin >> S;

    int ans = 10000;
    int acc = 0;
    for (int i = 0; i < (int) S.size(); i++) {
        int d = S[i] - '0';
        acc = (acc * 10 + d) % 1000;
        // printf("acc: %d\n", acc);
        if (i >= 2) {
            chmin(ans, abs(acc - 753));
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  map<char,ll> ans;
  for(ll i=0;i<n;i++) {
    string tmp;
    cin >> tmp;
    map<char,ll> cnt;
    if(i==0) {
      for(ll j=0;j<tmp.size();j++) {
        ans[tmp[j]]++;
      }
    }
    else {
      for(ll j=0;j<tmp.size();j++) {
        cnt[tmp[j]]++;
      }
      for(auto p:ans) {
        ans[p.first]=min(p.second,cnt[p.first]);
      }
    }
  }
  for(auto p:ans) {
    ll num=p.second;
    while(num-->0) {
      cout << p.first;
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;

#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define lli long long int
#define pb push_back
#define pob pop_back
#define rep(i,a,b) for(lli i=a;i<b;i++)
#define repv(a,b) for(int i=a;i>=b;i--)
#define itr vector<lli> :: iterator
#define maximum(a,b,c)  max(a,max(b,c))
#define minimum(a,b,c) min(a,min(b,c))
#define tim clock_t

inline void fast()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}


void solve()
{
	string s1,s2;
  cin>>s1>>s2;
  lli ctr=0;
  rep(i,0,3)
  {
    if(s1[i]==s2[i])
      	ctr++;
  }
  cout<<ctr<<"\n";
}

int main()
{
	fast();
	lli t=1,n,m;
	
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
d = [list(map(int, input().split())) for i in range(a[2])]
e = [min(b) + min(c)]
for f in d:
  e.append(b[f[0] - 1] + c[f[1] - 1] - f[2])
print(min(e))  


Measured memory_bytes: 42400
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
  string S;
  int MIN=999;
  cin >> S;
  for(int i=0;i<S.length()-2;++i){
    int T = ctoi(S[i])*100 + ctoi(S[i+1])*10 + ctoi(S[i+2]);
    int diff = abs(753-T);
    if(MIN>diff){
      MIN = diff;
    }
  }
  cout << MIN << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	int n,m;
	pair<int,int> ba[100000];
	int ans=0;
	
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		ba[i]=make_pair(b,a);
	}

	sort(ba,ba+m);
	int pre=ba[0].first-1;
	ans=1;
	for(int i=1;i<m;i++)
	{
		if(ba[i].second>pre)
		{
			ans++;
			pre=ba[i].first-1;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	string s; cin >> s;
	bool b[26] = {};

	rep(i, 0, s.size()) {
		if (b[s[i] - 'a']) {
			cout << "no" << endl;
			return 0;
		}
		b[s[i] - 'a'] = true;
	}
	cout << "yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll modinv(ll a, ll m) {ll b = m, u = 1, v = 0;while (b) {ll t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
const int INF = 1e9;
const ll LLINF = 1e16;

int main(void)
{
    ll n;
    string s;
    cin >> n;
    cin >> s;
    vector<ll> mrrp;
    vector<ll> mlwp;
    for (int i = n-1; i >= 0; i--)
    {
        if(s[i] == 'R'){
            mrrp.push_back(i);
        }
    }
    for (int i = 0; i < n; i++)
    {
        if(s[i] == 'W'){
            mlwp.push_back(i);
        }
    }
    int m = min(mrrp.size(), mlwp.size());
    ll cnt = 0;
    for (int i = 0; i < m; i++)
    {
        if(mrrp[i] > mlwp[i]){
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 5812
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main() {
	/*int n;
	cin >> n;
	double ans = (n+1) / 2;
	ans /= (double)n;
	cout << setprecision(7) << ans;*/


	/*int n, k;
	cin >> n >> k;
	int h;
	int ans = 0;
	rep(i, n) {
		cin >> h;
		if (h >= k)ans++;
	}
	cout << ans;*/


	int n;
	cin >> n;
	int a;
	vector<int>ans(n);
	rep(i, n) {
		cin >> a;
		a--;
		ans[a] = i + 1;
	}
	rep(i, n)cout << ans[i] << " ";
	return 0;
}

Measured memory_bytes: 1152