akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,tmp;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  
  scanf("%lld %lld",&n,&m);
  rep(i,n) scanf("%d",&a[i]);
  
  rep(i,n-1){
    if(a[i]>m){
      result += a[i]-m;
      a[i]=m;
    }
    if(a[i]+a[i+1]>m){
      result+=a[i]+a[i+1]-m;
      a[i+1]=m-a[i];
    }
  }
  printf("%lld",result);
  return 0;
}



Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <math.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
using namespace std;
#define rep(I,N) for(int I = 0; I < (int)(N); I++)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;

int main(void){
	rep(i, 9){
		rep(j, 9){
			cout << i+1 << "x" << j+1 << "=" << (i+1)*(j+1) << endl;
		}
	}
	return 0;	
}

Measured memory_bytes: 1116
#include <stdio.h>
int main(void)
{
	int N;
	scanf("%d",&N);
	if(N>=0 && N<=127){
		if(N>=65 && N<=90)
			printf("1\n");
		else if(N>=97 && N<=122)
printf("2\n");
		else{
			printf("0\n");
		}
	}
	return 0;
}



Measured memory_bytes: 2068
double n,dp[333][333][333];
int a,cnt[4];
main()
{
	for(scanf("%lf",&n);~scanf("%d",&a);)cnt[a]++;
	for(int k=0;k<=n;k++)
	{
		for(int j=0;j<=n;j++)
		{
			for(int i=0;i<=n;i++)
			{
				if(!i&&!j&&!k)continue;
				dp[i][j][k]=(
					(i?i/n*(dp[i-1][j][k]+n/(i+j+k)):0)+
					(j?j/n*(dp[i+1][j-1][k]+n/(i+j+k)):0)+
					(k?k/n*(dp[i][j+1][k-1]+n/(i+j+k)):0)
				)*n/(i+j+k);
			}
		}
	}
	printf("%.9f",dp[cnt[1]][cnt[2]][cnt[3]]);
}

Measured memory_bytes: 262144
/*
    CP Submission
*/

#include<bits/stdc++.h>

using namespace std;

/* Shortcuts */
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define val(x) cout << #x << ": " << (x) << endl;
#define log(x) cout << (x) << endl;
#define sz(x) (int)(x.size())

/* typedefs */
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <string,string> mss;

int main(){

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

    string s; cin>>s;

    bool g=1;

    if(s[0] != 'A'){
        g=0;
    }
    bool hasC = 0;
    for(int i = 2; i <= s.length() - 2; i++){
        if(s[i] == 'C'){
            if(hasC) g=0;
            else hasC=1;
        }
    }
    if(!hasC) g=0;
    for(int i = 0; i < s.length(); i++){
        if(isupper(s[i]) && !(i >= 2 && i <= s.length() - 2 && s[i] == 'C') && !(i == 0 && s[i] == 'A')){
            g=0;
        }
    }

    cout << (g ? "AC" : "WA") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {	
	int n;
	cin >> n;

	map<int, int> mp;
	for(int i = 0; i < n; ++i) {
		int s;
		cin >> s;
		mp[s] = 1;
	}
	
	int q;
	cin >> q;
	
	int ans = 0;
	for(int i = 0; i < q; ++i) {
		int t;
		cin >> t;
		
		if( mp[t] ) ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 3136
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>

using namespace std;
typedef long long ll;

ll N, d[100001] = {};

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++)cin >> d[i];
	stable_sort(d, d + N + 1);
	cout << d[N / 2 + 1] - d[N / 2] << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int INF = 1e9;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<int>> c(H + 2, vector<int>(W + 2));
  vector<vector<int>> d(H + 2, vector<int>(W + 2, INF));

  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  for (int i = 1; i <= H; i++) {
    string s;
    cin >> s;
    for (int j = 1; j <= W; j++) {
      c[i][j] = (s[j - 1] == '.' ? 1 : 0);
    }
  }

  priority_queue<pair<int, pair<pair<int, int>, int>>,
                 vector<pair<int, pair<pair<int, int>, int>>>,
                 greater<pair<int, pair<pair<int, int>, int>>>>
      que;
  que.push(make_pair(0, make_pair(make_pair(x1, y1), -1)));
  while (!que.empty()) {
    int dist = que.top().first;
    int x = que.top().second.first.first, y = que.top().second.first.second;
    int dir = que.top().second.second;
    que.pop();
    if (x == x2 && y == y2) {
      cout << dist << endl;
      return 0;
    }
    if (dist > d[x][y]) continue;
    for (int i = 0; i < 4; i++) {
      if (i % 2 == dir % 2) continue;
      int ddx = 0, ddy = 0;
      while (true) {
        ddx += dx[i], ddy += dy[i];
        int tmp = (abs(ddx + ddy) + K - 1) / K;
        if (c[x + ddx][y + ddy]) {
          if (d[x + ddx][y + ddy] > dist + tmp) {
            d[x + ddx][y + ddy] = dist + tmp;
            que.push(make_pair(dist + tmp,
                               make_pair(make_pair(x + ddx, y + ddy), i)));
          }
        } else {
          break;
        }
      }
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 48928
N = int(input())
A = sorted(list(map(int, input().split())))

dp = [True]*(A[-1]+1)

ans = 0

for i in range(len(A)):
    if dp[A[i]]:
        if (i == len(A)-1) or (A[i] != A[i+1]):
            ans += 1
    try:
        k = 1
        while(True):
            dp[k*A[i]] = False
            k += 1
    except:
        pass

print(ans)

Measured memory_bytes: 32252
#include <stdio.h>
#include <string.h>

int main(void){
    int k, l;
    char s[105];

    scanf("%d%s", &k, s);
    l = strlen(s);
    if(l <= k){
        printf("%s\n", s);
    }else{
        for(int i = 0; i < k; i++){
            printf("%c", s[i]);
        }
        printf("...\n");
    }
    return 0;
}


Measured memory_bytes: 1664
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
#if DEBUG
            ReadLine();
#endif
        }
        
        void Solve(ConsoleInput cin)
        {
            int[] n = cin.ReadIntArray(4);

            if (n.Contains(1) && n.Contains(9) && n.Contains(7) && n.Contains(4))
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }

        class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;

            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }

            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }

            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 13396
# include <iostream>
# include <string>
using namespace std;
int main() {
    int a,b;
    cin>>a>>b;
    if(a==1&&b>1){
        cout<<"Alice";
    }
    else if(b==1&&a>1){
        cout<<"Bob";
    }
    else if(a>b){
        cout<<"Alice";
    }
    else if(b>a){
        cout<<"Bob";
    }
    else if(a==b){
        cout<<"Draw";
    }
}

Measured memory_bytes: 256
#include <stdio.h>
	int main(){
		int a,b;
		scanf("%d %d",&a,&b);
		if( a%3 ==0 || b%3 ==0  || (a+b)%3 ==0 ){
			printf("Possible");
		}else{
			printf("Impossible");
		}
		return 0;
	}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, n) for (size_t i = 0; i < (n); i++)
#define REP(n) FOR(i, n)
#define cinv(v, n) REP(n) {cin>>(v)[i];}
#define nvec(T, v, n) vector<T> v(n); cinv(v, n)
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}
 
#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))
 
#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )
 
#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}
 
#define acm accumulate
#define pub push_back
#define pof pop_front
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))
 
#define GCD(v) gcd(ALL(v), 0l)
 
template <typename T>
T gcd(T a, T b) {
    if (a > b) swap(a, b);
    if (a == 0) return b;
    return gcd(b%a, a);
}
template <typename InputItr, typename T>
T gcd(InputItr first, InputItr last, T init) {
    for (; first != last; ++first) init = gcd(init, *first);
    return init;
}
 
 
 
int main(){
  string n;
  cin>>n;
  if(n.find("7")!=-1){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
}
 
 
 
 
 
 
/* きょむ〜 */

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

int main()
{
   string s,t;
   cin>>s>>t;
   int x,y;
   cin>>x>>y;
   string u;
   cin>>u;
   if(u==s)
   x=x-1;
   else 
   y=y-1;
   cout<<x<<" "<<y<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

int n, k, h;
int ans;

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

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

typedef pair<int,int> P;
typedef pair<P,int> P2;

int main(){
  int h,w,sx,sy,gx,gy;
  int grid[10][10],d[10][10][10];
  int dy[] = {-1,0,1,0}, dx[] = {0,1,0,-1};

  while(cin >> w >> h,(w||h)){
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++){
	cin >> grid[i][j];
	if(grid[i][j] == 2){sy = i; sx = j;}
	if(grid[i][j] == 3){gy = i; gx = j;}
	for(int k=0;k<=6;k++)d[i][j][k] = -1;
      }

    d[sy][sx][6] = 0;
    queue<P2> q; q.push(P2(P(sy,sx),6));

    int res = -1;
    while(q.size()){
      P2 p = q.front(); q.pop();
      int y = p.first.first, x = p.first.second, t = p.second;

      if(y==gy && x==gx){
	res = t;
	break;
      }
      if(t==1)continue;

      for(int i=0;i<4;i++){
	int ty = y+dy[i], tx = x+dx[i], tt = t-1;
	if(ty<0 || tx<0 || h<=ty || w<=tx)continue;
	if(grid[ty][tx] == 0)continue;
	if(grid[ty][tx] == 4)tt = 6;
	if(d[ty][tx][tt]<0){
	  d[ty][tx][tt] = d[y][x][t] + 1;
	  q.push(P2(P(ty,tx),tt));
	}
      }
    }
    if(res<0)cout << "-1\n";
    else cout << d[gy][gx][res] << endl;
  }
}

Measured memory_bytes: 1200
#include<cstdio>
#define N 100005
int n,m;
int vis[N];
int dp[N];
int head[N],nxt[N],to[N],tot;
void add(int x,int y){nxt[++tot]=head[x];head[x]=tot;to[tot]=y;}
int DP(int u){
	if(vis[u])return dp[u];
	vis[u]=1;
	dp[u]=0;
	for(int e=head[u];e;e=nxt[e]){
		int v=to[e];
		int cur=DP(v)+1;
		if(cur>dp[u])dp[u]=cur;
	}
	return dp[u];
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;++i){
		int u,v;scanf("%d%d",&u,&v);--u,--v;
		add(u,v);
	}
	int ans=0;
	for(int i=0;i<n;++i){
		int cur=DP(i);
		if(cur>ans)ans=cur;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3456
n=int(input())
a=list(input().split())
if n > 3:
    ans=''
    ans += ' '.join(a[::-2])
    if n%2==0:
        ans += ' ' + ' '.join(a[0::2])
    else:
        ans += ' ' + ' '.join(a[1::2])
    print(ans)
else:
    ans=[]
    for i in range(n):
        ans.append(a[i])
        ans.reverse()
    print(' '.join(ans))

Measured memory_bytes: 28412
#include <bits/stdc++.h>
#define ll long long
#define fastio cin.sync_with_stdio(false); cin.tie(NULL)
using namespace std;
int n;
ll tenpow[20]={0};
ll sub(ll num , int from,int to){

  ll re= num%tenpow[to]/tenpow[from-1];
  return re;
}
int main(){
  fastio;
  tenpow[0]=1;
  for (int i=1;i<20;i++)tenpow[i]=tenpow[i-1]*10;
  string s;
  cin>>s;
  ll num=stoll(s);
  n=s.size();
  vector<vector<vector<pair<ll,int>>>>dp (n+1,vector<vector<pair<ll,int>>>(n,vector<pair<ll,int>>(n+1,{0,0})));
  for (int i=1;i<=n;i++){
    dp[i][0][i]={sub(num,1,i),1};
    for (int j=1;j<=i-1;j++){
      for (int v=1;v<=i-j;v++){
        dp[i][j][1].first+=dp[i-1][j-1][v].first+sub(num,i,i)*dp[i-1][j-1][v].second;
        dp[i][j][1].second+=dp[i-1][j-1][v].second;
      }
      for (int k=2;k<=i-j;k++){
        dp[i][j][k].first=dp[i-1][j][k-1].first+tenpow[k-1]*sub(num,i,i)*dp[i-1][j][k-1].second;
        dp[i][j][k].second=dp[i-1][j][k-1].second;
      }
    }
  }
  ll re=0;
  for (int j=0;j<=n-1;j++){
    for (int k=1;k<=n-j;k++){
      re+=dp[n][j][k].first;
    }
  }
  cout<<re<<'\n';
  return 0;
}


Measured memory_bytes: 3684
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();

		String[] input = br.readLine().split(" ");
		int n = Integer.parseInt(input[0]);
		int m = Integer.parseInt(input[1]);
		int l = Integer.parseInt(input[2]);
		int i = 0;
		int j = 0;
		long a = 0;

		int nm[][] = new int[n][m];
		int ml[][] = new int[m][l];

		for( i=0 ; i<n ; i++ ){
			input = br.readLine().split(" ");
			for( j=0 ; j<m ; j++ ){
				nm[i][j]=Integer.parseInt(input[j]);
			}
		}

		for ( i=0 ; i<m ; i++ ){
			input = br.readLine().split(" ");
			for( j=0 ; j<l ; j++ ){
				ml[i][j]=Integer.parseInt(input[j]);
			}
		}

		for ( i=0 ; i<n ; i++ ){
			for( j=0 ; j<l ; j++ ){
				for( int k=0 ; k<m ; k++ ){
					 a = a + (nm[i][k] * ml[k][j]);
				}
				sb.append(String.valueOf(a));
				a = 0;
				if( j==l-1 ) break;
				sb.append(" ");
			}
			sb.append("\n");
		}

		System.out.print(sb);

	}
}

Measured memory_bytes: 32308
#include <bits/stdc++.h>
#define int long long
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

class mint {
  private: 
    ll x;

  public:
    constexpr mint(const ll x = 0) noexcept : x((x % MOD + MOD) % MOD) {}
    constexpr ll value() noexcept { return x; }
    constexpr mint operator += (const mint right) noexcept {
      if ((x += right.x) >= MOD) x -= MOD;
      return *this;
    }
    constexpr mint operator -= (const mint right) noexcept {
      if ((x += MOD - right.x) >= MOD) x -= MOD;
      return *this;
    }
    constexpr mint operator *= (const mint right) noexcept {
      x = x * right.x % MOD;
      return *this;
    }
    constexpr mint operator /= (const mint right) noexcept {
      return *this *= right.inv();
    }
    constexpr mint operator + (const mint right) const noexcept {
      return mint(*this) += right;
    }
    constexpr mint operator - (const mint right) const noexcept {
      return mint(*this) -= right;
    }
    constexpr mint operator / (const mint right) const noexcept {
      return mint(*this) /= right;
    }
    constexpr mint operator * (const mint right) const noexcept {
      return mint(*this) *= right;
    }
    constexpr mint inv() const {
      return pow(MOD-2);
    }
    constexpr mint pow(ll n) const {
      if (n == 0) return 1;
      mint a = pow(n>>1);
      a *= a;
      if (n & 1) a *= *this;
      return a;
    }
};

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, k; cin >> n >> k;
  int r = n - k;
  int b = n - r;

  auto nCr = [&](int x, int y) {
    mint res(1);

    rep(i, y) res *= (x - i);
    rep(i, y) res /= (i + 1);

    return res;
  };

  rep2(i, 1, k) cout << (nCr(r+1, i) * nCr(b-1, i-1)).value() << endl;

  return (0);
}


Measured memory_bytes: 3628
import collections as c
import sys


n = int(input())
v = list(map(int, input().split()))

v1 = [v[i] for i in range(n) if i%2 == 0]
v2 = [v[i] for i in range(n) if i%2 == 1]

length1 = len(v1)
length2 = len(v2)

v1 = c.Counter(v1)
v2 = c.Counter(v2)

if len(set(v)) == 1:
    print(len(v) // 2)
    sys.exit()


if v1.most_common()[0][0] != v2.most_common()[0][0]:
    ans = (length1 - v1.most_common()[0][1]) + (length2 - v2.most_common()[0][1])
else:
    a1 = length1 - v1.most_common()[0][1]
    a2 = length1 - v1.most_common()[1][1]
    b1 = length2 - v2.most_common()[0][1]
    b2 = length2 - v2.most_common()[1][1]

    ans = min([a1+b2, a2+b1])

print(ans)    


Measured memory_bytes: 22360
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

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

    int p_rank = 0;
    int q_rank = 0;
    int cnt = 1;
    do {
        if (a == p) p_rank = cnt;
        if (a == q) q_rank = cnt;
        cnt++;
    } while (next_permutation(a.begin(), a.end()));

    cout << abs(p_rank - q_rank) << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner in = new Scanner(System.in);
		int[] char_count = new int[26];

		while(in.hasNextLine()){

			String str = in.nextLine();

			//if(str.length() == 0){
			if(str.equals("")){
				break;

			}else{

				String lower_case = str.toLowerCase();

				for (int i = 0; i < lower_case.length(); i++) {

					if(lower_case.charAt(i) == 'a'){

						char_count[0]++;

					}else if(lower_case.charAt(i) == 'b'){

						char_count[1]++;

					}else if(lower_case.charAt(i) == 'c'){

						char_count[2]++;

					}else if(lower_case.charAt(i) == 'd'){

						char_count[3]++;

					}else if(lower_case.charAt(i) == 'e'){

						char_count[4]++;

					}else if(lower_case.charAt(i) == 'f'){

						char_count[5]++;

					}else if(lower_case.charAt(i) == 'g'){

						char_count[6]++;

					}else if(lower_case.charAt(i) == 'h'){

						char_count[7]++;

					}else if(lower_case.charAt(i) == 'i'){

						char_count[8]++;

					}else if(lower_case.charAt(i) == 'j'){

						char_count[9]++;

					}else if(lower_case.charAt(i) == 'k'){

						char_count[10]++;

					}else if(lower_case.charAt(i) == 'l'){

						char_count[11]++;

					}else if(lower_case.charAt(i) == 'm'){

						char_count[12]++;

					}else if(lower_case.charAt(i) == 'n'){

						char_count[13]++;

					}else if(lower_case.charAt(i) == 'o'){

						char_count[14]++;

					}else if(lower_case.charAt(i) == 'p'){

						char_count[15]++;

					}else if(lower_case.charAt(i) == 'q'){

						char_count[16]++;

					}else if(lower_case.charAt(i) == 'r'){

						char_count[17]++;

					}else if(lower_case.charAt(i) == 's'){

						char_count[18]++;

					}else if(lower_case.charAt(i) == 't'){

						char_count[19]++;

					}else if(lower_case.charAt(i) == 'u'){

						char_count[20]++;

					}else if(lower_case.charAt(i) == 'v'){

						char_count[21]++;

					}else if(lower_case.charAt(i) == 'w'){

						char_count[22]++;

					}else if(lower_case.charAt(i) == 'x'){

						char_count[23]++;

					}else if(lower_case.charAt(i) == 'y'){

						char_count[24]++;

					}else if(lower_case.charAt(i) == 'z'){

						char_count[25]++;

					}
				}
			}
		}
		// ??¢????????????????????????????????????????????¨?????°?????¨???
		char a = 'a';

		for(int i = 0; i < 26; i++){

			System.out.println(a++ + " : " + char_count[i]);

		}
	}
}

Measured memory_bytes: 26308
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#define ll long long
using namespace std;
const int MOD = 1000000007;
const long long INF = 1LL << 60;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   ll n;
   cin >> n;
   vector<ll> a(n);
   ll point = -1;
   ll cnt = 0;
   for(ll i = 0;i < n;i++) {
      cin >> a[i];
      if (point != -1) {
          if (point>a[i]) {
              cnt+=point-a[i];
          } else {
              point = a[i];
          }
      } else {
          point = a[i];
      }
   }
   cout << cnt << endl;
}

Measured memory_bytes: 4776
import math
from decimal import Decimal
H,W = map(int,input().split())
if H==1 or W == 1:
  print(1)
elif H%2==0 and W%2== 0:
  print(Decimal((H*W)/2))
elif H%2 == 1 and W%2==1:
  print(Decimal(H*math.floor(W/2)+math.ceil(H/2)))
elif H%2 == 1 and W%2==0:
  print(Decimal(H*math.floor(W/2)))
else:
  print(Decimal(W*math.floor(H/2)))

Measured memory_bytes: 5076
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

int main() {
  i64 a;
  string s;
  cin >> a >> s;
  if(a >= 3200) {
    cout << s << endl;
  }
  else {
    cout << "red" << endl;
  }
}


Measured memory_bytes: 764
object Main {
  def main(args: Array[String]): Unit = {
    val in = new java.util.Scanner(System.in)
    val a = in.nextInt
    val hour = a / 3600
    val b = a - hour*3600
    val minute = b/ 60
    val second = b - minute*60
    println(hour+":"+minute+":"+second)
  }
}

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

int main()
{
    int size1=0,num=0,count=0;
    cin>>size1;
    vector<int>n;

for(int i=0;i<size1;i++){
    cin>>num;
    n.push_back(num);

}
for(int i=0;i<n.size();i++){
    if(n[i]%2!=0&&i%2==0){count++;}
}

cout<<count;

    return 0;
}


Measured memory_bytes: 3496
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
using namespace std;

#define X first
#define Y second
#define EPS 1e-6

class Room{
public:
	Room(int xx, int yy){
		x = xx;
		y = yy;
	}

	Room(int xx, int yy, double dd){
		x = xx;
		y = yy;
		dist = dd;
	}
	int x;
	int y;
	double dist;
	
	bool operator <(const Room &arg) const{
		if(abs(dist - arg.dist) < EPS){
			return x < arg.x;
		}else{
			return dist < arg.dist;
		}
	}
};

double euc_dist(int x1, int y1, int x2, int y2){
	return sqrt(pow(x1 - x2 , 2) + pow(y1 - y2, 2));
}

int main(){
	int n,tx,ty;
	cin >> n;
	for(int cases=0;cases<n;cases++){
		vector<pair<int,int> > l;
		set<pair<int,int> > s;
		pair<int,int> pos;
		vector<Room> rooms;
		
		while(cin >> tx >> ty){
			if(tx == 0 && ty == 0) break;
			l.push_back(make_pair(tx,ty));
		}

		rooms.push_back(Room(0, 0, 0));
		pos.X = 0;
		pos.Y = 0;
		for(int i=0;i<l.size();i++){
			pos.X += l[i].X;
			pos.Y += l[i].Y;
			if(s.find(pos) != s.end()) continue;
			s.insert(pos);
			rooms.push_back(Room(pos.X,
								 pos.Y,
								 euc_dist(0,0,pos.X,pos.Y)));
			//cout << rooms[i].x << " " <<rooms[i].y << " " << rooms[i].dist << endl;
		}
		sort(rooms.begin(), rooms.end());
		cout << rooms.back().x << " " << rooms.back().y << endl;
	}
}

Measured memory_bytes: 0
n = int(input())
f = list(map(int,input().split()))
f.sort(reverse = True)
ans = 0
if n%2 == 0:
    for i in range(n//2):
        ans += f[i] * 2
    ans -= f[0]
else:
    for i in range(n//2):
        ans += f[i] * 2
    ans += f[n//2]-f[0]

print(ans)


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

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  int money = 2147483647;
  int maxp = max(x, y);
  for (int w = 0; w <= maxp; w++) {
    int u = x - w;
    u = max(0, u);
    int v = y - w;
    v = max(0, v);
    if (u + w >= x && v + w >= y) {
      money = min(money, a * u + b * v + c * 2 * w);
    }
  }

  cout << money << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

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

const long long MOD = 1e9+7;

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() {
    int h, n;
    cin >> h >> n;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        sum += a;
    }
    cout << (h <= sum ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
# n = gets.to_s.to_i
m = 2019
s = gets.to_s.chomp.bytes

ans = 0
# p '0'.ord #=> 48
if false # m == 2 || m == 5
  
  n.times{ |i| (s[i] - 48 )%m == 0 && ans+=(i+1) }

else
  
  h = Hash.new(0)
  h[0] = 1
  
  cur = 0
  p10 = 1
  
  s.reverse_each do |c|
    cur = ( cur + ( c - 48 ) * p10 ) % m
    ans += h[cur]
    h[cur] += 1
    p10 = p10 * 10 % m
  end
end

puts ans

Measured memory_bytes: 16340
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
const ll INF = 5e15;
ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}
int main(){
    ll N, M;
    cin >> N >> M;
    string s, t;
    cin >> s >> t;
    ll g = gcd(N, M);
    for(ll i = 0; N / g * i < N && M / g * i < M; i++){
        if(s[N / g * i] != t[M / g * i]){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << N * M / g << endl;
    return 0;
}


Measured memory_bytes: 512
name = input()

if name == 'SUN':
  print(7)
if name == 'MON':
  print(6)
if name == 'TUE':
  print(5)
if name == 'WED':
  print(4)
if name == 'THU':
  print(3)
if name == 'FRI':
  print(2)
if name == 'SAT':
  print(1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;
 
#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
 
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
 
void dfs(VVI& G, int u, int c, vector<bool>& vis){
  vis[u] = true;
  if(!c) return;
  
  for(int to: G[u]){
	dfs(G, to, c-1, vis);
  }
}
 
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
 
  int N, M;
while(
  cin >> N >> M,N){
  VVI G(N);
  REP(i,M){
	int u, v;
	cin >> u >> v;
	--u;
	--v;
	G[u].PB(v);
	G[v].PB(u);
  }
 
  vector<bool> vis(N);
  dfs(G, 0, 2, vis);
  cout << count(ALL(vis), true) - 1 << endl;
 }
  return 0;
}

Measured memory_bytes: 3156
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	n := scanInt()
	arr := make([]int, n)
	max := 0
	for i := range arr {
		num := scanInt()
		max = Max(max, num)
		arr[i] = num
	}

	sort.Ints(arr)

	divisible := map[int]bool{}
	for i := 0; i < n-1; i++ {
		if arr[i] == arr[i+1] {
			divisible[arr[i]] = true
			continue
		}

		num := arr[i]
		for i := 2; i*num <= max; i++ {
			divisible[i*num] = true
		}
	}

	ans := 0
	for i := range arr {
		if !divisible[arr[i]] {
			ans++
		}
	}

	fmt.Println(ans)
}


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

int main(){
  int n; cin >>n;
  vector<int> a(n);
  rep(i,n){
    cin >>a[i];
    a[i]--;
  }
  int now = 0, ans = 0;
  while(true){
    if(now==1){
      cout << ans << endl;
      return 0;
    }
    if(ans>=n){
      cout << -1 << endl;
      return 0;
    }
    ans++;
    now = a[now];
  }
  return 0; 
}

Measured memory_bytes: 3768
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
typedef pair<ll, ll> P;
ll H, W, N;
// ますが多いので(y,x)周りに何個黒があるかをマップで管理
map<P, int> MAP;
int main(){
  cin >> H >> W >> N;
  int vy[9] = {0,-1,-1,0,1,1,1,0,-1};
  int vx[9] = {0,0,1,1,1,0,-1,-1,-1};
  ll cnt = 0;
  FOR(i,0,N) {
    ll y, x;
    cin >> y >> x;
    FOR(j,0,9) {
      if(y+vy[j]<=1||y+vy[j]>=H||x+vx[j]<=1||x+vx[j]>=W) continue;
      MAP[P(y+vy[j],x+vx[j])]++;
    }
  }
  ll ans[10];
  FOR(i,0,10) ans[i] = 0;
  for(auto itr = MAP.begin(); itr != MAP.end(); itr++) {
    ans[itr->second]++;
  }
  ans[0] = (W - 2) * (H - 2);
  FOR(i,1,10) ans[0] -= ans[i];
  FOR(i,0,10) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 56448
#ifdef __APPLE__
    # include <iostream>
    # include <cmath>
    # include <algorithm>
    # include <stdio.h>
    # include <cstdint>
    # include <cstring>
    # include <string>
    # include <cstdlib>
    # include <vector>
    # include <bitset>
    # include <map>
    # include <queue>
    # include <ctime>
    # include <stack>
    # include <set>
    # include <list>
    # include <random>
    # include <deque>
    # include <functional>
    # include <iomanip>
    # include <sstream>
    # include <fstream>
    # include <complex>
    # include <numeric>
    # include <immintrin.h>
    # include <cassert>
    # include <array>
    # include <tuple>
    # include <unordered_map>
    # include <unordered_set>
    # include <thread>
#else
    # include <bits/stdc++.h>
#endif

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back
#define fir first
#define sec second

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;

const int max_n = 10, inf = 1000111222;

char a[max_n][max_n];

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

    int n,m,k;
    cin>>n>>m>>k;
    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    int ans=0;
    for (int mask=0;mask<(1ll<<(n+m));mask++){
        int cnt=0;
        for (int i=0;i<n;i++){
            for (int j=0;j<m;j++){
                if (a[i][j]=='#'){
                    if (!(mask&(1ll<<i))){
                        if (!(mask&(1ll<<(n+j)))){
                            cnt++;
                        }
                    }
                }
            }
        }
        ans+=(cnt==k);
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 3592
#include<stdio.h>
int main()
{
  int year,month,day;
  int n,result;
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d%d%d",&year,&month,&day);
      result=(1000-year)*(19+20)*5+((999-year)/3+1)*5;
      result-=((month-1)*20+(day-1));
      if(year%3!=0) result+=(month-1)/2;
      printf("%d\n",result);
    }
  return 0;
}

Measured memory_bytes: 596
#include "bits/stdc++.h"
using namespace std;
const int N = 5005;
const int base = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    int res = 1;
    for(int i = 1; i <= n; ++i) {
        res = res * 1LL * i % base;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>


using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const double PI = acos(-1.0);
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define all(v) v.begin(), v.end()

char alfa[] = { 'A','B' ,'C','D' ,'E' ,'F' ,'G' ,'H' ,'I' ,'J' ,'K' ,'L' ,'M' ,'N' ,'O' ,'P' ,'Q' ,'R' ,'S' ,'T' ,'U' ,'V' ,'W' ,'X' ,'Y','Z' };

inline void finish() {
	cout << -1 << endl;
	exit(0);
}

unsigned GetDigit(unsigned num) {
	return log10(num) + 1;
}

template <typename T>
inline void debug(vector<T> v) {
	cout << "[";
	for (ll i = 0; i < v.size() - 1; ++i) {
		cout << v[i] << ", ";
	}
	cout << v[v.size() - 1] << "]" << endl;
}

void Main();
inline void DebugMain() {
	while (true) {
		Main();
	}
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	bool debug = false;
	if (debug) {
		cout << "\x1b[41m" << "Debug Mode " << endl;
	}
	(debug) ? DebugMain() : Main();
	return 0;
}


ll calcC(ld lastNum, ld calcNum, ll A, ll B, ll X) {
	if (calcNum < 1) {
		return 0;
	}

	ll ans;

	ans = A * calcNum + B * GetDigit(calcNum);

	if (calcNum == lastNum) {
		return calcNum;
	}

	if (ans > X) {
		return calcC(calcNum, calcNum - (fabs(calcNum - lastNum) / 2), A, B, X);
	}
	else {
		return calcC(calcNum, calcNum + (fabs(calcNum - lastNum) / 2), A, B, X);
	}

}

inline void Main() {
	ll X, Y, N;
	ll A, B;
	ll M1, D1, M2, D2;
	ld ans;
	string S;



	cin >>N;
	ans = (ll)((N + 0.99) / 1.08);

	if ((ll)(ans * 1.08) != N) {
		cout << ":(";
	}else {
		cout << (ll)ans;
	}
	

	


}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <math.h>
using namespace std;

struct punto{
    long double x,y;
    punto operator-(const punto b)const{
        punto aux;
        aux.x = x-b.x;
        aux.y = y-b.y;
        return aux;
    }
    long double operator*(const punto b)const{
        return ( (x*b.x) + (y*b.y) ) ;
    }
};

long double mod(punto p){
    return sqrt( p.x*p.x + p.y*p.y );
}

int main(){


int N;
cin>>N;
vector<punto>V (N);
for(int i = 0; i < N; i++){
    punto p;
    cin>>p.x>>p.y;
    V[i] = p;
}

long double rta = 0.0;
int index = 1;
for(int i = 0; i < N; i++){
        ///cout<<"---"<<endl;
    punto vec = V[ (i+1)%N ]-V[i]; /// genero todos los posibles lados
    punto per;per.x = -vec.y;per.y = vec.x; ///busco la perpendicular = (-y,x).
    /// ahora queremos el punto mas hacia el vector perpendicular.
    while( per*V[ (index+1)%N ] >= per*V[index] ){
        index = (index+1)%N;
    }
    rta = max(rta, max( mod(V[index]-V[i]) , mod(V[index]-V[(i+1)%N]) )  );
}

cout.precision(12);
cout << rta<< endl;

return 0;
}



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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n; cin >> n;
  ll T; cin >> T;
  vector<ll> t(n); rep(i,n) cin >> t[i];

  ll ans = 0;
  for(int i = 1;i<n;i++) ans += min(t[i]-t[i-1],T);

  ans += T;
  cout << ans << endl;
  
  return 0;
}


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

int main(void) {
    int n, tmp;
    int a[9];
    bool b[9];
    fill(b, b+9, false);
    for(int i=0;i<9;i++) cin >> a[i];
    cin >> n;
    for(int i=0;i<n;i++) {
      cin >> tmp;
      for(int j=0;j<9;j++) {
         if(a[j]==tmp) {
           b[j]=true;
           break;
         }
      }
    }
    if(b[0]&&b[1]&&b[2]) { cout << "Yes"; return 0; }
    if(b[3]&&b[4]&&b[5]) { cout << "Yes"; return 0; }
    if(b[6]&&b[7]&&b[8]) { cout << "Yes"; return 0; }
    if(b[0]&&b[3]&&b[6]) { cout << "Yes"; return 0; }
    if(b[1]&&b[4]&&b[7]) { cout << "Yes"; return 0; }
    if(b[2]&&b[5]&&b[8]) { cout << "Yes"; return 0; }
    if(b[0]&&b[4]&&b[8]) { cout << "Yes"; return 0; }
    if(b[2]&&b[4]&&b[6]) { cout << "Yes"; return 0; }
  
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstring>

using namespace std;

int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  int ans = 0;

  if(k >= a) ans += a;
  else {
    ans += k;
    cout << ans << endl;
    return 0;
  }

  if(k <= a + b) {
    cout << ans << endl;
    return 0;
  }

  if(k >= a + b){
    ans -= (k - (a+b));
    cout << ans << endl;
  }

  // while(k > 0){
  //   if(a > 0) {
  //     ans ++;
  //     a --;
  //   }
  //   else if(a <= 0 && b > 0){
  //     b --;
  //   }
  //   else if(a <= 0 && b <= 0 && c > 0) {
  //     ans --;
  //     c--;
  //   }
  //   k --;
  // }

  // cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3632
n_max = 10 ** 5 + 10
sieve = [0, 0] + [1]*n_max
m = 2
while m * m <= n_max:
    if sieve[m]:
        for n in range(2*m, n_max, m):
            sieve[n] = 0
    m += 1

ok = [0]*n_max
cums = [0]
for n in range(n_max):
    if sieve[n] and sieve[(n+1)//2]:
        ok[n] = 1
    cums.append(cums[-1]+ok[n])

q = int(input())
for i in range(q):
    l, r = map(int, input().split())
    print(cums[r+1]-cums[l])

Measured memory_bytes: 13384
n, q = gets.split.map(&:to_i)
s = gets.strip

ns = Array
       .new(n) { |i| s[i, 2] == 'AC' ? 1 : 0 }
       .inject([0]) { |acc, m| acc << m + acc.last.to_i }
# p ns

q.times do
  l, r = gets.split.map(&:to_i)
  # p l..r
  p ns[r-1] - ns[l-1]
end


Measured memory_bytes: 4220
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll H, W;
  cin >> H >> W;
  vector<string> S(H);
  rep(i, H) cin >> S[i];
  rep(i, 2 * H) {
    rep(j, W) {
      cout << S[i / 2][j];
    }
    ENDL;
  }
  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define nl '\n'
#define AC ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
const int MOD = 1000000007;
const int N = 2*1e5;
struct mi {
	ll v; explicit operator ll() const { return v; }
	mi() { v = 0; }
	mi(ll _v) { 
		v = (-MOD < _v && _v < MOD) ? _v : _v % MOD;
		if (v < 0) v += MOD;
	}
	friend bool operator==(const mi& a, const mi& b) { 
		return a.v == b.v; }
	friend bool operator!=(const mi& a, const mi& b) { 
		return !(a == b); }
	friend bool operator<(const mi& a, const mi& b) { 
		return a.v < b.v; }
   
	mi& operator+=(const mi& m) { 
		if ((v += m.v) >= MOD) v -= MOD; 
		return *this; }
	mi& operator-=(const mi& m) { 
		if ((v -= m.v) < 0) v += MOD; 
		return *this; }
	mi& operator*=(const mi& m) { 
		v = v*m.v%MOD; return *this; }
	mi& operator/=(const mi& m) { return (*this) *= inv(m); }
	friend mi pow(mi a, ll p) {
		mi ans = 1; assert(p >= 0);
		for (; p; p /= 2, a *= a) if (p&1) ans *= a;
		return ans;
	}
	friend mi inv(const mi& a) { assert(a.v != 0); 
		return pow(a,MOD-2); }
		
	mi operator-() const { return mi(-v); }
	mi& operator++() { return *this += 1; }
	mi& operator--() { return *this -= 1; }
    mi operator++(int) { mi temp; temp.v = v++; return temp; }
    mi operator--(int) { mi temp; temp.v = v--; return temp; }
	friend mi operator+(mi a, const mi& b) { return a += b; }
	friend mi operator-(mi a, const mi& b) { return a -= b; }
	friend mi operator*(mi a, const mi& b) { return a *= b; }
	friend mi operator/(mi a, const mi& b) { return a /= b; }
    friend ostream& operator<<(ostream& os, const mi& m) {
        os << m.v; return os;
    }
    friend istream& operator>>(istream& is, mi& m) {
        ll x; is >> x;
        m.v = x;
        return is;
    }
};

map<pair<ll, ll>,pair<int,int>> mapping;
int a_zero = 0;
int b_zero = 0;
int all_zero = 0;

int main(){
    AC
    int n;
    cin>>n;
    int cnt=0;
    for(int i=0; i<n; i++){
        ll a, b;
        cin>>a>>b;
        if(a==0 && b==0){
            cnt++;
            continue;
        }

        ll g = __gcd(a,b);
        a/=g;
        b/=g;
        
        if(b<0){
            a*=-1;
            b*=-1;
        }
        if(a<=0) mapping[{b, -a}].second++;
        else mapping[{a, b}].first++;
    }

    mi ans = 1;
    mi two = 2;
    for(auto p : mapping){
        ans = ans*(pow(two, p.second.first)+pow(two, p.second.second)-1);
    }
    ans+=cnt;
    cout<<ans-1<<endl;
}

Measured memory_bytes: 16048
#include <stdio.h>

int GCD(int a,int b)
{
    if (a % b == 0) return b;
    else
        return GCD(b, a % b);
}

int main()
{
    int a, b, temp;
    
    scanf("%d %d", &a, &b);
    if(a < b)
    {
        temp = a;
        a = b;
        b = temp;
    }
    printf("%d\n", GCD(a,b));
    return 0;
}



Measured memory_bytes: 2756
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
         String com;
         int a,b;
         String p;
    
        String str = sc.nextLine();
        int q=sc.nextInt();
        
        for(int i=1;i<=q;i++){
        	 com = sc.next();
           if(com.equals("print")){
              a = sc.nextInt();
              b = sc.nextInt();
              System.out.println(str.substring(a,b+1));
             }
            else if(com.equals("reverse")){
                a = sc.nextInt();
                b = sc.nextInt();
                String temp1=str.substring(0,a);
                String temp2=str.substring(a,b+1);
                String temp3=str.substring(b+1);
                StringBuffer sb=new StringBuffer(temp2);
                temp2 = sb.reverse().toString();
        	    str=temp1+temp2+temp3;
           }
           else if(com.equals("replace")){
                a = sc.nextInt();
                b = sc.nextInt();
                p = sc.next();
               String temp1=str.substring(0,a);
               String temp3=str.substring(b+1);
               str=temp1+p+temp3;
           }
         }
       sc.close();
  } 
}


Measured memory_bytes: 29588