akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

int n, m, x;
vi c;
vvi a;
const int INF = 100100100;

int dfs(int cnt, int sum, vi us){
    if(cnt == n){
        bool ok = true;
        rep(i, m) if(us[i] < x) ok = false;
        if(ok) return sum;
        else return INF;
    }
    else{
        int Nsum = sum + c[cnt];
        vi Nus(m);
        rep(i, m) Nus[i] += us[i] + a[cnt][i];
        return min(dfs(cnt+1, sum, us), dfs(cnt+1, Nsum, Nus));
    }
}

void Main(){
    cin >> n >> m >> x;
    c = vi(n);
    a = vvi(n, vi(m));

    rep(i, n){
        cin >> c[i];
        rep(j, m) cin >> a[i][j];
    }
    
    // dfs で 2^n 通りを全探索
    int ans = dfs(0, 0, vi(m, 0));
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
    return;
}

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

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

int main(){
  int d;
  cin >> d;
  vector<int> c(27);
  for(int i=1;i<=26;i++){
    cin >> c.at(i);
  }
  vector<vector<int>> s(d+1, vector<int>(27));
  for(int i=1;i<=d;i++){
    for(int j=1;j<=26;j++){
      cin >> s.at(i).at(j);
    }
  }
  vector<int> t(d+1); //1~26
  for(int i=1;i<=d;i++){
    cin >> t.at(i);
  }
  vector<int> v(d+1);
//  vector<vector<int>> last(d+1, vector<int>(27));
  vector<int> last(27,0);
  int score=0;
  
  for(int i=1;i<=d;i++){
    last.at(t.at(i)) = i;
    v.at(1) += s.at(i).at(t.at(i));
    for(int j=1;j<=26;j++){
//      v.at(1) = v.at(1) - c.at(j)*(i-last.at(i).at(j));
      v.at(1) = v.at(1) - c.at(j)*(i-last.at(j));
    }
    score = max(1000000+v.at(1),0);
    cout << v.at(1) << endl;
  }
  
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
#define Mod 1e9+7
const LL mod=1e9+7;
const LL inf=0x3f3f3f3f;
using namespace std;
int dis[Max],pre[Max];
int n,m;
void init()
{
	for(int i=0;i<=n;i++)
		pre[i]=i;
}
int Find(int x)
{
	if(x!=pre[x])
	{
		int fa=pre[x];
		pre[x]=Find(pre[x]);
		dis[x]+=dis[fa];
	}
	return pre[x];
}

int main()
{
	int x,y,d;
	scanf("%d%d",&n,&m);
	init();
	for(int i=0;i<m;i++)
	{
		scanf("%d%d%d",&x,&y,&d);
		int fx=Find(x),fy=Find(y);
		//printf("%d %d\n",fx,fy);
		if(fx==fy)
		{
			if(dis[x]+d!=dis[y])
			{
				printf("No\n");
				return 0;
			}
		}
		else
		{
			pre[fy]=fx;
			dis[fy]=dis[x]+d-dis[y];
		}


	}
	printf("Yes\n");
    return 0;
}


Measured memory_bytes: 1152
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;

namespace AOJ
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Trim().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        public static class eratos
        {
            const long Max = 100000000;
            static readonly bool[] isntprime = new bool[Max / 2 + 1];
            static eratos()
            {
                isntprime[0] = true;
                long sqrt = ((long)Math.Ceiling(Math.Sqrt(Max) + 0.1)) / 2;
                for (long i = 1; i < sqrt; ++i)
                    if (!isntprime[i])
                    {
                        long p = 2 * i + 1;
                        for (long j = 2 * i * (i + 1); j < isntprime.Length; j += p)
                            isntprime[j] = true;
                    }
            }
            static public bool isPrime(long x)
            {
                if (2 == x) return true;
                return x % 2 == 0 ? false : !isntprime[x / 2];
            }
        }
        static void Main(string[] args)
        {
            var cnt = 0;
            var n = Sarray()[0];
            for (var i = 0; i < n; ++i)
            {
                if (eratos.isPrime(Sarray()[0]))
                    ++cnt;
            }
            WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 69304
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;

int main(){
	string s;
	int indexA, indexZ;
	cin >> s;
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == 'A') {
			indexA = i;
			break;
		}
	}
	for (int i = s.size() - 1; i > 0; --i) {
		if (s[i] == 'Z') {
			indexZ = i;
			break;
		}
	}
	cout << indexZ - indexA + 1 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstdint>
#include <cmath>
#include <numeric>
#include <functional>
#include <queue>
#include <stack>
#include <deque>
#include <utility>

using namespace std;

void recdist(int i,
             int j,
             int h,
             int w,
             int **dist,
             int now_dist,
             deque<pair<int, int> > &bpoints,
             int &ret)
{
  if(i != 0 && dist[i - 1][j] > now_dist)
    {
      dist[i - 1][j] = now_dist;
      bpoints.push_back(make_pair(i - 1, j));
      ret = std::max(now_dist, ret);
      //      recdist(i - 1, j, h, w, dist, now_dist + 1);
    }
  if((i + 1) != h && dist[i + 1][j] > now_dist)
    {
      dist[i + 1][j] = now_dist;
      bpoints.push_back(make_pair(i + 1, j));
      ret = std::max(now_dist, ret);
      //      recdist(i + 1, j, h, w, dist, now_dist + 1);
    }
  if(j != 0 && dist[i][j - 1] > now_dist)
    {
      dist[i][j - 1] = now_dist;
      bpoints.push_back(make_pair(i, j - 1));
      ret = std::max(now_dist, ret);
      //      recdist(i, j - 1, h, w, dist, now_dist + 1);
    }
  if((j + 1) != w && dist[i][j + 1] > now_dist)
    {
      dist[i][j + 1] = now_dist;
      bpoints.push_back(make_pair(i, j + 1));
      ret = std::max(now_dist, ret);
      //      recdist(i, j + 1, h, w, dist, now_dist + 1);
    }
}

int main()
{
  int h,w;
  cin >> h >> w;
  char a[h][w];
  int **dist = new int*[h];
  deque<pair<int, int> > bpoints;
  for(int i = 0;
      i < h;
      ++i)
    {
      dist[i] = new int[w];
    }

  for(int i = 0;
      i < h;
      ++i)
    {
      for(int j = 0;
          j < w;
          ++j)
        {
          cin >> a[i][j];
          if(a[i][j] == '#')
            {
              dist[i][j] = 0;
            }
        }
    }


  for(int i = 0;
      i < h;
      ++i)
    {
      for(int j = 0;
          j < w;
          ++j)
        {
          if(a[i][j] == '#')
            {
              dist[i][j] = 0;
              bpoints.push_back(make_pair(i,j));
            }
          else
            {
              dist[i][j] = 1000000;
            }
        }
    }
  int now_dist = 1;
  int bpoints_size = bpoints.size();
  int ret = 0;
  while(bpoints_size != 0)
    {
      for(int i = 0;
          i < bpoints_size;
        ++i)
        {
          recdist(bpoints.front().first,
                  bpoints.front().second,
                  h,
                  w,
                  dist,
                  now_dist,
                  bpoints,
                  ret);
          bpoints.pop_front();
        }
      ++now_dist;
      bpoints_size = bpoints.size();
    }
  cout << ret << endl;


  return 0;
}


Measured memory_bytes: 13328
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <stack>

using namespace std;
const static int STRLEN_MAX = 110;
enum KType{
  PAREN,
  BRACKET
};

bool analyse( string str ) {
  stack<KType> stk;
  int len = str.size();
  for( int i = 0; i < len; i++ ) {
    switch ( str[ i ] ) {
      case '(':
        stk.push( PAREN );
        break;
      case '[':
        stk.push( BRACKET );
        break;
      case ')':
        if( stk.empty() ) { return false; }
        if( stk.top() != PAREN ) { return false; }
        stk.pop();
        break;
      case ']':
        if( stk.empty() ) { return false; }
        if( stk.top() != BRACKET ) { return false; }
        stk.pop();
        break;
    }
  }
  return stk.empty();
};

int main() {
  char str[ STRLEN_MAX ];
  int pos = 0;
  while( 1 ) {
    int c = getchar();
    if( c == '\n' || c == '\r' ) { continue; }
    str[ pos++ ] = c;
    if( c == '.' ) {
      str[ pos ] = '\0';
      if( string( str ) == "." ) { return EXIT_SUCCESS; }
      cout << ( analyse( str ) ? "yes" : "no" ) << endl;
      pos = 0;
    }
  }
}

Measured memory_bytes: 1172
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int r,g,b,n;
	scanf("%d%d%d%d",&r,&g,&b,&n);
	int a3 = max(max(r,g),b);
	int a1 = min(min(r,g),b);
	int a2 = r+g+b-a1-a3;
	long long sum = 0;
	for(int i = 0;i*a3<=n;i++){
		int f = i*a3;
		for(int j = 0;j*a2+f<=n;j++){
			int s = j*a2;
			if( (n-f-s) % a1 == 0)sum++;
		}
	}
	printf("%d\n",sum);
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=1.6e7+23;
const int N=16;

ll ans[N];
int x[N],y[N],p[N],_min[maxn][N],pw[N][3];
bool vis[maxn];
int n;

vector<int> mask(int j){
	vector<int> t(n);
	int now=0;
	while(now<n){
		t[now++]=j%3;
		j/=3;
	}
	return t;
}

int main(){
	memset(ans,0x3f,sizeof(ans));
	cin>>n;
	int BIT=1;
	int nn=n;
	for(int i=0,j=1;i<n;i++,j*=3){
		pw[i][1]=j;
		pw[i][2]=j*2;
	}
	while(nn--) BIT*=3;
	for(int i=0;i<n;i++){
		scanf("%d%d%d",&x[i],&y[i],&p[i]);
	}
	ans[0]=0;
	for(int i=0;i<n;i++){
		_min[0][i]=min(abs(x[i]),abs(y[i]));
		ans[0]+=1ll*_min[0][i]*p[i];
	}
	for(int i=1;i<BIT;i++){
		vector<int> bit=mask(i);
		int pop_count=0;
		for(int j:bit) pop_count+=j>0;
		int last=n-1;
		while(!bit[last]) last--;
		int pre=i-pw[last][bit[last]];
		ll cost=0;
		for(int j=0;j<n;j++){
			if(bit[last]==1)
				_min[i][j]=min(_min[pre][j],abs(x[last]-x[j]));
			else if(bit[last]==2)
				_min[i][j]=min(_min[pre][j],abs(y[last]-y[j]));
			cost+=1ll*_min[i][j]*p[j];
		}
		ans[pop_count]=min(ans[pop_count],cost);
	}
	for(int i=0;i<=n;i++){
		printf("%lld\n",ans[i]);
	}
}

Measured memory_bytes: 901304
s=gets.chomp.chars
t=gets.chomp.chars
ans = []
(s.length-t.length + 1).times do |i|
  res = 0
  t.length.times do |j|
    next if t[j] == s[j+i] 
    res += 1
  end
  ans << res
end
puts ans.min

Measured memory_bytes: 14388
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
using namespace std;

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

    vi v(n);
    each(&it,v)cin>>it;


    int ans=10000000;
    rep2(i,1,101)
    {
        int t=0;
        rep(j,n)
        {
            t+=pow(v[j]-i,2);
        }
        ans=min(ans,t);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(c,itr) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define INF 1e9
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
int main(){
	int n;
	cin>>n;
	pi p[n];
	rep(i,n){
		int a;
		cin>>a;
		p[i]=mp(a,i+1);
	}
	sort(p,p+n);
	rep(i,n){
		cout<<p[i].se<<" ";
	}
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout <<" "<<kbrni;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

//i???1-n?????§?????????
//i???????????§??????????¨??????????(i???1????????????)
//i???????????????x????????????(i???1????????????)
template<class V> class BIT {
private:
	int n;
	vector<V> bit;

public:
	void add(int i,V x)
	{
		while(i <= n){
			bit[i] += x;
			i += i & -i;
		}
	}
	V sum(int i)
	{
		V s = 0;
		while(i>0){
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}
	//?????????????????????0?????´???
	BIT(int sz){
		n = sz+1;
		bit.resize(sz+1,0);
	}
	BIT(vector<V> v) {
		int sz = (int)v.size();
		n = sz;
		bit.resize(n+1);
		rep(i,n){
			 add(i+1,v[i]);
		}
	}
};

int main()
{
	int n,q;
	cin >> n >> q;
	BIT<int> bt(n);
	rep(i,q){
		int a;
		cin >> a;
		if(a == 0){
			int x,y;
			cin >> x >> y;
			bt.add(x,y);
		}else{
			int x,y;
			cin >> x >> y;
			cout << bt.sum(y) - bt.sum(x-1) << "\n";
		}
	}
}

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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	int n , m ;
	cin>> n >> m ;
	vector<int> a(n);
	rep(i,n) cin >>a[i];
	map<int,int> P;//mod M / 回数
	int wa = 0 ;P[wa] ++;
	rep(i,n) {
		wa += a[i];
		wa %= m ;
		P[wa] ++ ;
	}
	ll ans = 0 ;
	for(auto x: P){
		ll N = x.second;
		ans += N * (N-1) / 2 ;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int main() {
    int N; cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        int a; cin >> a;
        if (i % 2 == 1 && a % 2 == 1) ans++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N;
    string S;
  	cin >> N >> S;
  	int x =0;
  	int x_max =0;
  	for(int i = 0;i < N;i++){
 		if(S[i] == 'I'){
      		x++;
          	x_max = max(x_max,x);
        }
      	else x--;	
    }
  	cout << x_max << endl;
}

Measured memory_bytes: 384
public class Main {
	public static void main(String[] args) {
		var sc = new java.util.Scanner(System.in);
		var d = sc.nextInt();
		var t = sc.nextInt();
		var s = sc.nextInt();

		System.out.println(((double) d / s <= t) ? "Yes" : "No");

	}
}


Measured memory_bytes: 35664
#include<stdio.h>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	int left,right;
	scanf("%d%d",&left,&right);
	if(right%n==0 || left%n==0){
		printf("OK\n");
	}else{
		
		if(right/n-left/n>0){
			printf("OK\n");
		}
		else	printf("NG");
	}
	return 0;
}

Measured memory_bytes: 3224
#include<iostream>
using namespace std;
int main(){
  string t;
  cin >> t;
  string s="Sunny";
  string c="Cloudy";
  string r="Rainy";
  if(t==s){
    cout << c;
  }else if(t==c){
    cout << r;
  }else{
    cout << s;
  }
  return 0;
}


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

int main() {
  int n, a, b;  cin >> n;
  a = n % 1110;
  b = (n % 1000) % 111;

  //1110で割って，1の位だけ残る ssst型
  if(0 <= a && a <= 9) {
    cout << "Yes" << endl;
  }
  //111で割って，1の位だけ残る sttt型
  else if(b == 0) {
    cout << "Yes" << endl;
  }
  //それ以外のgm
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,A,B,C;
    cin>>N>>A>>B>>C;
    vint l(N);
    REP(i,N) cin>>l[i];

    int ans=1e9;
    REP(_S,pow(4,N)){
        int a=0,b=0,c=0,cost=0;
        for(int i=0,S=_S;i<N;i++,S/=4){
            int x=S%4;
            if(x==0) if(a>0) cost+=10,a+=l[i]; else a+=l[i];
            if(x==1) if(b>0) cost+=10,b+=l[i]; else b+=l[i];
            if(x==2) if(c>0) cost+=10,c+=l[i]; else c+=l[i];
        }
        if(a and b and c){
            cost+=abs(a-A)+abs(b-B)+abs(c-C);
            ans=min(ans,cost);
        }
    }
    cout<<ans<<endl;
 
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <string>
#include <algorithm>

using namespace std;
typedef long long ll;

int main()
{
  ll N, M;
  
  cin >> N >> M;
  vector <pair<ll, ll> > x(N);

  for(int i=0;i<N;i++ )
    {
      int a,b;
      cin >> a >> b;
      x[i] = make_pair(a,b);
    }

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

  ll ans = 0;
  for(int i=0;i<N && M>0;i++)
    {
      ans += x[i].first*min(x[i].second, M);
      M -= min(x[i].second, M);
    }

  cout << ans << endl;
  return 0;
}


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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
  fastIO;
  string s;
  cin >> s;
  for(int i = 0 ; i < s.size(); i ++ ){
    cout << s[i];
    if(i==3)
      cout << " ";
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}



int main() {
	int n, m, a;
	while (1) {
		cin >> n >> m >> a;
		if (n == 0 && m == 0 && a == 0) break;
		vvi v(n + 1, vi(1001, 0));
		int h, p, q;
		rep(i, m) {
			cin >> h >> p >> q;
			v[p][h] = q;
			v[q][h] = p;
		}
		int pos = a;
		for (int i = 1000; i >= 0;i--) {
			if (v[pos][i] != 0) {
				pos = v[pos][i];

			}
		}
		cout << pos << endl;
	}
}



Measured memory_bytes: 3348
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(a) (a).begin(), (a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x, 0, sizeof(x))
#define MINF(x) memset(x, 0x3f, sizeof(x))
#define MMINUS(a) memset(a, 0xff, sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double EPS = 1.0 / LINF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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

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

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

using namespace std;

//===================================== template =========================================================

vector<int> GetPrime(int n) {
    vector<bool> t(n, true);
    t[1] = false;

    for (int i = 2; i <= n; ++i) {
        if (!t[i]) continue;
        for (int j = 2; i * j <= n; ++j) {
            t[i*j] = false;
        }
    }

    vector<int> prime;
    for (int i = 1; i <= n; ++i) if (t[i]) prime.push_back(i);
    return prime;
}

vector<int> CountDiv(int n) {
    vector<int> prime = GetPrime(n);
    vector<int> div_cnt(prime.size(), 0);
    
    for (int i = 0; i < prime.size(); ++i) {
        int p = prime[i];
        for (int num = 1; num <= n; ++num) {
            int cnt = 0; int tmp = num;
            while (tmp % p == 0) { cnt++; tmp /= p; }
            div_cnt[i] += cnt;
        }
    }

    return div_cnt;
}

ll cnt75(vector<int> divcnt) {
    ll cnt = 0;
    for (int i = 0; i < divcnt.size(); ++i) {
        if (divcnt[i] >= 74) cnt++;
    }

    for (int i = 0; i < divcnt.size(); ++i) 
    for (int j = 0; j < divcnt.size(); ++j) {
        if (i == j) continue;
        if (divcnt[i] >= 2 && divcnt[j] >= 24) cnt++;
        if (divcnt[i] >= 4 && divcnt[j] >= 14) cnt++;
    }

    for (int i = 0; i < divcnt.size(); ++i) 
    for (int j = 0; j < divcnt.size(); ++j)
    for (int k = j+1; k < divcnt.size(); ++k) {
        if (i == j || i == k) continue;
        if (divcnt[i] >= 2 && divcnt[j] >= 4 && divcnt[k] >= 4) cnt++;
    }

    return cnt;
}

int main() {
    cin.tie(nullptr); ios_base::sync_with_stdio(false);
    int N; cin >> N;
    auto cntDiv = CountDiv(N);
    cout << cnt75(cntDiv) << endl;
}

Measured memory_bytes: 888
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
    int a,b,c;
    while(scanf("%d%d",&a,&b)==2)
    {
        c=0;
        if(a>b)
        {
            c=c+a;
            a--;
        }
        else
        {
            c=c+b;
            b--;
        }
        if(a>b)
        {
            c=c+a;
            a--;
        }
        else
        {
            c=c+b;
            b--;
        }
        printf("%d\n",c);
    }
    return 0;
}


Measured memory_bytes: 128
prime = [3, 5, 7, 11, 13, 17]
N = int(input())
ans = 0
for i in range(1, N+1, 2):
    a = 1; x = i
    for j in range(6):
        n = prime[j]    #; print(i, n)
        w = 0
        while x%n == 0:
            x = x//n
            w += 1 
        a *= w + 1
        if x  == 1:
            break
    if a == 8:
        ans += 1
print(ans)

Measured memory_bytes: 9164
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#define rep(i,n) for (int i=0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
    int n, sum=0, front=-1;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n-1);
    rep(i, n)cin >> a[i];
    rep(i, n)cin >> b[i];
    rep(i, n-1)cin >> c[i];
    rep(i, n){
        sum += b[a[i]-1];
        if(a[i] == front+1) sum += c[front-1];
        front = a[i];
    }
    cout << sum << endl;
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

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

	ll n; cin >> n;
	vl a(n);
	FOR(i,0,n) cin >> a[i];

	ll res = 0, cur = 0;
	stack<pair<ll,pll>> s;
	s.push({0,{0,0}});
	FOR(i,0,n) {
		while (sz(s) && s.top().xx > a[i]) {
			auto e = s.top();
			cur -= e.xx*(e.yy.yy-e.yy.xx);
			s.pop();
		}
		cur += a[i]*(i+1-s.top().yy.yy);
		s.push({a[i],{s.top().yy.yy,i+1}});
		res += cur;
	}
	cout << res << endl;
}



Measured memory_bytes: 6656
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

ct=0
at=-100
for a in A:
    ct+=B[a-1]
    if a==at+1:
        ct+=C[a-2]
    at=a

print(ct)


Measured memory_bytes: 3060
#include<cstdio>
using namespace std;
int main()
{
	int t,i,flg;
	char s[100];
	scanf("%d",&t);
	scanf("%s",s);
	flg=0;
	if(t%2!=0)	flg=1;
	else{
		for(i=0;i<t/2;i++){
			if(s[i]!=s[t/2+i])	flg=1;
		}
	}
	if(flg==0)	printf("Yes\n");
	else	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
# coding = SJIS

n = int(input())
a = [int(input()) for i in range(n)]
ans = 0

a.sort()

i = 0

while i < n:
    ko = 1
    while (i + ko) < n and a[i] == a[i + ko]:
        ko += 1
    if ko % 2 == 1:
        ans += 1
    i += ko

print(ans)

Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define    ll          unsigned long long int
#define    sz          200010
#define    md          1000000007
#define    py          printf("Yes\n")
#define    pn          printf("No\n")
#define    sc1(a)      scanf("%lld",&a)
#define    sc2(a,b)    scanf("%lld %lld",&a,&b)
#define    pv(a)      printf("%lld\n",a)

using namespace std;


ll ara[sz];
ll num[sz];

int main()
{


    ll n,i,j,x=0;

    cin>>n;

    for(i=1;i<n;i++)cin>>num[i];

    ara[1]=num[1];
    ara[n]=num[n-1];

    for(i=2;i<n;i++)
    {
        ara[i]=min(num[i],num[i-1]);
    }

    for(i=1;i<=n;i++)
    {
        x+=ara[i];
    }


    cout<<x<<endl;




    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

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

    priority_queue<int> pq;
    
    rep(i, N) {
        int A;
        cin >> A;
        pq.push(A);
    }

    rep(i,M){
        int A = pq.top();
        pq.pop();
        pq.push(A/2);
    }

    ll ans = 0;
    while(!pq.empty()){
        int A = pq.top();
        pq.pop();
        ans+=A;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3912
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
#include<list>
using namespace std;

struct Info {
	int i;
	int j;
	int cnt;
	Info(int ii, int jj, int dcnt) {
		i = ii;
		j = jj;
		cnt = dcnt;
	}
};

// 特定の文字列を数える関数
size_t count(const string& str, const string& sub, const size_t ini = 0, const size_t fin = string::npos) {
	size_t pos = str.find(sub, ini);
	size_t cnt = 0;
	while (pos < fin) {
		cnt += 1;
		pos = str.find(sub, pos + sub.length());
	}
	return cnt;
}

int main() {

	int H, W;
	cin >> H >> W;

	vector<string> s(H, "");

	int nb = 0;

	for (int i = 0; i < s.size(); i++) {
		cin >> s[i];
		nb += count(s[i], "#");
	}

	list<Info> path;
	path.clear();
	path.push_back(Info(0, 0, 1));

	vector<Info> nns = { Info(-1,0,1), Info(1,0,1), Info(0,-1,1),Info(0,1,1) };

	Info loc = path.front();
	path.pop_front();

	int di = 0;
	int dj = 0;

	while (loc.i != H - 1 || loc.j != W - 1) {
		for (int k = 0; k < nns.size(); k++) {
			di = loc.i + nns[k].i;
			dj = loc.j + nns[k].j;
			if (0 <= di && di < H && 0 <= dj && dj < W) {
				if (s[di][dj] == '.') {
					s[di][dj] = '#';
					path.push_back(Info(di, dj, loc.cnt + nns[k].cnt));
				}
			}
		}
		if (path.size() == 0) {
			loc = Info(0, 0, -1);
			break;
		}
		else {
			loc = path.front();
			path.pop_front();
		}
	}

	if (loc.cnt == -1) {
		cout << -1 << endl;
	}
	else {
		cout << H * W - loc.cnt - nb << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,d[101111];
int main(){
	scanf("%d",&n);
	for(int i=0; i<=n; i++)d[i] = i;
	for(int i=6; i<=n; i*=6)
	for(int j=0; j+i<=n; j++)
		d[j+i] = min(d[j+i],d[j]+1);
	for(int i=9; i<=n; i*=9)
	for(int j=0; j+i<=n; j++)
		d[j+i] = min(d[j+i],d[j]+1);
	printf("%d\n",d[n]);
	return 0;
}


Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String toi = scanner.nextLine();
		int cflag = 0;
		int joken1 = 0;
		int joken2 = 0;
		int joken3 = 0;


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

			if(toi.charAt(0) == 'A') {
				joken1 = 1;
			}else {
				break;
			}

			if(2 <= i && i <= toi.length() - 2 && toi.charAt(i) == 'C' && joken2 == 0) {
				joken2++;
			}else if(0 < i  && Character.isUpperCase(toi.charAt(i))){
				joken3 ++;
				break;
			}
		}



		if(joken1 == 1 && joken2 == 1 && joken3 == 0) {
			System.out.println("AC");
		}else {
			System.out.println("WA");
		}
	}
}


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

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// Type / Class / Struct Definitions:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;

// Global Variables:

// Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) {
        cin >> a[i] >> b[i];
    }
    sort(all(a));
    sort(all(b));
    reverse(all(b));

    if(n % 2) {
        cout << b[n / 2] - a[n / 2] + 1 << endl;
        return 0;
    } else {
        cout << b[n / 2 - 1] + b[n / 2] - (a[n / 2 - 1] + a[n / 2]) + 1 << endl;
    }
    return 0;
}
// ===========================================

// Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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

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


Measured memory_bytes: 4844
#include <stdio.h>
#define N 60
#define M 1000000007
typedef long long LL;

LL read()
{
	char c;
	while((c = getchar()) < 48 || c > 57);
	LL x = c - 48;
	while((c = getchar()) > 47 && c < 58) x = x * 10 + c - 48;
	return x;
}

int main() 
{
	LL p2[N + 1], m2, x, sum = 0, y;
	int i, j, c1[N] = {0}, n;
		
	scanf("%d", &n);
	for(p2[j = 0] = 1, i = 1; i <= N; j = i++){
		p2[i] = p2[j] << 1;
	}
	for(register int i = 1; i <= n; i++){
		x = read();
		for(register int j = 0; x >= p2[j]; j++){
			if(x & p2[j]) c1[j]++;
		}
	}
	for(i = 0, m2 = 1, y = (LL)n; i < N; i++){
		x = (LL)c1[i];
		sum += x * (y - x) % M * m2 % M;
		m2 <<= 1;
		if(m2 >= M) m2 -= M;
	}
	printf("%lld\n", sum %= M);
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int a[30],t;
	r(i,30)a[i]=0;
	r(i,28){
		cin>>t;
		a[t-1]++;
	}
	r(i,30)if(!a[i])cout<<i+1<<endl;
}

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

int main (){/* 
    ll A;
    double B;
    cin >> A >> B;
    B *= 100;
    ll b = B;
    ll ans = A*b/100;
    cout << ans << endl;
 */
/* 力技
    ll A;
    string B;
    cin >> A >> B;
    if(B.size() == 1) {
        cout << A*(B.at(0) - '0') << endl;
    } else if(B.size() == 4){
        ll temp = 100*(B.at(0) - '0') + 10*(B.at(2) - '0') + B.at(3) - '0';
        cout << (A*temp)/100 << endl;
    } else {
        ll temp = 100*(B.at(0) - '0') + 10*(B.at(2) - '0');
        cout << (A*temp)/100 << endl;
    } */
    ll A;
    double B;
    cin >> A >> B;
    B *= 100;
    B += 0.5;
    ll b = B;

    cout << A*b/100 << endl;
}


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

int main()
{
    vector<vector<int>> A(3,vector<int>(3));
    vector<vector<bool>> check(3,vector<bool>(3));
    int N;
    int b[10];
    
    for(int i = 0;i<3;i++)
    {
        for(int j = 0;j<3;j++)
        {
            cin>>A[i][j];
        }
    }

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

    for(int i = 0;i<3;i++)
    {
        for(int j = 0;j<3;j++)
        {
            check[i][j] = false;
            for(int k = 0;k < N; k++)
            {
                if(A[i][j] == b[k])check[i][j] = true;
            }
        }
    }
    
    //ビンゴチェック(縦)
    for(int i = 0;i<3;i++)
    {
        if(check[i][0] and check[i][1] and check[i][2])
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }

    for(int i = 0;i<3;i++)//ビンゴチェック(横)
    {
        if(check[0][i] and check[1][i] and check[2][i])
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }

    if(check[0][0] and check[1][1] and check[2][2])
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    if(check[0][2] and check[1][1] and check[2][0])
    {
        cout<<"Yes"<<endl;
        return 0;
    }

    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int s[100000],t[100001];
int main(void){
    int n=100000;
    s[1]=1,s[2]=1;
    for(int i=2;i<n;i++){
        bool ok=true;
        for(int j=2;j*j<=i;j++){
            if(i%j==0){
                ok=false;
                break;
            }
        }
        if(ok==true){
            s[i-1]=1;
            if(s[(i+1)/2-1]==1){
                t[i]=1;
            }
        }
    }
    for(int i=0;i<100000;i++){
        t[i+1]+=t[i];
    }
    int m;
    cin>>m;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        cout<<t[b]-t[a-1]<<endl;
    }
    //cout<<t[3]<<endl;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REP1(i, n) for (ll i = 1; i <= n; i++)
#define RREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define RREP1(i, n) for (ll i = n; i >= 1; i--)
#define FOR(i, a, b, c) for (ll i = a; i <= b; i += c)
#define RFOR(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)
#define MAX3(a, b, c) MAX(MAX(a, b), c)
#define MIN3(a, b, c) MIN(MIN(a, b), c)
#define SORT(t, a, n) qsort(a, n, sizeof(t), ({ int _f (const void *_a, const void *_b) { return *(t *)_a - *(t *)_b; } _f; }))
#define RSORT(t, a, n) qsort(a, n, sizeof(t), ({ int _f (const void *_a, const void *_b) { return *(t *)_b - *(t *)_a; } _f; }))
#define SUM(a, n) ({ ll _s = 0; REP(_i, n) _s += a[_i]; _s; })
#define PROD(a, n) ({ ll _p = 1; REP(_i, n) _p *= a[_i]; _p; })
#define CNT(x, a, n) ({ ll _c = 0; REP(_i, n) if (a[_i] == x) _c++; _c; })
#define MAXM(t, a, n) ({ t _m = a[0]; REP(_i, n) _m = MAX(_m, a[_i]); _m; })
#define MINM(t, a, n) ({ t _m = a[0]; REP(_i, n) _m = MIN(_m, a[_i]); _m; })
#define INF 1073709056
#define LLINF 4611686016279904256LL
typedef long long ll;

int main() {
    int r, g, b;
    scanf("%d %d %d", &r, &g,&b);
    
    if ((r * 100 + g * 10 + b) % 4 == 0) puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 128
///
// File:  c.go
// Author: ymiyamoto
//
// Created on Sat May 26 17:04:42 2018
//
package main

import (
	"fmt"
)

const MOD int64 = 1e9 + 7

var N int
var T, A []int64

func max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func min(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func main() {
	fmt.Scan(&N)
	T = make([]int64, N)
	A = make([]int64, N)

	for i := range T {
		fmt.Scan(&T[i])
	}

	for i := range A {
		fmt.Scan(&A[i])
	}

	dp := make([]int64, N)
	for i := range T {
		if i != 0 {
			if T[i] != T[i-1] {
				dp[i] = 1
			} else {
				dp[i] = T[i]
			}
		} else {
			dp[i] = 1
		}

		if dp[i] == 1 && A[i] < T[i] {
			dp[i] = 0
		}
	}

	dp2 := make([]int64, N)
	for i := len(A) - 1; i >= 0; i-- {
		if i != len(A)-1 {
			if A[i] != A[i+1] {
				dp2[i] = 1
			} else {
				dp2[i] = A[i]
			}
		} else {
			dp2[i] = 1
		}
		if dp2[i] == 1 && T[i] < A[i] {
			dp2[i] = 0
		}
	}

	//fmt.Println(dp)
	//fmt.Println(dp2)

	ans := int64(1)
	for i := range dp {
		ans *= min(dp[i], dp2[i])
		ans %= MOD
	}
	fmt.Println(ans)
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int N;
  vector<int> a;
  int res=0;
  cin >> N;

  rep(i,N) {
    int aa;
    cin >> aa;
    a.push_back(aa);
  }

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

  int prev = 0;
  int cnt = 0;
  for(auto it=a.begin();it!=a.end();it++){
    if(*it==prev){
      cnt++;
    }
    else {
      if(cnt%2==1) res++;
      cnt=1;
    }
    prev = *it;
  }
  if(cnt%2==1) res++;

  cout << res << endl;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

string s;
int x,y;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> s >> x >> y;
}

bool arrival(vector<int> cmd, int x){
    int n=cmd.size();
    vector<map<int,bool>> dp(n+1);
    dp[0][0] = true;
    dp[1][cmd[0]] = true;
    for (int i = 1; i < n; i++)
    {
        for(auto d:dp[i]){
            dp[i+1][d.first+cmd[i]] = true;
            dp[i+1][d.first-cmd[i]] = true;
        }

    }
    return dp[n][x];
}

int solve(){
    vector<int> cmdX,cmdY;
    cmdY.push_back(0);
    bool argX=true;
    int suc=0;
    for (int i = 0; i < s.length(); i++)
    {
        if(s[i]=='F') suc++;
        else if(s[i]=='T'){
            if(argX) cmdX.push_back(suc);
            else cmdY.push_back(suc);
            suc=0;
            argX ^= true;
        }
        if(i==s.length()-1){
            if(argX) cmdX.push_back(suc);
            else cmdY.push_back(suc);
            suc=0;
            argX ^= true;
        }
    }
    DBG(cmdX)
    DBG(cmdY)
    string ans;
    if(arrival(cmdX,x) && arrival(cmdY,y)) ans="Yes";
    else ans="No";
    cout << ans << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 190720
// Problem : A - Weather Prediction 
// Contest : AtCoder Beginner Contest 141
// URL : https://atcoder.jp/contests/abc141/tasks/abc141_a
// Memory Limit : 1024,000000 MB 
// Time Limit : 2000,000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

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

  cout.precision(16);
  cout << fixed;
  
  vector<string> a = {"Sunny", "Cloudy", "Rainy"};
  
  string s;
  cin >> s;
  
  int idx = 0;
  for (int i = 0; i < (int)s.size(); ++i) {
    if (a[i] == s) {
      idx = i;
      
      break;
    }
  }
  
  cout << a[(idx + 1) % (int)a.size()];
}


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

typedef long long ll;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)


int main()
{
    optimize();


        ll n;
        cin>> n;

        ll a[n], mx[n], mn[n];

        for(ll i=0; i<n; i++)
            cin>> a[i];

            if(n==2)
            {
                cout<< max(a[0], a[1]);
                nl;
                return 0;

            }


        ll c=0;

        mx[0] = a[0];
        mn[n- 1] = a[n- 1];

        for (ll i = 1; i< n; i++)
            mx[i] = __gcd (mx[i- 1], a[i]);


        for (ll i = n- 2; i>= 0; i--)
            mn[i] = __gcd(mn[i + 1], a[i]);

            ll t, res= 1;
            res= max(mx[n-2], mn[1]);


        for(ll i=1; i<n; i++)
        {

            t= __gcd(mn[i], mx[i-2]);
            t= max(t, __gcd(t, a[i]));
            res= max(t, res);
        }

        cout<< res;
        nl;


    return 0;
}




Measured memory_bytes: 5964
#include<iostream>

int main(){
	int a,b;
	
	while( std::cin >> a >> b ){
		int num1 = a;
		int num2 = b;
	
		if( a<b ){
			num2 = a;
			num1 = b;
		}
		int gcd;
		while( (gcd = num1%num2) != 0){
			num1 = num2;
			num2 = gcd;
		}
		gcd = num2;
		int lcm = a / gcd * b;
		std::cout << gcd <<" "<< lcm << "\n";
	}
	
	return 0;
}

Measured memory_bytes: 1160
n, m = map(int, input().split())
a = list(map(int, input().split()))
threshold = 0
for ai in a:
  threshold += ai
threshold /= (4 * m)
a.sort(reverse=True)
for i in range(m):
  if a[i] < threshold:
    print('No')
    break
  if i == m - 1:
    print('Yes')
    break


Measured memory_bytes: 9148
#include<bits/stdc++.h>
#include<string>
#include<cctype>
#include<cmath>
#include<queue>
#include<stack> 
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
const int MAX_V=105;
 
int main(){
  
  string s;
  int i;
  
  cin >> s;
  for(i=0;i<s.size();i+=2){
    cout << s[i];
  }
  cout << endl;

    return 0;
}
 

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vector<vector<int>> g(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--,b--;
		g[a].push_back(b);
	}
	vector<int> ans(n+1);
	auto bfs=[&](int v){
		queue<int> que;
		vector<int> dist(n,-1),pre(n,-1);
		que.push(v);
		dist[v]=0;
		while(!que.empty()){
			int now=que.front();
			que.pop();
			for(auto itr:g[now]){
				if(dist[itr]!=-1) continue;
				dist[itr]=dist[now]+1;
				pre[itr]=now;
				que.push(itr);
			}
		}
		int cnt=INF,st;
		rep(i,n){
			if(i==v || dist[i]==-1) continue;
			for(auto itr:g[i]){
				if(itr==v){
					if(chmin(cnt,dist[itr])){
						st=i;
					}
				}
			}
		}
		if(cnt==INF){
			vector<int> ret(n+1);
			return ret;
		}
		vector<int> ret;
		while(st!=-1){
			ret.push_back(st);
			st=pre[st];
		}
		return ret;
	};
	rep(i,n){
		vector<int> now=bfs(i);
		if(ans.size()>now.size()) ans=now;
	}
	if(ans.size()==n+1){
		cout<<-1<<endl;
		return 0;
	}
	cout<<ans.size()<<endl;
	for(auto v:ans){
		cout<<v+1<<endl;
	}
}

Measured memory_bytes: 384
#include<cstdio>
#include<queue>
#include<string.h>
using namespace std;

const int MAXn = 1e5+5;
const int MAXm = 2e5+5;

int tot;
bool vis[MAXn];
int head[MAXn];
int to[MAXm<<1];
int nxt[MAXm<<1];
int bfscnt[MAXn];
bool flag = true;

int n, m;

void add(int x,int y) {

    nxt[++tot] = head[x];
    head[x] = tot;
    to[tot] = y;
}

void inp() {

    for(int i = 1; i <= m; i++) {

        int x,y;
        scanf("%d %d",&x,&y);
        add(x,y);
        add(y,x);
    }
}

void bfs() {

    queue<int> q;
    q.push(1);
    bfscnt[1] = 1;
    vis[1] = true;
    int cnt = 0;

    while(!q.empty()) {

        int x = q.front();
        q.pop();
        cnt++;
        for(int i = head[x]; i ;i = nxt[i]) {
            if(vis[to[i]])
                continue;
            vis[to[i]] = true;
            
            bfscnt[to[i]] = x;
            q.push(to[i]);
        }
    }
    if(cnt != n)
        flag = false;
}

void debug() {

    for(int i = 1; i <= n; i++)
        printf("%d ",bfscnt[i]);
}

int main() {

    while(~scanf("%d %d",&n,&m)) {
        inp();

        bfs();
        if(flag) {
            puts("Yes");
            for(int i = 2; i <= n; i++) {
                if(i == 2) printf("%d",bfscnt[i]);
                else printf("\n%d",bfscnt[i]);
            }
        }
        else puts("No");
        tot = 0;
        flag = true;
        memset(bfscnt,0,sizeof(bfscnt));
        memset(nxt,0,sizeof(nxt));
        memset(head,0,sizeof(head));
        memset(vis,false,sizeof(vis));
        puts("");
    }

    return 0;
}

Measured memory_bytes: 7272