akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int N; cin >> N;
  vector<int> p(N);
  for(int i=0; i<N; i++){
    cin >> p[i];
  }

  string ans = "YES";
  int cnt = 0;
  for(int i=0; i<N; i++){
    if (p[i] != (i+1)) cnt++;
    if (cnt > 2){
      ans = "NO";
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

#define SIZE 120

int main(void){
    int N, X;
    cin >> N >> X;
    int m[SIZE];
    for(int i=0; i<N; i++){
        cin >> m[i];
    }

    int m_min = INT32_MAX;
    int sum = 0;
    for(int i=0; i<N; i++){
        if(m[i] <= m_min){
            m_min = m[i];
        }
        sum += m[i];
    }

    int d_num=0;
    X -= sum;
    d_num += N;
    d_num += X/m_min;

    cout << d_num;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define inf 0x3f3f3f3f

int main()
{
    int n,maxx=0,flag=1;
    cin>>n;
    for(int i=0;i<n;i++) //1 2 1 1 3
	{
		int x; cin>>x;
		if(maxx>x)
		 {
		 	 flag=0;
		 }
		 if(maxx<x-1)//贪心  最大值能小则小
		 {
		 	if(x>1) maxx=x-1;
		 	 else   maxx=x;
		 }

		//cout<<maxx<<endl;
	}
	 if(flag)
		cout<<"Yes"<<endl;
	 else
		cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
H = int(input())
if H==1:
  print(1)
elif 2 <= H and H <= 3:
  print(3)
elif 4 <= H and H <= 7:
  print(7)
else:
  for i in range (1,43):
    if 2**(i-1)<=H and H <2**(i):
      print(2**(i)-1)
    else:
      pass

Measured memory_bytes: 3060
N,M = map(int,input().split(' '))
MOD = 1000000007
a = [int(input()) for i in [0]*M]

a.append(-1)
a.append(N+1)

a.sort()

ds = [a[i+1] - a[i] - 1 for i in range(0,M+1)]

if 0 in ds:
	print(0)
	exit()

k = max(ds)

a = [0,1]
for i in range(2,k+1):
	a.append((a[i-2]+a[i-1]) % MOD)

ans = 1

for d in ds:
	ans = (ans * a[d] ) % MOD

print(ans)







Measured memory_bytes: 7848
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int 
#define mod 10000000007

ll n,k,h[100001],dp[100001];

ll solve(ll i)
 {
    if(i>=n)
     {
      return mod;     
     }
    if(i==n-1)
     {
      return 0;     
     }
    if(dp[i]!=-1)
     {
         return dp[i];
     }
    ll ans=mod;
    for(ll j=1;j<=k&&(i+j)<n;j++)
     {
      ans=min(ans,solve(i+j)+abs(h[i+j]-h[i]));     
     }
    return dp[i]=ans; 
 }

int main() {
	// your code goes here
ll i;
cin>>n>>k;
for(i=0;i<n;i++)
 {
  cin>>h[i];
  dp[i]=-1;
 }
cout<<solve(0); 
	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
    int64_t n, m;
    cin >> n >> m;

    string s;
    cin >> s;

    vector<bool> gameover(n + 1);
    int64_t len = 0;
    for (auto c : s | indexed(0)) {
        gameover[c.index()] = (c.value() == '1');
        if (gameover[c.index()]) {
            ++len;

            if (len >= m) {
                cout << -1 << endl;
                return 0;
            }
        } else {
            len = 0;
        }
    }

    vector<int64_t> path;
    path.push_back(n);
    while (path.back() > 0) {
        auto cur = path.back();
        if (cur - m <= 0) {
            path.push_back(0);
            break;
        }

        int64_t cur3 = 0;
        for (auto cur2 : irange(cur - m, cur)) {
            if (gameover[cur2]) {
                continue;
            }

            bool found = false;
            cur3 = max(cur3, cur2 - m);
            while (cur3 < cur2) {
                if (!gameover[cur3]) {
                    path.push_back(cur2);
                    path.push_back(cur3);
                    found = true;
                    break;
                }
                ++cur3;
            }

            if (found) {
                break;
            }
        }
    }

    const auto* delim = "";
    for (uint64_t i = 0; i < path.size() - 1; ++i) {
        cout << delim << path[path.size() - 2 - i] - path[path.size() - 1 - i];
        delim = " ";
    }
    cout << endl;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define mod 1000000007

using namespace std;
int r[2001][2001],l[2001][2001],u[2001][2001],d[2001][2001];

int main()
{
	IOS;
	int n,m;
	cin>>n>>m;

	string s[n];
	for(int y=0;y<n;y++)
		cin>>s[y];
	for(int y=0;y<n;y++)
	{
		for(int x=0;x<m;x++)
		{
			if(s[y][x]=='.')
			{
				if(x==0)
					l[y][x]=1;
				else
					l[y][x]=l[y][x-1]+1;
			}
			else
				l[y][x]=0;
		}
	}

	for(int y=0;y<m;y++)
	{
		for(int x=0;x<n;x++)
		{
			if(s[x][y]=='.')
			{
				if(x==0)
					u[x][y]=1;
				else
					u[x][y]=u[x-1][y]+1;
			}
			else
				u[x][y]=0;
		}
	}


	for(int y=0;y<m;y++)
	{
		for(int x=n-1;x>=0;x--)
		{
			if(s[x][y]=='.')
			{
				if(x==n-1)
					r[x][y]=1;
				else
					r[x][y]=r[x+1][y]+1;
			}
			else
				r[x][y]=0;
			}
	}


	for(int y=0;y<n;y++)
	{
		for(int x=m-1;x>=0;x--)
		{
			if(s[y][x]=='.')
			{
				if(x==m-1)
					d[y][x]=1;
				else
					d[y][x]=d[y][x+1]+1;
			}
			else
				d[y][x]=0;
		}
	}

	int max__=0;
	for(int y=0;y<n;y++)
		for(int x=0;x<m;x++)
			max__=max(u[y][x]+d[y][x]+l[y][x]+r[y][x]-3,max__);
	cout<<max__;
	return 0;
}


Measured memory_bytes: 67072
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;

#define repi(i,a,b) for(ll i = (a); i < (b); i++)
#define rep(i, n) for(ll i = 0; i < (n); ++i)

int main() {
    ll MOD = 1000000007;
    int N, M;
    cin >> N >> M;
    vector<int> s(N);
    vector<int> t(M);
    rep(i, N) cin >> s[i];
    rep(i, M) cin >> t[i];
    vector<vector<ll>> v(N + 1);
    vector<vector<ll>> sum(N + 1);
    rep(i, N + 1) {
        v[i].resize(M + 1);
        sum[i].resize(M + 1);
        rep(j, M + 1) {
            v[i][j] = 0;
            sum[i][j] = 0;
        }
    }
    repi(i, 1, N + 1) {
        ll buf = 0;
        repi(j, 1, M + 1) {
            if (s[i - 1] != t[j - 1]) v[i][j] = 0;
            else v[i][j] = (1 + sum[i - 1][j - 1]) % MOD;
            buf += v[i][j];
            buf %= MOD;
            sum[i][j] = (sum[i - 1][j] + buf) % MOD;
        }
    }
    cout << 1+sum[N][M] << endl;
    return 0;
}



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

using namespace std;

int a[200020];
int si[200020];

int ff(int x) {
    return a[x]= a[x] == x ? x : ff(a[x]);
}


int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++)a[i] = i, si[i] = 1;
    for (int i = 1; i <= m; i++) {
        int x, y;
        cin >> x >> y;
        x = ff(x);
        y = ff(y);
        if (x != y) {
            a[y] = x;
            si[x] += si[y];
        }
    }
    int ma = 1;
    for (int i = 1; i <= n; i++) {
        ma = max(ma, si[i]);
    }
    cout << ma << endl;
    return 0;
}

Measured memory_bytes: 5168
#include <bits/stdc++.h>
using namespace std;
char a[1000];
int main()
{
	long long n,a1=0,a2=0,a3=0,a4=0;
	cin>>n;
	while(n--)
	{
		memset(a,'\0',sizeof(a));
		cin>>a;
			if(a[0]=='B')
			{
				a1++;
			}
			if(a[strlen(a)-1]=='A')
			{
				a2++;
			}
			if(a[strlen(a)-1]=='A'&&a[0]=='B')
			{
				a4++;
			}
		for(int i=0;i<strlen(a)-1;i++)
		{
			if(a[i]=='A'&&a[i+1]=='B')
			{
				a3++;
			}
		}
	}
	long long aa=min(a1,a2);
	if(a1==a4&&a2==a4&&a4!=0)
	{
		a3--;
	}
	cout<<aa+a3<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<vector>
#include<cstdio>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)

using namespace std;

enum FACE { TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT };
template <class T>
class dice {
public:
  dice() {
    id[TOP] = 0; id[FRONT] = 1; id[LEFT] = 2;
    id[RIGHT] = 3; id[BACK] = 4; id[BOTTOM] = 5;
  }
  T& operator[] (FACE f) { return var[id[f]]; }
  const T& operator[] (FACE f) const { return var[id[f]]; }
  bool operator==(const dice<T>& b) const {
    const dice<T> &a = *this;
    return a[TOP] == b[TOP] && a[BOTTOM] == b[BOTTOM] &&
      a[FRONT] == b[FRONT] && a[BACK] == b[BACK] &&
      a[LEFT] == b[LEFT] && a[RIGHT] == b[RIGHT];
  }
  void roll_x() { roll(TOP, BACK, BOTTOM, FRONT); }
  void roll_y() { roll(TOP, LEFT, BOTTOM, RIGHT); }
  void roll_z() { roll(FRONT, RIGHT, BACK, LEFT); }
  vector<dice> all_rolls() {
    vector<dice> ret;
    for (int k = 0; k < 6; (k&1?roll_y():roll_x()),++k)
      for (int i = 0; i < 4; roll_z(), ++i)
        ret.push_back(*this);
    return ret;
  }
  bool equivalent_to(const dice& di) {
    for (int k = 0; k < 6; (k&1?roll_y():roll_x()),++k)
      for (int i = 0; i < 4; roll_z(), ++i)
        if (*this == di) return true;
    return false;
  }
private:
  void roll(FACE a, FACE b, FACE c, FACE d) {
    T tmp = id[a];
    id[a] = id[b]; id[b] = id[c];
    id[c] = id[d]; id[d] = tmp;
  }
  T var[6];
  int id[6];
};

FACE face[] = {TOP,FRONT,RIGHT,LEFT,BACK,BOTTOM};

class UnionFind
{
public:
  int par[40];

  void init(int n){ rep(i,n)par[i] = i; }

  int find(int x)
  {
    if(x == par[x])return x;
    return par[x] = find(par[x]);
  }

  void unit(int x,int y)
  {
    x = find(x), y = find(y);
    if(x != y)par[x] = y;
    find(x),find(y);
  }

};

int main()
{
  int n;
  while(cin >> n,n)
    {
      dice<char> dices[n];
      string fc;
      rep(i,n)rep(j,6)
	{
	  cin >> fc;
	  dices[i][face[j]] = fc[0];
	}
      

      UnionFind uf;
      uf.init(n);
      rep(i,n)REP(j,i+1,n)
	if(dices[i].equivalent_to(dices[j]))uf.unit(i,j);

      set<int> ans;
      rep(i,n)ans.insert(uf.find(i));

      cout << n - ans.size() << endl;

    }
  return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int n,price=0;
    cin >> n;
    rep(cake,26){
        rep(donut,15){
            if(cake*4+donut*7==n){
                cout << "Yes";
                return 0;
            }
        }
    }
    
    cout << "No";
    
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>

int main(){
    double A, B;

    scanf("%lf", &A);
    scanf("%lf", &B);

    if(A>B)
        printf("GREATER\n");
    else if(B>A)
        printf("LESS\n");
    else
        printf("EQUAL\n");
    
    return 0;
}

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  CIN(N, K);
  vector< int > a(N);
  REP(i, N) {
    cin >> a[i];
  }
  map< int, int > mp;
  int ans = INF;
  int ub = 0;
  int sm = 0ll;
  REP(lb, N) {
    while (ub < N) {
      if (sm >= K) {
	break;
      }
      if (a[ub++] <= K && mp[a[ub - 1]]++ == 0) {
	sm++;
      }
    }
    if (sm >= K) {
      ans = min(ans, ub - lb);
    }
    /*
    debug(ans);
    debug(lb);
    debug(ub);
    debug(sm);
    cout << endl;
    */
    if (a[lb] <= K && --mp[a[lb]] == 0) {
      sm--;
    }
  }

  if (ans == INF) ans = 0;
  cout << ans << endl;

  

  return 0;
}




Measured memory_bytes: 7812
//**KEEP IT SHORT AND SIMPLE**

#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FILES freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define REP(i,a,b) for (int i = a; i < b; i++)
#define NL '\n'
#define F first
#define S second
#define dot(a, b) (conj(a) * (b)).real()
#define cross(a, b) (conj(a)* (b)).imag()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef bool bl;
typedef vector < vector<long long> > vvl;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
typedef map <long long, long long> mll;
typedef map <long long, bool> mlb;
typedef priority_queue<long long, vector<long long>, greater<long long> > minPq;
typedef tuple<ll, ll, ll> line;
typedef complex<double> point;
const double pi = 2 * acos(0.0);
const int OO = 0x3f3f3f3f;
int main()
{
    IO
    ll n;
    cin >> n;
    ll h[n], ans[n];
    REP(i, 0, n)    cin >> h[i];
    ans[0] = 0;
    ans[1] = abs(h[1] - h[0]);
    REP(i, 2, n)    ans[i] = min(abs(h[i] - h[i - 1]) + ans[i - 1], abs(h[i - 2] - h[i]) + ans[i - 2]);
    cout << ans[n - 1];
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    if(a+b < c) dunk(a+ 2*b +1);
    else dunk(b+c);
    
}
    

Measured memory_bytes: 256
L=int(input())-1
for i in range(1,21):
    if 2**i>L+1:
        N=i
        break
M=2*(N-1)
l=[]
for i in range(1,N):
    l.append((i,i+1,2**(i-1)))
    l.append((i,i+1,0))
L-=2**(N-1)-1
t=2**(N-1)
for i in range(N-1,-1,-1):
    if 2**i<=L:
        l.append((i+1,N,t))
        L-=2**i
        t+=2**i
        M+=1
print(N,M)
for i in l:
    print(*i)

Measured memory_bytes: 9232
unittest
{
	assert( [ "20 3", "5 10 15" ].parse.expand.solve == 10 );
	assert( [ "20 3", "0 5 15" ].parse.expand.solve == 10 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto kn = input.front.split.to!( long[] );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( kn[ 0 ], kn[ 1 ], as );
}

auto solve( long k, long n, long[] as )
{
	auto ans = long.max;
	as.sort();
	foreach( i, a; as )
	{
		ans = min( ans, as[ n - 1 + i ] - a );
		as ~= k + a;
	}
	return ans;
}


Measured memory_bytes: 11448
#include<bits/stdc++.h>
using   namespace      std;
typedef long long      LL;
typedef vector<int>    VI;
typedef pair<int,int>  PII;

int main(){

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

	cout<< ar[n/2] - ar[(n/2) - 1]<< endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    // 1. AC list を vector<bool>で持つ
    // 2. WAのcount

    int N,M;
    cin >> N >> M;
    // ac_list[0] は不使用
    vector<bool> ac_list(N+1,false);
    vector<pair<int,string>> submissions(M);

    // read ac list
    REP(i,M) {
        int q;
        string result;
        cin >> q >> result;
        if (result=="AC") ac_list[q]= true;
        auto p = make_pair(q,result);
        submissions[i]=p;
    }

    int pena_count = 0;
    // calc penalty count
    vector<bool> already_ac_list(N+1,false);
    REP(i,M) {
        // ACなら状態変化して飛ばす
        if (submissions[i].second == "AC") {
            already_ac_list[submissions[i].first] = true;
            continue;
        }
        // 既にACしているなら飛ばす
        if (already_ac_list[submissions[i].first]) continue;
        // 結果ACできていない問題なら飛ばす
        if (!ac_list[submissions[i].first]) continue;
        pena_count++;
    }

    int ac_count=0;
    // calc ac count
    FOR(i,1,N+1) {
        if (ac_list[i]) ac_count++;
    }
    cout << ac_count << " " << pena_count << endl;

    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cctype>
#include <cstdio>
#include <vector>
using namespace std;

int main()
{
    int price[3];
    cin >> price[0] >> price[1] >> price[2];
    sort(price, price+3);
    cout << price[0]+price[1];

    
    return 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>

/***** type *****/
using namespace std;
using ll = long long;
using ld = long double;
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
template <class T> using vvvt = vector<vector<vector<T>>>;
using ml = boost::multiprecision::cpp_int;

/***** define *****/
#define all(c) (c).begin(), (c).end()            // begin to end
#define rep(i, b, e) for (ll i = b; i < e; i++)  // repeat
#define repr(i, b, e) for (ll i = b; e < i; i--) // repeat reverse
/***** const value *****/
#define llong_max 9223372036854775807            // 9 * 10^18
#define ldbl_max 1.79769e+308                    // 1.7 * 10^308
#define mod 1000000007                           // 1e9 + 7
#define pi 3.14159265                            // 3.14 ...
#define nya 10                                   // nya size
/***** for each macro *****/
#define fori(i, ...) if(ll i = -1) for(__VA_ARGS__) if(i++, true)
#define each(i, e, v) fori(i, auto& e: v)
#define forir(i, ...) if(ll i = Size(v)) for(__VA_ARGS__) if(i--, true)
#define eachr(i, e, v) forir(i, auto& e: boost::adaptors::reverse(v))

/***** lambda *****/
auto Adjust = [] // add vector or sub vector
(auto b, auto e, auto x)
{ for (auto it = b; it != e; ++it)* it += x; };
auto Bit = [] // long long bit shift
(auto n) { return (1LL << n); };
auto Count = [] // long long count value
(auto b, auto e, auto x) { return (ll)count(b, e, x); };
auto CtoLL = [] // char to long long
(auto c) { return (ll)(c - '0'); };
auto Divc = [] // long double div ceiling
(auto a, auto b) { return ceil((ld)a / (ld)b); };
auto Nya = [] // long long nya size
(auto n) { return (ll)pow(10, n); };
auto Size = []  // long long collection size
(auto& c) { return (ll)(c).size(); };
auto Sum = []   // long long accumulate
(auto b, auto e) { return accumulate(b, e, 0LL); };
auto VVT = []   // vector<vector<T>> resize 
(auto& vvt, auto ysize, auto xsize)
{ vvt.resize(ysize); each(i, vy, vvt) vy.resize(xsize); };
auto VVVT = []   // vector<vector<vector<T>>> resize 
(auto& vvvt, auto zsize, auto ysize, auto xsize)
{ vvvt.resize(zsize); each(z, vz, vvvt) VVT(vz, ysize, xsize); };
auto InVVT = []  // input vector<vector<T>> (T != struct)
(auto& vvt) { each(y, vy, vvt) each(x, e, vy) cin >> e; };
auto InVVVT = [] // input vector<vector<vector<T>>> (T != struct)
(auto& vvvt) { each(z, vz, vvvt) InVVT(vz); };

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

	ll i = 5;
	ll ans = 0;
	if (N % 2 == 1)
	{
		cout << 0;
		return 0;
	}

	while (i <= N)
	{
		ll temp = N / i;
		temp /= 2;
		ans += temp;
		i *= 5;
	}

	cout << ans;
	return 0;
}



Measured memory_bytes: 256
n, k = map(int, input().split())
r, s, p = map(int, input().split())
d = {'r':r, 's':s, 'p':p}
t = input()
def janken(x):
    if x == 'r':
        return 'p'
    elif x == 's':
        return 'r'
    else:
        return 's'
l = ['']*k
for i in range(n):
    l[i%k] += t[i]
ans = 0
for i in l:
    dp = [janken(i[0])] + ['-1']*(len(i)-1)
    ans += d[janken(i[0])]
    for j in range(1, len(i)):
        if janken(i[j]) != dp[j-1]:
            ans += d[janken(i[j])]
            dp[j] = janken(i[j])
        else:
            dp[j] = '0'
print(ans)

Measured memory_bytes: 6132
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n; cin >> n;
    vector<int>v(n);
    for(auto & e : v) cin >> e;
    cout << accumulate(all(v),0LL,[](int a, int b){return a+b;}) - *max_element(all(v))/2  << endl;
}




Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class AtCoderA
{
    static void Main()
    {
        long a;
        long b;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            a = long.Parse(words[0]);
            b = long.Parse(words[1]);
        }

        Console.WriteLine((a + b) % 2 == 0 ? ((a + b) / 2).ToString() : "IMPOSSIBLE");
    }
}

Measured memory_bytes: 11092
def b(M,x,y,n=1):
 M[x][y]='0';t=[]
 if'1'==M[x-1][y]:t+=[b(M,x-1,y,n+1)]
 if'1'==M[x][y-1]:t+=[b(M,x,y-1,n+1)]
 if'1'==M[x+1][y]:t+=[b(M,x+1,y,n+1)]
 if'1'==M[x][y+1]:t+=[b(M,x,y+1,n+1)]
 M[x][y]='1'
 return max([n]+t)
for e in iter(input,'0'):
 n,m=int(e),int(input())
 P=[['0']*(n+2)for _ in[0]*(m+2)]
 for i in range(m):P[i+1][1:-1]=input().split()
 print(max(b(P,i,j)for i in range(1,m+1)for j in range(1,n+1)if'1'==P[i][j]))


Measured memory_bytes: 5732
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		long m = fs.nextLong();
		int a[] = fs.nextIntArray(n);
		
		for(int i=0;i<n;i++) {
			a[i]/=2;
		}
		
		long lcm = 1;
		for(int i=0;i<n;i++) {
			lcm = lcm(a[i],lcm);
			if(lcm > m) {
				System.out.println(0);
				return;
			}
		}
		for(int i=0;i<n;i++) {
			if((lcm/a[i]) %2 == 0) {
				System.out.println(0);
				return;
			}
		}
		
		long ans = (m - lcm) / (lcm*2) + 1;
		System.out.println(ans);
		
	}
	static long lcm(long x, long y) {
		return x / gcd(x, y) * y;
	}

	static long gcd(long x, long y) {
		return y == 0 ? x : gcd(y, x % y);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

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

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

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

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 40508
#include <iostream>

using namespace std;

int main()
{
  int H, W;
  cin >> H >> W;

  char GRID[100][100];
  bool is_all_white_H[100];
  bool is_all_white_W[100];
  
  for (int h=0; h<H; ++h) {
    for (int w=0; w<W; ++w) {
      cin >> GRID[h][w];
    }
  }

  for (int h=0; h<H; ++h) {
    is_all_white_H[h] = true;
    for (int w=0; w<W; ++w) {
      if (GRID[h][w]=='#') {
	is_all_white_H[h] = false;
	break;
      }
    }
  }

  for (int w=0; w<W; ++w) {
    is_all_white_W[w] = true;
    for (int h=0; h<H; ++h) {
      if (GRID[h][w]=='#') {
	is_all_white_W[w] = false;
	break;
      }
    }
  }

  for (int h=0; h<H; ++h) {
    if (is_all_white_H[h])
      continue;
    for (int w=0; w<W; ++w) {
      if (is_all_white_W[w])
	continue;
      cout << GRID[h][w];
    }
    cout << endl;
  }


  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String S = scan.nextLine();
        String T = scan.nextLine();
        boolean flag = false;
        int count = 0;
        for(int i = S.length()-T.length(); i >= 0; i--){
            count = 0;
            for(int j = 0; j < T.length(); j++){
                if(S.charAt(i+j) == T.charAt(j) || S.charAt(i+j) == '?'){
                    count++;
                }
            }
            if(count == T.length()){
                S = S.substring(0, i)+T+S.substring(i+T.length());
                flag = true;
                break;
            }
        }
        
        if(flag){
            S = S.replace("?", "a");
            System.out.println(S);
        }else{
            System.out.println("UNRESTORABLE");
        }
        
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;

void solve(){
	int s, t, d;
	cin >> s >>t >> d;
	vector<ll> w(d);
	rep(i, d) {
		cin >> w[i];
	}
	ll mi = 0;
	ll r = 0;
	rep(i, d) {
		r += w[i]; mi = min(mi, r);
		if (r + s <= t) {
			cout << i + 1 << endl; return;
		}
	}
	if (r >= 0) {
		cout << -1 << endl; return;
	}
	ll dif = (s - t + mi + abs(r) - 1) / abs(r);
	ll ans = dif * d;
	s -= dif * abs(r);
	if (s <= t) {
		cout << ans << endl; return;
	}
	rep(i, d) {
		ans++;
		s += w[i];
		if (s <= t) {
			cout << ans << endl; return;
		}
	}
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(5);
	//init();
	solve();

	//cout << "finish" << endl;
	//stop
	return 0;
}


Measured memory_bytes: 3612
#include<stdio.h>

#define N 100001
#define Gard -1

typedef struct{
  int parent;
  int leftch;
  int rightch;
}Tree;

int Calheight(int );

Tree Binary[N];

int main(){
  int loop,freq,lchild,rchild,count,change;
  int i;
  
  scanf("%d",&loop);
  for(i=0;i<loop;i++){
    Binary[i].parent=Gard;
  }
  
  for(i=0;i<loop;i++){
    scanf("%d %d %d",&freq,&lchild,&rchild);
    Binary[freq].leftch=lchild;
    Binary[freq].rightch=rchild;
    
    if(lchild!=Gard){
      Binary[lchild].parent=freq;
    }
    
    if(rchild!=Gard){
      Binary[rchild].parent=freq;
    }
  }
  
  for(i=0;i<loop;i++){
    printf("node %d: parent = %d, ",i,Binary[i].parent);

    if(Binary[i].parent==Gard){
      printf("sibling = %d, ",Gard);
    }
    
    else if((Binary[Binary[i].parent].leftch!=i) && (Binary[Binary[i].parent].leftch!=Gard)){
      printf("sibling = %d, ",Binary[Binary[i].parent].leftch);
    }
    
    else if((Binary[Binary[i].parent].rightch!=i) && (Binary[Binary[i].parent].rightch!=Gard)){
      printf("sibling = %d, ",Binary[Binary[i].parent].rightch);
    }

    else{
      printf("sibling = %d, ",Gard);
    }

    count=0;
    if(Binary[i].leftch!=Gard){
      count++;
    }

    if(Binary[i].rightch!=Gard){
      count++;
    }

    printf("degree = %d, ",count);

    count=0;
    change=i;
    while(Binary[change].parent>Gard){
      change=Binary[change].parent;
      count++;
    }
   
    printf("depth = %d, ",count);

    printf("height = %d, ",Calheight(i));
    
    if(Binary[i].parent==Gard){
      printf("root\n");
    }

    else if((Binary[i].leftch==Gard) && (Binary[i].rightch==Gard)){
      printf("leaf\n");
    }

    else{
      printf("internal node\n");
    }
						     
  }
  return 0;
}

int Calheight(int i){
  int height1=0;
  int height2=0;

  if(Binary[i].leftch!=Gard){
    height1=Calheight(Binary[i].leftch)+1;
  }
  
  if(Binary[i].rightch!=Gard){
    height2=Calheight(Binary[i].rightch)+1;
  }


  if(height1>=height2){
    return height1;
  }

  else{
    return height2;
  }
}



Measured memory_bytes: 2044
a = int(input())  # 数値入力
b = int(a/100)
c = a%100
if b>0 and b<=12:
    if c>0 and c<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if c>0 and c<=12:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 2940
inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
l = inp.shift().split(' ')
a = l.shift() * 1
b = l.shift() * 1
k = l.shift() * 1
if (k > a) {
    b = b - (k - a)
    if (b < 0) {
        b = 0
    }
    a = 0
} else {
    a = a - k
}
console.log(a + ' ' + b)


Measured memory_bytes: 21956
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

class Vector:
    def __init__(self, x, y):
        self.x, self.y = x, y
        self.sqrnorm = pow(self.x, 2) + pow(self.y, 2)
        self.norm = self.sqrnorm ** 0.5

    def __add__(self, other):
        return Vector(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return Vector(self.x - other.x, self.y - other.y)

    def __mul__(self, other):
        return Vector(self.x * other, self.y * other)

    __rmul__ = __mul__

class Circle:
    def __init__(self, ox, oy, r):
        self.o, self.r = Vector(ox, oy), r

def rot90(v): return Vector(-v.y, v.x)

def comv(c1, c2):
    if c1.r < c2.r: c1, c2 = c2, c1
    r1, o1 = c1.r, c1.o
    r2, o2 = c2.r, c2.o
    d = (o1 - o2).norm
    s, mx = r1 + r2 + d, max(r1, r2, d)
    if s + eps < 2 * mx: return []
    elif s > 2 * mx:
        a = (r1 * r1 - r2 * r2 + d * d) / d / 2
        h = (r1 * r1 - a * a) ** 0.5
        o2o1 = o2 - o1
        v1 = o1 + o2o1 * (a / d) + rot90(o2o1) * (h / d)
        v2 = o1 + o2o1 * (a / d) - rot90(o2o1) * (h / d)
        return [v1, v2]
    else: return [(o2 - o1) * (r1 / d)]

def isinside(c, v): return (c.o - v).norm <= c.r + eps

eps = 10 ** -7
def main():
    def ok(t):
        # 円の列挙と中心の列挙
        cc = []
        vv = []
        for x, y, c in xyc:
            cc.append(Circle(x, y, t / c))
            vv.append(Vector(x, y))
        # 共有点の列挙
        for j in range(n):
            for i in range(j):
                vv += comv(cc[i], cc[j])
        for v in vv:
            cnt=0
            for c in cc:
                if isinside(c,v):cnt+=1
                if cnt==k:return True
        return False

    n, k = MI()
    xyc = LLI(n)
    l, r = 0, 200000
    for _ in range(50):
        t = (l + r) / 2
        if ok(t): r = t
        else: l = t
    print(t)

main()


Measured memory_bytes: 85848
def gcd(a,b):
  if b == 0:
    return a
  return gcd(b,a%b)

N = int(input())
A = list(map(int,input().split()))
L = [0]*(N+2)
R = [0]*(N+2)
for i in range(N):
  L[i+1] = gcd(L[i],A[i])
for i in range(N,0,-1):
  R[i] = gcd(R[i+1],A[i-1])
ans = 0
for i in range(1,N+1):
  ans = max(ans,gcd(L[i-1],R[i+1]))
print(ans)


Measured memory_bytes: 14436
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var H = one[0];
  var A = one[1];
  myout(Math.ceil(H / A));
}


Measured memory_bytes: 29948
import scala.io.StdIn
object Main {
  def main(args:Array[String]):Unit = {

    val in = StdIn.readLine().split(" ").map(s => s.toInt)

    if (in(0) > in(1)) {
      println("a > b")
    } else if (in(0) < in(1)) {
      println("a < b")
    } else {
      println("a == b")
    }
  }
}

Measured memory_bytes: 43632
#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mInt = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000



int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<int> a(N),b(M);
	rep(i,N)scanf("%d",&a[i]);
	rep(i,M)scanf("%d",&b[i]);
	
	vector<int> c = convolution(a,b);
	
	rep(i,c.size()){
		if(i!=0)printf(" ");
		printf("%d",c[i]);
	}
	cout<<endl;
	
    return 0;
}


Measured memory_bytes: 18988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main()
{
    int n;
    cin >> n;
    vector<pair<int, int>> xy(n);
    ll ans = 0;
    set<int> s;
    for (int i = 0; i < n; i++)
    {
        int x, y;
        cin >> x >> y;
        xy[i] = make_pair(x, y);
    }
    int ma = __INT_MAX__;
    sort(xy.begin(), xy.end());
    for (int i = 0; i < n; i++)
    {
        for (int l = 0; l < n; l++)
        {
            int tmp = 0;
            if (i == l)
                continue;
            int y = xy[i].second - xy[l].second;
            int x = xy[i].first - xy[l].first;
            for (int j = 0; j < n; j++)
            {
                for (int k = 0; k < n; k++)
                {
                    if (k == i && j == 0)
                        continue;
                    int yy = xy[k].second - xy[j].second;
                    int xx = xy[k].first - xy[j].first;
                    if (y == yy && x == xx)
                        tmp++;
                }
            }
            ma = min(ma, n - tmp);
        }
    }
    if (n <= 2)
        cout << 1 << endl;
    else
        cout << ma << endl;
}


Measured memory_bytes: 256
fun main (args:Array<String>){
    val dayOfWeek = readLine()!!
    if(dayOfWeek == "SUN") print(7)
    if(dayOfWeek == "MON") print(6)
    if(dayOfWeek == "TUE") print(5)
    if(dayOfWeek == "WED") print(4)
    if(dayOfWeek == "THU") print(3)
    if(dayOfWeek == "FRI") print(2)
    if(dayOfWeek == "SAT") print(1)
}

Measured memory_bytes: 34328
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <vector>
#include <queue>
#include <unordered_map> 
#include <iomanip>
#include <random>
#include <future>
#include <thread>
#include <utility>
#include <set>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (INT_MAX/3)
#define INF_L (LLONG_MAX/3)
#define PSB push_back
#define PN 1000000007
typedef long long LL;
#define int long long


// booooooooooooost
// #include <boost/multiprecision/cpp_int.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// namespace mp = boost::multiprecision;	//多倍長整数(mp::cpp_int), 多倍長小数(mp::cpp_dec_float_100)


signed main() {

	string s;
	cin >> s;

	if (4 <= s.size() && s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	

	return 0;
}

Measured memory_bytes: 256
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let v = read_vec::<u32>();
    let a = v[0];
    let b = v[1];
    println!("{}", a * b - (a + b - 1));
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdio>
#include<utility>
#include<algorithm>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
using ll=long long;

int N,M;
int X[100],Y[100],h[100];


int main(){
    string s,t;cin>>s>>t;
    int n=s.size();
    vector<char> S(26,'!'),T(26,'!');
    bool flags=true;
    rep(i,0,n){
        if(S[(int)(s[i]-'a')]=='!'){
          S[(int)(s[i]-'a')]=t[i];
          continue;
        }  
        if(S[(int)(s[i]-'a')]!='!'&&S[(int)(s[i]-'a')]!=t[i]){
            flags=false;break;
        }
    }
    bool flagt=true;
    rep(i,0,n){
        if(T[(int)(t[i]-'a')]=='!'){
          T[(int)(t[i]-'a')]=s[i];
          continue;
        }  
        if(T[(int)(t[i]-'a')]!='!'&&T[(int)(t[i]-'a')]!=s[i]){
            flagt=false;break;
        }
    }
    if(flags&&flagt) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;    
}

Measured memory_bytes: 776
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

ll n,d,x;

vector<vector<ll>> P;

ll ans(ll k,ll day){
    vector<ll> dp(k+1,0);
    dp[0]=k;
    for(int i=0;i<n;i++){
        for(int t=0;t+P[day][i]<=k;t++){
            dp[t+P[day][i]]=max(dp[t+P[day][i]],dp[t]+P[day+1][i]-P[day][i]);
        }
    }
    ll ret=0;
    for(int i=0;i<=k;i++){
        ret=max(ret,dp[i]);
    }
    return ret;
}


int main(){
    cin>>n>>d>>x;
    P.resize(d,vector<ll>(n));
    for(auto &i:P){
        for(auto &t:i){
            cin>>t;
        }
    }
    for(int i=0;i+1<d;i++){
        x=ans(x,i);
    }
    cout<<x<<endl;
    
    
    return 0;
}



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

using i64 = int64_t;

map<char, int> mp;

string init(){
    string res = "";
    for(char c='a';c<='z';++c){
        res.push_back(c);
        mp[c] = c - 'a';
    }
    for(char c='A';c<='Z';++c){
        res.push_back(c);
        mp[c] = c - 'A' + 26;
    }
    return res;
}

int main(){
    int n;
    string alphabets = init();
    while(cin >> n, n != 0){
        vector<int> v;
        for(int i=0;i<n;++i){
            int k;
            cin >> k;
            v.push_back(k);
        }
        string s;
        cin >> s;
        string ans = "";
        int idx = 0;
        for(auto e: s){
            int i = mp[e] - v[idx];
            if(i < 0)i += 52;
            ans.push_back(alphabets[i]);
            idx++;
            idx %= (int)v.size();
        }
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3164
#include<bits/stdc++.h>
#define sz(v) ((int)(v).size())
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 2005;

int h, w, a, b;
char str[MAXN][MAXN];

int main(){
	cin >> h >> w >> a >> b;
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			str[i][j] = '0';
		}
	}
	swap(b, a);
	for(int i=0; i<a; i++){
		for(int j=0; j<b; j++){
			str[i][j] = '1';
		}
	}
	for(int i=a; i<h; i++){
		for(int j=b; j<w; j++){
			str[i][j] = '1';
		}
	}
	for(int i=0; i<h; i++) puts(str[i]);
}


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

using namespace std;using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

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

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

int main() {
  string S;
  cin >> S;
  if(S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) {
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pi pair<int,int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<": "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int MAXN = 1e7 + 5;

void cp()
{
    int k;
    cin >> k;
    bool ok = false;
    int sum = 0;
    int ans = -1;
    for(int i = 1; i <= k; i++)
    {
        sum = sum * 10 + 7;
        sum %= k;
        if(sum == 0)
        {
            ans = i;
            break;
        }
    }
    cout << ans;
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}

Measured memory_bytes: 3656
# -*- coding: utf-8 -*-
# 引数が一つだけのやつ
# n = int(input())
# 引数が複数あるやつ（全部数字）
# target = [int(x) for x in input().split()]

# 引数が複数あるやつ（そうじゃないの）
# target = [int(x) for x in input().split()]

# 最初の行で複数行を受け取って処理するやつ
target_1 = list(input())
target_2 = list(input())

# 初期

result = 0
# 判定
for idx in range(len(target_1)):
    if target_1[idx] != target_2[idx]:
        result += 1

print(result)


Measured memory_bytes: 12464
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
 
#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    int r;
    cin >> r;
    if(r < 1200){
        cout << "ABC" << endl;
    }else if(r < 2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
    return 0;
}

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

using namespace std;

typedef vector<int> Vec;

void solve(Vec &s){
  int ans = 20;
  const int dx[8] = {-1,-1,-1,0,0,1,1,1};
  const int dy[8] = {-1,0,1,-1,1,-1,0,1};
  queue<Vec> Q;
  Q.push(s);
  set<Vec> visited;
  visited.insert(s);
  while(!Q.empty()){
    Vec v = Q.front(); Q.pop();
    int size = v.size();
    ans = min(ans,size);
    for(int i = 0 ; i < size ; i++){
      for(int j = 0 ; j < 8 ; j++){
        Vec next;
        int nx = i%4 + dx[j];
        int ny = i/4 + dy[j];
        if(nx < 0 || ny < 0 || nx >= min(4,size) || ny >= 5) continue;
        if(nx+ny*4 < 0 || nx+ny*4 >= size) continue;
        if(v[i] == v[nx+ny*4]){
          for(int k = 0 ; k < size ; k++){
            if(i == k || nx+ny*4 == k) continue;
            next.push_back(v[k]);
          }
          if(!visited.count(next)){
            visited.insert(next);
            Q.push(next);
          }
        }
      }
    }
  }
  cout << ans << endl;
}

int main(){
  int Tc;
  cin >> Tc;
  while(Tc--){
    Vec vec(20);
    for(int i = 0 ; i < 20 ; i++){
      cin >> vec[i];
    }
    solve(vec);
  }
  return 0;
}

Measured memory_bytes: 1324