akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

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

constexpr ll INF = 1ll<<60;

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; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, K, S, T;
std::vector<ll> as, bs;
bool fl[20];
ll comb[100][100];
ll coef[100];
ll ans;

int main() {
  comb[0][0] = 1;

  repi( i, 1, 100 ) {
    comb[i][0] = comb[i][i] = 1;

    repi( j, 1, i )
      comb[i][j] = comb[i-1][j]+comb[i-1][j-1];
  }

  std::cin >> N >> K >> S >> T;

  rep( i, 100 ) repi( j, 1, std::min( i+1, K+1 ) ) {
    coef[i] += comb[i][j];
  }

  bool fl = false;

  rep( b, 18 ) {
    ll s = S>>b&1 , t = T>>b&1;

    if( !s && t )
      bs.emplace_back( b );

    if( s && !t )
      fl = true;
  }

  rep( i, N ) {
    ll A;
    std::cin >> A;

    rep( b, 18 ) {
      ll s = S>>b&1 , t = T>>b&1;
      ll x = A>>b&1;

      if( s == 1 && !x )
        goto end;
      if( !t && x )
        goto end;
    }

    as.emplace_back( A );

end:;
  }

  if( fl ) {
    std::cout << 0 << std::endl;

    return 0;
  }

  rep( bit, 1ll<<(bs.size()) ) {
    ll mask = 0;

    rep( i, bs.size() ) if( bit>>i&1 )
      mask |= 1ll<<bs[i];

    std::map<ll, ll> mp;
    
    rep( i, as.size() )
      ++mp[as[i]&mask];

    ll sum = 0;

    itr( it, mp )
      sum += coef[it->second];

    ans += (__builtin_popcountll(bit)&1 ? -1 : 1)*sum;
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

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

    sort(ab,ab+n);
    long long int ans=0;
    int drink=0;
    for(int i=0;i<n;++i){
        if(drink + ab[i].second <= m){
            ans += ab[i].first * ab[i].second;
            drink += ab[i].second;
        }
        else{
            long long amari = m-drink;
            ans += ab[i].first * amari;
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
template<typename T> vector<int> z_algorithm(const int len, const T& in) {
  vector<int> res(len, 0);
  int c = 0;
  for (int i = 1; i < len; ++i) {
    if (i + res[i - c] < c + res[c]) {
      res[i] = res[i - c];
    } else {
      int j = max(0, c + res[c] - i);
      while (i + j < len && in[j] == in[i + j]) j++;
      res[i] = j;
      c = i;
    }
  }
  res[0] = len;
  return res;
}

template<typename T> vector<int> z_algorithm(const T& in) {
  return z_algorithm((int) in.size(), in);
}

template<typename T> vector<int> z_algorithm(const T& in_first, const T& in_second) {
  T combined = T();
  combined.insert(combined.end(), in_first.begin(), in_first.end());
  combined.insert(combined.end(), in_second.begin(), in_second.end());
  // combined.append(in_first);
  // combined.append(in_second);
  int n = (int) in_first.size(), m = (int) in_second.size();
  vector<int> v = z_algorithm(n + m, combined);
  vector<int> res(m);
  for (int i = 0; i < m; i++) {
    res[i] = min(n, v[i + n]);
  }
  return res;
}

signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  vector<int> aa(n + n), bb(n + n);
  for (int i = 0; i < n; i++) {
    aa[i] = a[i] ^ a[(i + 1) % n];
    bb[i] = b[i] ^ b[(i + 1) % n];
  }
  for (int i = n; i < n + n; i++) {
    aa[i] = aa[i - n];
    bb[i] = bb[i - n];
  }
  // for (int i = 0; i < n + n; i++) cerr << aa[i] << " ";
  // cerr << endl;
  // for (int i = 0; i < n + n; i++) cerr << bb[i] << " ";
  // cerr << endl;
  auto res = z_algorithm(bb, aa);
  vector<pair<int, int>> ans;
  for (int i = 0; i < n; i++) {
    //cerr << res[i] << endl;
    if (res[i] >= n) {
      ans.emplace_back(i, b[0] ^ a[i]);
    }
  }
  for (auto p : ans) {
    cout << p.first << " " << p.second << '\n';
  }
  return 0;
}

Measured memory_bytes: 13300
import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;
import java.math.BigInteger;

public class Main {
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = in.nextInt();
        double need = in.nextDouble();
        int count = 0;
        while(n-->0){
            long a = in.nextLong();
            long b = in.nextLong();
            double ans = Math.sqrt((a*a)+(b*b));
            if(ans<=need){
                ++count;
            }
        }
        out.println(count);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext() {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
    }
}



Measured memory_bytes: 56624
#include <bits/stdc++.h>
#define TARUNNO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
   #define INF 99999
   #define MAX 100000
   #define pb push_back
   #define pf push_front
   #define pob pop_back
   #define pof pop_front
   #define ins insert
   #define mp make_pair
   #define F first
   #define S second
   #define Endl endl
   #define PII pair<ll,ll>
   #define pii pair<int, int>
   #define PIPII pair<ll , pair<ll, ll> >
#define testing() {cout<<"OK"<<endl;}
#define array(a,n) for(int i=0;i<int(n);i++){cout<<a[i];}
#define vector(v) for(int i=0;i<v.size();i++){cout<<v[i]<<" ";}cout<<endl;
using namespace std;
template<typename T>
string to_string(T str){stringstream stream;stream << str;return stream.str();}


int main(){
    TARUNNO;
    string s, t;
    cin>>s>>t;
    cout<<t+s<<endl;
    return 0;
}



                             //   C O M F O R T A B L Y   N U M B   //


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
int N,i,sum=0;
cin>>N;
vector<int> a(N);
for(i=0;i<N;i++){
 cin>>a[i];
}
sort(a.begin(),a.end());
i=N-1;
if(N%2==0){
while(i-1>=0){
 sum=sum+a[i]-a[i-1];
 i=i-2;
}
cout<<sum<<endl;
}
if(N%2!=0){
while(i>=2){
  sum=sum+a[i]-a[i-1];
 i=i-2;
}
sum+=a[0];
cout<<sum<<endl;
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) {return s + d + t;})
#define all(a) a.begin(), a.end()
// #define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int N;
  cin >> N;
  vector<int> H(N);
  rep(i, 0, N) {
    cin >> H[i];
  }
  int ans = 0;
  bool flag = false;
  while (sum(H)) {
    rep(i, 0, N) {
      if (H[i]) {
        --H[i];
        flag = true;
      } else {
        if (flag) ++ans;
        flag = false;
      }
    }
    if (flag) ++ans;
    flag = false;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
using namespace std;

long long A[10],B[10];
int main(){
	int N,M;
	cin >> N >> M;
	for(int i = 0 ; i < N ; i++) cin >> A[i];
	for(int i = 0 ; i < M ; i++) cin >> B[i];

	map<long long,int> o;
	for(int i = 0 ; i < N ; i++){
		for(long long j = 1 ; j*j <= A[i] ; j++){
				if( A[i] % j == 0 ){
				long long a = A[i] / j;
				long long b = j;
				int af = 1;
				int bf = 1;
				for(int k = 0 ; k < M ; k++){
					if( a%B[k] != 0 ) af = 0;
					if( b%B[k] != 0 ) bf = 0;
				}
				if( af ) o[a] |= (1<<i);
				if( bf ) o[b] |= (1<<i);
			}
		}
	}
	int ans = 0;
	for( map<long long,int>::iterator it = o.begin(); it != o.end(); ++it){
		if( it->second == (1<<N)-1 ) ans++;
	}
	cout << ans << endl;
	
	
}


Measured memory_bytes: 1844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// check if it is judged online
int n;
int main() {
#ifdef LOCAL
	freopen("textname.in", "r", stdin);
	freopen("textname.out", "w", stdout);
#endif
	cin >> n;
	for (int i = 1; i <= 9; ++i)
		for (int j = 1; j <= 9; ++j)
			if (n == (i * j)) {
				puts("Yes");
				return 0;
			}
	puts("No");
	return 0;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define for_each(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = __INT_MAX__;               // 2^31 - 1
const long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);
typedef long double ld;

int main() {
    ld a, b, c;
    cin >> a >> b >> c;
    ld l = (ld)sqrt(a * b) * 2;
    ld r = c - b - a;
    if (l < r)
        CYES;
    else
        CNO;
    return 0;
}


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

int row,column,op;
map<pair<int,int>,int>ma;
map<int,long long >ma2;
int main()
{
 scanf("%d%d%d",&row,&column,&op);
 long long  l1=row-2;
 long long l2=column-2;
 ma2[0]=l2*l1;
// for(int i=0;i<=9;i++)cout<<ma2[i]<<endl;
 //cout<<"??????????????????"<<endl;
 for(int i=1;i<=op;i++)
 {
     int n1,n2;
     scanf("%d%d",&n1,&n2);
     if(n1-2>=1&&n2-2>=1)
     {
        // if(ma2[ma[make_pair(n1-2,n2-2)]]!=0)
         ma2[ma[make_pair(n1-2,n2-2)]]--;
         ma[make_pair(n1-2,n2-2)]++;
         ma2[ma[make_pair(n1-2,n2-2)]]++;

     }
     if(n1-2>=1&&n2-1>=1&&n2<=column-1)
     {
       //  if(ma2[ma[make_pair(n1-2,n2-1)]]!=0)
         ma2[ma[make_pair(n1-2,n2-1)]]--;
         ma[make_pair(n1-2,n2-1)]++;
         ma2[ma[make_pair(n1-2,n2-1)]]++;
     }
     if(n1-2>=1&&n2>=1&&n2<=column-2)
     {
      //   if(ma2[ma[make_pair(n1-2,n2)]]!=0)
         ma2[ma[make_pair(n1-2,n2)]]--;
         ma[make_pair(n1-2,n2)]++;
         ma2[ma[make_pair(n1-2,n2)]]++;
     }
     if(n1-1>=1&&n2-2>=1&&n1<=row-1)
     {
        // if(ma2[ma[make_pair(n1-1,n2-2)]]!=0)
         ma2[ma[make_pair(n1-1,n2-2)]]--;
         ma[make_pair(n1-1,n2-2)]++;
         ma2[ma[make_pair(n1-1,n2-2)]]++;
     }
     if(n1-1>=1&&n2-1>=1&&n1<=row-1&&n2<=column-1)
     {
        // if(ma2[ma[make_pair(n1-1,n2-1)]]!=0)
         ma2[ma[make_pair(n1-1,n2-1)]]--;
         ma[make_pair(n1-1,n2-1)]++;
         ma2[ma[make_pair(n1-1,n2-1)]]++;
     }
     if(n1-1>=1&&n2>=1&&n1<=row-1&&n2<=column-2)
     {
        // if(ma2[ma[make_pair(n1-1,n2)]]!=0)
         ma2[ma[make_pair(n1-1,n2)]]--;
         ma[make_pair(n1-1,n2)]++;
         ma2[ma[make_pair(n1-1,n2)]]++;
     }
     if(n1>=1&&n2-2>=1&&n1<=row-2)
     {
        // if(ma2[ma[make_pair(n1,n2-2)]]!=0)
         ma2[ma[make_pair(n1,n2-2)]]--;
         ma[make_pair(n1,n2-2)]++;
         ma2[ma[make_pair(n1,n2-2)]]++;
     }
     if(n1>=1&&n2-1>=1&&n1<=row-2&&n2<=column-1)
     {
        // if(ma2[ma[make_pair(n1,n2-1)]]!=0)
         ma2[ma[make_pair(n1,n2-1)]]--;
         ma[make_pair(n1,n2-1)]++;
         ma2[ma[make_pair(n1,n2-1)]]++;
     }
     if(n1>=1&&n2>=1&&n1<=row-2&&n2<=column-2)
     {
         //if(ma2[ma[make_pair(n1,n2)]]!=0)
         ma2[ma[make_pair(n1,n2)]]--;
         ma[make_pair(n1,n2)]++;
         ma2[ma[make_pair(n1,n2)]]++;
     }
 }




  for(int i=0;i<=9;i++)cout<<ma2[i]<<endl;

}


Measured memory_bytes: 56448
#include<iostream>
using namespace std;
int main() {
	int N, M, a, b, city[50];
	cin >> N >> M;
	for (int i = 0;i < N;i ++) city[i] = 0;
	for (int i = 0;i < M;i ++) {
		cin >> a >> b;
		city[a-1] ++;
		city[b-1] ++;
	}
	for (int i = 0;i < N;i ++) {
		cout << city[i];
		if (i != N - 1) cout << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<map>
#define ll long long
#define INF 0x3f3f3f3f
#define N 200005
using namespace std;
struct node{
	int data,num;
}e[N];
bool cmp(node a,node b)
{
	return a.num>b.num;
}
map<int,int> ma;
int a[N];

int main()
{
	int n,k;
	cin>>n>>k;
	ma.clear();
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		ma[a[i]]++;
	}
	int d=0;
	map<int,int>::iterator it;
	for(it=ma.begin();it!=ma.end();it++)
	{
		e[d].data=it->first;;
		e[d++].num=it->second;
	}
	sort(e,e+d,cmp);
	if(d<=k){
		printf("0\n");
		return 0;
	}
	int ans=0;
	for(int i=k;i<d;i++)
	ans+=e[i].num;
	printf("%d\n",ans);
	return 0;
}

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

int main(){
    int N; cin>>N;
    double sum = 0;
    rep(i, N){
        double x;
        string u;
        cin>>x>>u;
        if(u == "BTC")
            x *= 380000;
        sum += x;
    }

    cout << fixed << setprecision(5) << sum << endl;
}


Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,L=MI()
    S=[ST() for _ in range(N)]
    S.sort()
    print(*S,sep="")
if __name__ == '__main__':
    main()

Measured memory_bytes: 6864
#include <stdio.h>
#include <iostream>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

int main() {
    int N;
    cin >> N;

    int ai;
    int cnt4 = 0;
    int cnte = 0;
    int cnto = 0;
    REP(0, i, N) {
        cin >> ai;

        if (ai % 4 == 0) {
            cnt4++;
            continue;
        }

        if (ai % 2 == 0) {
            cnte++;

            if (cnte % 2 == 0) {
                cnte--;
            }

            continue;
        }

        cnto++;
    }

    // cout << "N=" << N << endl;
    // cout << "cnt4=" << cnt4 << endl;
    // cout << "cnto=" << cnto << endl;
    // cout << "cnte=" << cnte << endl;
    if (cnte + cnto - cnt4 > 1) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(void){
    int n,cnt=1;
    char c;
    char str[100000];
    scanf("%d",&n);
    scanf("%s",str);
    c=str[0];
    for(int i=1;i<n;i++){
        if(str[i]!=c){
            c=str[i];
            cnt++;
        }
    }
    printf("%d",cnt);
    return 0;
}

Measured memory_bytes: 256
from math import sqrt
x1, y1 = map(int, raw_input().split())
x0, y0, r0 = map(int, raw_input().split())

def solve(x1, y1, r1, x2, y2, r2):
    rr0 = (x2 - x1)**2 + (y2 - y1)**2
    xd = x2 - x1
    yd = y2 - y1
    rr1 = r1**2; rr2 = r2**2
    cv = (rr0 + rr1 - rr2)
    sv = sqrt(4*rr0*rr1 - cv**2)
    return (
        (x1 + (cv*xd - sv*yd)/(2.*rr0), y1 + (cv*yd + sv*xd)/(2.*rr0)),
        (x1 + (cv*xd + sv*yd)/(2.*rr0), y1 + (cv*yd - sv*xd)/(2.*rr0)),
    )

r1 = sqrt((x1 - x0)**2 + (y1 - y0)**2 - r0**2)

p0, p1 = sorted(solve(x1, y1, r1, x0, y0, r0))
print "%.08f %.08f" % p0
print "%.08f %.08f" % p1

Measured memory_bytes: 6640
#include <limits>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <bitset>
#include <map>
#include <unordered_map>
#include <cstdint>
using namespace std;

int main(){
    int64_t n;
    cin >> n;
    
    int64_t ds = 0;
    for(int i = n; i > 0; i /= 10)
    {
        ds += i%10;
    }
    
    cout << (n % ds == 0 ? "Yes" : "No") << '\n';
 
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

string S[200010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    map<string, int> mp;
    rep(i, N) {
        cin >> S[i];
        mp[S[i]]++;
    }
    int cnt = 0;
    rep(i, N) {
        cnt = max(cnt, mp[S[i]]);
    }
    set<string> v;
    rep(i, N) if (mp[S[i]] == cnt) v.insert(S[i]);
    for(auto itr = v.begin(); itr != v.end(); itr++) {
        cout << *itr << endl;
    }

        

    return 0;
}


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

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n, -1) {}

  //functions
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }

  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  int size(int x) {
    return -d[find(x)];
  }
};

int main() {
  int N, M, K;
  cin >> N >> M >> K;
  vector<int> friends(N, 0); //友人の数
  vector<vector<int>> blocks(N, vector<int>(0)); //ブロック相手の番号
  UnionFind uf(N); //Union-Find Tree

  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    friends[a]++, friends[b]++;
    uf.unite(a, b);
  }

  for (int i = 0; i < K; i++) {
    int c, d;
    cin >> c >> d;
    c--, d--;
    blocks[c].push_back(d), blocks[d].push_back(c);
  }
  //入力
  
  for (int n = 0; n < N; n++) {
    int ans = uf.size(n) - 1 - friends[n];
    for (int p: blocks[n]) {
      if (uf.same(n, p)) ans--;
    }

    cout << ans << ((n != N-1) ? " " : "\n");
  }
}


Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	std::string s; cin >> s;
	
	for(auto v: s) {
		if(v == ',') printf(" ");
		else printf("%c", v);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <vector>

using namespace std;

class List {
public:
	class Node {
	public:
		Node(int value = 0) :value(value), next(nullptr), back(nullptr) {};

		// 自分が消されるとき
		~Node() {
			if (back != nullptr) {
				back->setNext(next); // 自分の後ろのポインタに次の相手を伝える
			}
			if (next != nullptr) {
				next->setBack(back); // 自分の先のポインタに、後ろの相手を伝える
			}
		};


		int value;

		void setNext(Node* ptr) { next = ptr; };
		void setBack(Node* ptr) { back = ptr; };
		Node* getNext() { return next; }
		Node* getBack() { return back; }
	private:
		Node * next;
		Node* back;
	};

	List() : first(nullptr), last(nullptr) {};

	// 片付ける
	~List() {
		Node* current = first;
		while (current != nullptr) {
			Node* target = current;
			current = current->getNext();
			delete(target);
		}
	}

	// 全ての要素を削除する
	void clear() {

	}

	// 先頭に要素を追加する
	void insert(int x) {
		Node* t = first;

		first = new Node(x); // 新しいノードを追加する
		first->setNext(t); // 次ノードにさっきまでの先頭を指定

		if (t != nullptr) {
			t->setBack(first); // 旧先頭ノードの後ろに新しく追加したノードを指定
		}
		// これが最初の追加
		else {
			last = first;
		}
	}

	// 最初に見つかった要素を削除する
	void remove(int x) {

		Node* current = first;
		// 同値のものを探す
		while (current != nullptr) {

			// 見つかった
			if (current->value == x) break;

			current = current->getNext(); // 次のポインタを取得
		}

		if (current == nullptr) return; // 見つからなかった

		// 見つかった要素の削除
		if (current == first) {
			removeFirst();
		}
		else if (current == last) {
			removeLast(); // ラストに移譲する
		}
		else {
			delete(current);
		}
	}

	// 最初の要素を削除する
	void removeFirst() {
		Node* second = first->getNext();

		// 先頭の削除
		delete(first);

		// 旧2番手を先頭に設定
		first = second;
		// 消したのがlastでもあったのなら
		if (second == nullptr) { last = second; } // ラストも更新
	};

	// 最後の要素を削除する
	void removeLast() {
		Node* booby = last->getBack();

		// 最後尾の削除
		delete(last);

		// 旧ブービーを末尾に設定
		last = booby;

		// 消したのがfirstでもあったのなら
		if (booby == nullptr) { first = booby; } // 先頭も更新
	};

	// 入っている全ての要素を出力する
	void dump() {
		Node* current = first;
		int cnt = 0;
		while (current != nullptr) {
			if (cnt != 0) printf(" ");
			printf("%d", current->value);
			current = current->getNext();
			cnt++;
		}
		printf("\n");
	}

private:
	Node* first;
	Node* last;
};



int N;
int main() {
	List list;

	cin >> N;

	for (int i = 0; i < N; i++) {
		char command[20];
		int n;

		scanf("%s%d", command, &n);

		if (command[0] == 'i') {
			list.insert(n);
		}
		else if (strlen(command) > 6) {
			if (command[6] == 'F') {
				list.removeFirst();
			}
			else if (command[6] == 'L') {
				list.removeLast();
			}
		}
		else {
			list.remove(n);
		}

	}

	list.dump();
	return 0;
}


Measured memory_bytes: 34388
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> clock(13, 0);
	clock[0] = 1;
	vector<int> d(n);
	rep(i,n){
		cin >> d[i];
		++clock[d[i]];
	}
	vector<int> v;
	bool flag = true;
	rep(i,13){
		if(clock[i] >= 3){
			cout << 0 << endl;
			return 0;
		}
		if(clock[i] == 2){
			if(i == 0 || i == 12){
				cout << 0 << endl;
				return 0;
			}
			v.push_back(i);
			v.push_back(24-i);
		}
		if(clock[i] == 1){
			if(flag) v.push_back(i);
			else v.push_back(24-i);
			flag = !flag;
		}
	}
	v.push_back(24);
	sort(v.begin(), v.end());
	int ans = 24;
	rep(i,v.size()-1){
		chmin(ans, v[i+1] - v[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=1e9+5;
const int N=500000+5;
const ll mod=1e9+7;

int n;

struct Matrix{
	vector<vector<ll>> a=vector<vector<ll>>(n,vector<ll>(n));
	Matrix operator *(const Matrix& b){
		Matrix c;
		for(int i=0;i<n;++i){
			for(int j=0;j<n;++j){
				for(int k=0;k<n;++k){
					c.a[i][k]=(c.a[i][k]+a[i][j]*b.a[j][k])%mod;
				}
			}
		}
		return c;
	}
};

Matrix poww(Matrix a,ll b){
	Matrix r;
	for(int i=0;i<n;++i) r.a[i][i]=1;
	while(b){
		if(b&1) r=r*a;
		a=a*a;
		b>>=1;
	}
	return r;
}

int main(){
	ios::sync_with_stdio(0);	
	cin.tie(0);
	ll k;
	cin>>n>>k;
	Matrix mat;
	for(int i=0;i<n;++i){
		for(int j=0;j<n;++j){
			cin>>mat.a[i][j];
		}
	}
	mat=poww(mat,k);
	ll ans=0;
	for(int i=0;i<n;++i){
		for(int j=0;j<n;++j){
			ans=(ans+mat.a[i][j])%mod;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(n) for(ll i=0; i<n; i++)
const ll MOD = pow(10,9)+7;

ll n;
string s;
vector<ll> v[13];

void init()
{
  for (int i = 0; i < 13; i++)
  {
    for (ll j = 0; j < n; j++)
    {
      v[i].push_back(0);
    } 
  }
  reverse(s.begin(),s.end());
}

ll mod_pow(ll x, ll a,ll m)
{
  switch (a)
  {
  case 0:
    return 1;
    break;
  case 1:
    return x;
    break;  
  default:
    if(a%2==1){
      ll tmp = mod_pow(x,a-1,m);
      return (x*tmp)%m;
    } else {
      ll tmp = mod_pow(x,a/2,m);
      return tmp*tmp%m;
    }
    break;
  }
}

void dig_defined(ll i)
{
  ll x = atoi((s.substr(i,1).c_str()));
  ll m = (x*mod_pow(10,i,13))%13;
  for (int j = 0; j < 13; j++)
  {
    int k = (j+m)%13;
    v[k][i] = (v[k][i]+v[j][i-1])%MOD;
  }
}

void dig_undefined(ll i)
{
  ll m = mod_pow(10,i,13);
  for (int x = 0; x < 10; x++)
  {
    ll tmp = x*m%13;
    for (int j = 0; j < 13; j++)
    {
      int k = (j+tmp)%13;
      v[k][i] = (v[k][i]+v[j][i-1])%MOD;
    }
  }
}

// first digit
void first()
{
  if(s[0]=='?'){
    for (int i = 0; i < 10; i++)
    {
      v[i][0] = 1;
    }    
  } else {
    int x = atoi(s.substr(0,1).c_str());
    v[x][0] = 1;
  }
}

void print_v()
{
  for (int i = 0; i < 13; i++)
  {
    for (ll j = 0; j < n; j++)
    {
      cout << v[i][j] << " ";
    }
    cout << endl;
  }  
}

void ans()
{
 first();
 for (ll i = 1; i < n; i++)
 {
   if(s[i]=='?'){
     dig_undefined(i);
   } else {
     dig_defined(i);
   }
 }
}

int main()
{
  cin >> s;
  n = s.length();
  init();
  ans();
  cout << v[5][n-1] << endl;
  return 0;
}

Measured memory_bytes: 11316
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (ll)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// ll        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n, k;
  cin >> n >> k;
  vector<ll> a;
  ll bef = 0;
  ll conti = 0;
  rep(i, n) {
    char ctemp;
    cin >> ctemp;
    ll temp = ctemp - '0';
    if (bef != temp) {
      a.push_back(conti);
      conti = 0;
    }
    conti++;
    bef = temp;
  }
  if (conti > 0) a.push_back(conti);
  ll zeronum = (SIZE(a) + 1) / 2;
  if (zeronum <= k) {
    cout << accumulate(ALL(a), 0LL) << endl;
    return 0;
  }
  vector<ll> b(SIZE(a) + 1);
  b[0] = 0;
  rep(i, SIZE(a)) { b[i + 1] = b[i] + a[i]; }
  ll res = -100;
  rep(i, SIZE(a) + 1) {
    if (i % 2 == 0) {
      if (i + 2 * k > SIZE(a))
        chmax(res, b[SIZE(a)] - b[i]);
      else
        chmax(res, b[i + 2 * k] - b[i]);
    } else {
      if (i + 2 * k + 1 > SIZE(a))
        chmax(res, b[SIZE(a)] - b[i]);
      else
        chmax(res, b[i + 2 * k + 1] - b[i]);
    }
  }
  cout << res << endl;
  return 0;
}


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

int main() {
	bool Prime[10000] = {};
	for (int i = 2; i < 10000; i++) {
		Prime[i] = true;
	}
	for (int i = 2; i < 100; i++) {
		if (Prime[i]) {
			for (int j = 2; j < 10000 / i; j++) {
				Prime[i * j] = false;
			}
		}
	}
	int N, count = 0;
	cin >> N;
	for (int i = 2; i < 10000; i++) {
		if (Prime[i] && i % 10 == 1) {
			cout << i;
			count++;
			if (count != N) cout << " ";
		}
		if (count == N) break;
	}
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> ii;
typedef map<int, int> MPII;
typedef set<int> SETI;

const int mxN = 2e5;
const ld pi = 4.0 * atanl(1.0);
const int iinf = 1e9 + 10;
const int inf = 1e18 + iinf + 10;
const int mod = 1000000007;
const ld prec = .000001;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(c) c.begin(), c.end()
#define rall(c) c.end(), c.begin()

int n, m, t, a[mxN];
vi v;

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

int main() {
  fast();
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n);
  int ans = INT_MAX;
  for (int i = 1; i <= 100; ++i) {
    int s = 0;
    for (int j = 0; j < n; ++j) {
      s += pow(a[j] - i, 2);
    }
    ans = min(ans, s);
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3660
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		WriteLine(Solve());
		Out.Flush();
	}
	long Solve()
	{
		var I = GL;
		long A = I[0], B = I[1];
		if (A == B) return A;
		if (A == 0) A++;
		return Calc(A - 1) ^ Calc(B);
	}
	long Calc(long n)
	{
		if (n == 0) return 0;
		if (n == 1) return 1;
		if (n % 2 == 0) return n ^ Calc(n - 1);
		if (n % 4 == 1) return 1;
		return 0;
	}
	long Calc2(long n)
	{
		var ans = 0L;
		for (var i = 0L; i <= n; i++) ans ^= i;
		return ans;
	}
}


Measured memory_bytes: 13396
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	n <- readInt
	as <- readInts
	let
		res = n - solve 1 as
	print $ if res == n
		then -1
		else res

solve _ [] = 0
solve k (a:as)
	| k == a = 1 + solve ( succ k ) as
	| otherwise = solve k as

Measured memory_bytes: 4732
#include "stdio.h"

int main()
{
	int N[50];
	int MaxN,MaxM;
	int a,b;
	int i;

	scanf("%d %d", &MaxN, &MaxM);
	//初期化
	for (i = 0; i < 50; i++) {
		N[i] = 0;
	}
	//N回Inputする
	for (i = 0; i < MaxM; i++) {
		scanf("%d %d", &a, &b);
		N[a - 1] = N[a - 1] + 1;
		N[b - 1] = N[b - 1] + 1;
	}
	for (i = 0; i < MaxN; i++) {
		printf("%d\n", N[i]);
	}

	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
    int a=0,b=0,c=0,flag=0;
    scanf("%d %d %d",&a,&b,&c);
    if(a==b && a!=c) flag=1;
    if(b==c && b!=a) flag=1;
    if(c==a && c!=b) flag=1;

    if(flag==1) printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 1692
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class FForkInTheRoad {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    vector<vector<int>> G;
    map<P, int> path;
    int N, M;
    vector<double> dp;

    double calc(int v) {
        dp[N - 1] = 0;
        for (int i = N - 1; i >= 0; i--) {
            int num = G[i].size();
            if (num >= 2 && i == v) {
                num--;
            }

            double sum = 0;
            double maxv = -1;
            REP(j, G[i].size()) {
                int to = G[i][j];
                sum += dp[to] / num;
                maxv = max(maxv, dp[to]);
            }
            if (G[i].size() != num) {
                sum -= maxv / num;
            }

            dp[i] = sum + 1;
        }

        return dp[0] - 1;
    }

    void solve(std::istream& cin, std::ostream& cout) {
        cin >> N >> M;
        G.resize(N), dp.resize(N);

        REP(i, M) {
            int s, t;
            cin >> s >> t;
            s--, t--;
            G[s].push_back(t);
            path[{s, t}] = i;
        }

        double res = INF;
        REP(i, N) {
            res = min(res, calc(i));
        }

        fcout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    FForkInTheRoad solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 13696
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

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

	int A, B, C, D;
	A = s[0] - 0x30;
	B = s[1] - 0x30;
	C = s[2] - 0x30;
	D = s[3] - 0x30;

	int pm[2] = { 1, -1 };
	map<int, char> mp;
	mp[1] = '+';
	mp[-1] = '-';

	for (int op1 : pm) {
		for (int op2 : pm) {
			for (int op3 : pm) {
				if (A + op1 * B + op2 * C + op3 * D == 7) {
					cout << A << mp[op1] << B << mp[op2] << C << mp[op3] << D << "=" << 7 << endl;
					return 0;
				}
			}
		}
	}

	return 0;
}

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

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int MAXN = 1e5 + 5;

ll fastPow(ll x, ll b) {
    if (b == 0)
        return 1;
    else if (!(b & 1)) {
        return fastPow(x * x, b / 2);
    } else
        return x * fastPow(x * x, (b - 1) / 2);
}

//__builtin_popcount ();
int main() {
    FAST
string h;
    cin>>h;
    int sz=h.length();
    int ans=0;
    if(h[0]=='B')
    {
        for(int i=0;i<sz-1;i++)
        {
            if(h[i]=='W' && h[i+1]!='W')
                ans+=2;
        }
        if(h[sz-1]=='W')
            ans++;
    }
    else if(h[0]=='W')
    {
        for(int i=0;i<sz-1;i++)
        {
            if(h[i]=='B' && h[i+1]!='B')
                ans+=2;
        }
        if(h[sz-1]=='B')
            ans++;
    }
    int ans2=0;
    if(h[sz-1]=='B')
    {
        for(int i=sz-1;i>0;i--)
        {
            if(h[i]=='W' && h[i-1]!='W')
                ans2+=2;
        }
        if(h[0]=='W')
            ans2++;
    }
    else if(h[sz-1]=='W')
    {
        for(int i=sz-1;i>0;i--)
        {
            if(h[i]=='B' && h[i-1]!='B')
                ans2+=2;
        }
        if(h[0]=='B')
            ans2++;
    }

    cout<<min(ans2,ans)<<endl;

    return 0;
}

Measured memory_bytes: 512
/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/
 
#ifdef LOCAL
#include "debug.h"
#else
#include<bits/stdc++.h>
using namespace std;
#define debug(x...)
#endif
 
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> 
using ordered_set= tree<T, null_type, 
		less<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
template<class T> 		
using ordered_mset= tree<T, null_type, 
		less_equal<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
		
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)
 
*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	
 
const ll inf=1e17L;
 
ll ara[3005][3005];
ll dp[3005][3005][4];
int n,m;
 
ll f(int i,int j,int picked)
{
	if(picked>3 || i>n || j>m) return -inf;
	
	if(i==n && j==m)
	{
		return picked<3?ara[i][j]:0;
	}
	
	ll &ans=dp[i][j][picked];
	if(ans!=-1) return ans;
	
	if(ara[i][j])
	{
		ans=max(ans,f(i,j+1,picked+1)+ara[i][j]);
		if(picked<3) ans=max(ans,f(i+1,j,0)+ara[i][j]);
	}
	
	ans=max(ans,f(i,j+1,picked));
	ans=max(ans,f(i+1,j,0));
	
	return ans;
}
 
void solve()
{
	int k;
	cin>>n>>m>>k;
	
	for(int i=0;i<k;i++)
	{
		int r,c,val;
		cin>>r>>c>>val;
		
		ara[r][c]=val;
	}
	
	memset(dp,-1,sizeof dp);
	
	cout<<f(1,1,0);
}		
 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int testcase=1;
	//cin>>testcase;
	
	for(int i=1;i<=testcase;i++)
	{
		//cout<<"Case "<<i<<": ";
		solve();
	}
	
	#ifdef LOCAL
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	#endif
	
	
	return 0;
}


Measured memory_bytes: 356760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s,t;
  cin>>s>>t;
  if(s.size()+1!=t.size()){
    cout<<"No"<<endl;
    goto z;
  }
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]){
      cout<<"No"<<endl;
      goto z;
    }
  }
  cout<<"Yes"<<endl;
  z:;
}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionC
    {
        public struct C
        {
            public int t;
            public int x;
            public int y;
        }

        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            var n = int.Parse(Console.ReadLine());

            var c = new C[n];

            for (int i = 0; i < n; i++) {
                // 整数配列の入力
                var a = Console.ReadLine().Split(' ').Select(q => int.Parse(q)).ToArray();
                c[i] = new C { t = a[0], x = a[1], y = a[2] };
            }

            var nowT = 0;
            var nowX = 0;
            var nowY = 0;

            for(int i = 0; i < n; i++) {
                var diffT = c[i].t - nowT;
                var diffXY = Math.Abs(c[i].x - nowX) + Math.Abs(c[i].y - nowY);

                if (diffXY > diffT || diffXY % 2 != diffT % 2) {
                    Console.WriteLine("No");
                    Console.Out.Flush();
                    return;
                }

                nowT = c[i].t;
                nowX = c[i].x;
                nowY = c[i].y;
            }

            Console.WriteLine("Yes");

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 16312
n = input()
a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])
sumn = a + b + c + d

if sumn == 7:
    print(n[0]+"+"+n[1]+"+"+n[2]+"+"+n[3]+"=7")
elif sumn - 2*d == 7:
    print(n[0]+"+"+n[1]+"+"+n[2]+"-"+n[3]+"=7")
elif sumn - 2*c == 7:
    print(n[0]+"+"+n[1]+"-"+n[2]+"+"+n[3]+"=7")
elif sumn - 2*b == 7:
    print(n[0]+"-"+n[1]+"+"+n[2]+"+"+n[3]+"=7")
elif sumn - 2*b - 2*c == 7:
    print(n[0]+"-"+n[1]+"-"+n[2]+"+"+n[3]+"=7")
elif sumn - 2*b - 2*d == 7:
    print(n[0]+"-"+n[1]+"+"+n[2]+"-"+n[3]+"=7")
elif sumn - 2*c - 2*d == 7:
    print(n[0]+"+"+n[1]+"-"+n[2]+"-"+n[3]+"=7")
elif sumn - 2*b - 2*c - 2*d == 7:
    print(n[0]+"-"+n[1]+"-"+n[2]+"-"+n[3]+"=7")

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<climits>
using namespace std;

int main()
{
  int n,k;
  cin>>n>>k;
  int h[n+1];
  for(int i=1;i<=n;i++)
    cin>>h[i];
  int m[n+1];
  int mi;
  m[0]=0;
  m[1]=0;
  m[2]=abs(h[2]-h[1]);
  for(int i=3;i<=n;i++)
  {
    int j;
    if(i-k>=1)
        j=i-k;
    else
        j=1;
     mi=m[j]+abs(h[j]-h[i]);
     m[i]=mi;
      j++;
      for(j;j<i;j++)
      {
          if(m[j]+abs(h[j]-h[i])<mi)
          {
              mi=m[j]+abs(h[j]-h[i]);
              m[i]=mi;
          }
      }
  }
  cout<<m[n];
  return 0;
}


Measured memory_bytes: 1152
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        k: usize,
        a: usize,
        b: usize,
    }
    let mut ans = "NG";
    for i in a..=b {
        if i % k == 0 {
            ans = "OK";
        }
    }
    println!("{}", ans);
}


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

using namespace std;

int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);

  string s;
  cin >> s;
  int len = s.length();
  if(len == 2){
    if(s[0] == s[1]){
      cout << 1 << " " << 2 << endl;
    }else{
      cout << -1 << " " << -1 << endl;
    }
  }else if(len<2){
    cout << -1 << " " << -1 << endl;
  }else{
    for(int i = 0;i<len;i++){
      if(i+2 >= len)break;
      string temp = "";
      temp += s[i];
      temp += s[i+1];
      temp += s[i+2];
      sort(temp.begin(),temp.end());
      //cout << temp << endl;
      if(temp[0] == temp[1] || temp[1] == temp[2]){
        cout << i+1 << " " << i+3 << endl;
        return 0;
      }
    }
    cout << -1 << " " << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 3700