akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
vi e[100001];
int n,m;
int a,b;
int dp[100001];
int dfs(int x){
	if(dp[x]!=-1)
	re dp[x];
	int mx=0;
	rep(i,e[x].size())
	mx=max(mx,dfs(e[x][i])+1);
	dp[x]=mx;
	re dp[x];
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m;
	rep(i,m){
		cin>>a>>b;
		e[a-1].pb(b-1);
	}
	int ans=0;
	rep(i,n)
	dp[i]=-1;
	rep(i,n){
		ans=max(ans,dfs(i));
	}
	cout<<ans;
	re 0;
}



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

int par[MAX_N],temp[MAX_N],ans[3][MAX_N];
int myrank[MAX_N];

//Initialization
void init(int n){
	for(int i = 0; i < n; i++){
		par[i] = i;
		myrank[i] = 0;
	}
}



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

void unite(int x, int y){
	x = find(x);
	y = find(y);
	if(x == y) return;
	
	if(myrank[x] < myrank[y]){
		par[x] = y;
	} else {
		par[y] = x;
		if(myrank[x] == myrank[y]) myrank[x]++;
	}
}

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



signed main(){
	
	init(MAX_N);
	
	int N, K, L;
	int q, p, r ,s;
	map<pair<int,int>,int> mp;
	// vector<pair<int,int>> vp;
	// set<pair<int,int>> sp;
	
	
	cin>>N>>K>>L;
	
	rep(i, K){
		cin>>p>>q;
		unite(p,q);
	}
	rep(i, L){
		cin>>r>>s;
		unite(r+N,s+N);
	}
	
	
	
	rep(i,N){
		// ans[0][find(i)]++;
		// ans[1][find(i+N)]++;
		// vp.push_back(make_pair(find(i),find(i+N)));
		// if(same(i,find(i+N)) && same(i+N, find(i)+N))ans[2][find(i)]++;
		// if(mp.count(make_pair(find(i),find(i+N)))) mp[make_pair(find(i), find(N+i))]++;
		// else mp.insert(make_pair(make_pair(find(i),find(i+N)),1));
		mp[make_pair(find(i), find(N+i))]++;
	}
	
	rep(i,N){
		pair<int, int > temp;
		
		if(i-1)cout<<" ";
		
		cout<<mp[make_pair(find(i),find(N+i))];
		// cout<<min(ans[0][find(i)],ans[1][find(i+N)]);
		// cout<<ans[0][find(i)]<<" "<<ans[1][find(i+N)]<<" "<<ans[2][find(i)]<<" ";
	}cout<<endl;
	
	
	return 0;
}

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

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

int main() {
    int nmax = 1500;
    int a, b;
    cin >> a >> b;

    vector<vector<int> > v(nmax,vector<int>(2));
    rep(i, nmax){
        v[i][0] = (int)(i * 0.08);
        v[i][1] = (int)(i * 0.10);
    }

    int ans = -1;
    rep(i, nmax){
        if(v[i][0] == a && v[i][1] == b){
            ans = i;
            break;
        }    
    }
    cout << ans << endl;
    return 0;    
}


Measured memory_bytes: 384
N = int(input())
ans = int(input())

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

def lcm(x,y):
    return (x*y//gcd(x,y))

for i in range(N-1):
    t = int(input())
    ans = lcm(ans,t)

print(ans)


Measured memory_bytes: 2940
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
unordered_map<int,unordered_set<int> > R;
unordered_map<int,unordered_set<int> > B;

void solve(){
	int n,ans=0;
	cin >> n;
	vector<pair<int,int> > red(n),blue(n);
	for(int i = 0 ;i < n ; i++)cin >> red[i].first >> red[i].second;
	for(int i = 0 ;i < n ; i++)cin >> blue[i].first >> blue[i].second;
	
	sort(all(red));
	sort(all(blue));
	VI u(n,0);
	for(int i=0;i<n;i++){
		int mx=-1e9,tar=-1;
		for(int j=0;j<n;j++){
			if(u[j])continue;
			if(red[j].fi<blue[i].fi&&red[j].se<blue[i].se&&red[j].se>mx){
				mx = red[j].se;
				tar = j;
			}
		}
		if(tar!=-1){
		//	cout<<"tar=="<<tar<<endl;
			ans++;
			u[tar]=1;
		}
	} 
	cout<<ans<<endl;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
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 long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)



int main(){
    char c[2][3];
    rep(i,2) rep(j,3) cin>>c[i][j];

    bool ans=true;

    if(c[0][0]!=c[1][2]||c[0][1]!=c[1][1]||c[0][2]!=c[1][0]){
        ans=false;
    }
    if(ans) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

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

int main(){
  ll n;
  std::cin >> n;
  std::vector<ll> a(n);

  std::map<ll, ll> ch;

  ll sum=0;
  rep(i,n){
    ll temp;
    std::cin >> temp;
    ch[temp]++;
    sum+=temp;
  }


  ll q;
  std::cin >> q;

  std::vector<ll> ans(q);

  rep(i,q){
    ll b,c;
    std::cin >> b >> c;
    ch[c]+=ch[b];

    ll dec=ch[b]*b;
    ll inc=c*ch[b];

    sum=sum-dec+inc;
    ans[i]=sum;



    ch[b]=0;
  }

  for(ll num: ans){
    std::cout << num << '\n';
  }


  return 0;
}


Measured memory_bytes: 10492
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    if(n%4==0||n%7==0)
    {
        printf("Yes\n");
    }
    else if(n<4)
        printf("No\n");
    else
    {
        for(int i=0; i<100; i++)
            for(int j=0; j<100; j++)
                if((i*4+j*7)==n)
                {
                    printf("Yes\n");
                    return 0;
                }
        printf("No\n");
    }
}


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

using namespace std;
typedef pair<int,int> P;
typedef long long int ll;


P f(int x){
    int a = x%10;

    int b = 0;
    while (x) {
        b = x;
        x /= 10;
    }

    return P(a,b);
}


int main()
{
    int n;
    cin >> n;
    std::map<P,int> d;
    for (int i = 1; i <= n; ++i) {
        d[f(i)]++;
    }

    ll ans = 0;

    for (int i = 1; i <= n; ++i) {
        P p = f(i);
        ans += d[P(p.second, p.first)];
    }

    cout << ans << endl;

    return 0;
}

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

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

    
    string s;
    cin>>s;
    int n=s.length();
    int i=0;
    int j=((n-1)/2)-1;
    bool f1=true;
    while(i<=j){
        if(s[i]==s[j]){
            i++;
            j--;
        }
        else{
            f1=false;
            break;
        }
    }
    bool f2=true;
    i=((n+3)/2)-1;
    j=n-1;
    while(i<=j){
        if(s[i]==s[j]){
            i++;
            j--;
        }
        else{
            f2=false;
            break;
        }
    }
    bool f3=true;
    i=0;
    j=n-1;
    while(i<=j){
        if(s[i]==s[j]){
            i++;
            j--;
        }
        else{
            f3=false;
            break;
        }
    }
    /*if(f1){
        cout<<1<<" ";
    }
    if(f2){
        cout<<2<<" ";
    }
    if(f3){
        cout<<3<<endl;
    }*/

    if(f1&&f2&&f3){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int N;
  cin >> N;
  if(N == 1) {
    cout << "Hello World" << endl;
    return 0;
  }
  if(N == 2) {
    int a, b;
    cin >> a >> b;
    cout << a + b << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int fa[100500];
int road[100500];
int get_fa(int x) {
    if(fa[x]==x)return x;
    int a1=fa[x];
    int a2=get_fa(fa[x]);
    fa[x]=a2;
    road[x]=road[x]+road[a1];
    return a2;
}
int find_dis(int x) {
    if(fa[x]==x)return 0;
    return find_dis(fa[x])+road[x];
}

int main() {
    int n,cas,L,R,D;
    cin>>n>>cas;
    for(int i=0; i<=n; i++) {
        fa[i]=i;
        road[i]=0;
    }
    while(cas--) {
        cin>>L>>R>>D;
        int fl=get_fa(L);
        int fr=get_fa(R);
        if(fl==fr) {
            if(road[L]+D!=road[R]) {
                cout<<"No"<<endl;
                return 0;
            }
        } else {
            fa[fr]=fl;
            road[fr]=find_dis(L)-find_dis(R)+D;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

int main() {
  
  //文字列の箱の用意
  int N , M;
  cin >> N;
  vector <string> s (N);
  vector <string> t (M);
  
  //得点判定用num_maxとnum_now
  int num_max=0, num_now=0;
  
  //文字列の格納
  for(int i = 0;i < N; i++){
   	cin >> s.at(i); 
  }
  
  cin >> M;
  for(int i = 0;i < M; i++){
   	cin >> t.at(i); 
  }
  
  
  //判定用プログラム
  //判定用プログラム加算
  for(int i=0;i < N; i++){
    num_now=1;
    for(int j=i+1;j < N;j++){

      if(s.at(i) == s.at(j)){
        num_now++;
      }
    }
    
    //判定用プログラム減少
    for(int j=0;j < M;j++){
      if(s.at(i) == t.at(j)){
        num_now--;
      }
    }
     //最大値の置き換え
    if(num_max < num_now){
      num_max = num_now;
    }
  }
  
  //出力
  cout << num_max << endl;
  
  
}



Measured memory_bytes: 4320
n = int(input())
a = 0
w = 0
t = 0
r = 0

for i in range(n):
    s = input()
    if s == "AC":
        a += 1
    elif s == "WA":
        w += 1
    elif s == "TLE":
        t += 1
    elif s == "RE":
        r += 1
print(f'AC x {a}')
print(f'WA x {w}')
print(f'TLE x {t}')
print(f'RE x {r}')







Measured memory_bytes: 9200
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	char c[11];
	scanf("%s",&c);
	if(c[0]=='Y'&&c[1]=='A'&&c[2]=='K'&&c[3]=='I')printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 256
def partition(A, p, r):
    key = A[r]
    i = p
    for j in range(p, r):
        # 把小的放在左边
        if A[j] <= key:
            A[i], A[j] = A[j], A[i]
            i += 1
    # 最后交换key值
    A[r], A[i] = A[i], A[r]
    return i


if __name__ == '__main__':
    n = int(input())
    numlist = [int(num) for num in input().split(' ')]
    index = partition(numlist, 0, len(numlist) - 1)
    out = str(numlist[0:index]).replace(',', '').replace('[', '').replace(']', '') \
        + ' [' + str(numlist[index]) + '] '\
        + str(numlist[index + 1:]).replace(',', '').replace('[', '').replace(']', '')
    print(out)


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

int main() {

    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << max(a*c, max(a*d, max(b*c, b*d))) << endl;

    return 0;
}

Measured memory_bytes: 3536
n,m=map(int,input().split())
ansl=1
ansr=n
flag=0
for i in range(m):
    l,r=map(int,input().split())
    if (ansl>r)or(ansr<l):
        flag=1
        break
    if ansl<l:
        ansl=l
    if ansr>r:
        ansr=r
if flag==0:
    print(ansr-ansl+1)
else:
    print(0)

Measured memory_bytes: 45348
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  int a,b,h;
  cin>>a>>b>>h;
  cout<<(a+b)*h/2<<endl;
	return 0;
}

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

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	ll N;  cin >> N;

	ll keep;
	for(ll i = 1 ; i * i <= N ; i++)	if(N % i == 0)  keep = i;

  	ll keep2 = N / keep;
  	ll ans = 0;
  	while(keep > 0 || keep2 > 0){
		ans++;
      	keep /= 10, keep2 /= 10;
    }

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char s[3];
	int a=0,i;
	scanf("%s",s);
	for(i=0; i<3; i++){
		if(s[i]=='o'){
			a=a+1;
		}
	}
	printf("%d\n",700+100*a);
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
const vector<int> dy={-1,0,1,0},dx={0,-1,0,1};
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>void debag(const vector<T> &a){cerr<<"debag :";for(auto v:a)cerr<<v<<" ";cerr<<"\n";}
template<class T>void print(const vector<T> &a){for(auto v:a)cout<<v<<" ";cout<<"\n";}
class UF{
public:
	vector<int> par,num;
	int find(int v){
		return (par[v]==v)? v: (par[v]=find(par[v]));
	}
	explicit UF(int N):par(N),num(N,1){
		iota(all(par),0);
	}
	void unite(int u,int v){
		u=find(u),v=find(v);
		if(u==v)return;
		if(num[u]<num[v])swap(u,v);
		num[u]+=num[v];
		par[v]=u;
	}
	bool same(int u,int v){
		return find(u)==find(v);
	}
	bool ispar(int v){
		return v=find(v);
	}
	int size(int v){
		return num[find(v)];
	}
};
int main(){
  ll n;
  cin>>n;
  V<P> d(n);
  map<int,int> mp;
  for(int i=0;i<n;i++){
      cin>>d[i].fi>>d[i].se;
      mp[d[i].se]=i;
  }
  sort(all(d));
  UF uf(n);
  set<int> s,t;
  for(int i=1;i<=n;i++){
      s.insert(i);
  }
  for(int i=0;i<n;i++){
     auto ite=s.upper_bound(d[i].se);
     auto itt=t.lower_bound(d[i].se);
      if(ite!=s.end()){
          uf.unite(mp[d[i].se],mp[*ite]);
      } 
      if(itt!=t.begin()){
          itt--;
          uf.unite(mp[d[i].se],mp[*itt]);
      }
     if(s.size()){
          if(d[i].se<*s.rbegin())uf.unite(mp[d[i].se],mp[*s.rbegin()]);
      } 
      if(t.size()){
          if(d[i].se>*t.begin())uf.unite(mp[d[i].se],mp[*t.begin()]);
      }
      s.erase(d[i].se);
      t.insert(d[i].se);
  }
  for(int i=0;i<n;i++){
      cout<<uf.size(i)<<"\n";
  }
}


Measured memory_bytes: 26684
#include <bits/stdc++.h>
#define lol long long
using namespace std;
int main(){
    int a,b,c;
    string s,t,q;
    cin>>a>>b;
    if(a%3==0 || b%3==0 || (a+b)%3==0) cout<<"Possible\n";
    else cout<<"Impossible\n";
    return(0);
}

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

int main() {
  int N,x,sum;
  cin >> N;
  
  vector<int> vec(N);
  
  for (int i=0; i<N ; i++){
    cin >> vec.at(i);
  }
  
  x=1;
  sum=0;
  
  while (x!=2 && sum<N){
    x=vec.at(x-1);
    sum++;
  }
  if (x!=2){
    cout << "-1" <<endl;
  }
  else{
    cout << sum <<endl;
  }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
//typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    int M,T,PP,R;
    while(cin>>M>>T>>PP>>R && M){
        vector<int> tim(T,0);
        vector<vector<bool>> solve(T,vector<bool>(PP,false));
        vector<vector<int>> WA(T,vector<int>(PP,0));
    
        rep(i,0,R){
            int m,t,p,r;
            cin>>m>>t>>p>>r;
            t--; p--; 
            if(r==0){
                solve[t][p]=true;
                tim[t]+=m;   
            }
            else WA[t][p]++;
        }
    
        vector<int> solve_count(T,0);
        rep(i,0,T){
            rep(j,0,PP){
                if(solve[i][j]){
                    solve_count[i]++;
                    tim[i]+=WA[i][j]*20;   
                }
            }
        }
        vector<pair<int,pair<int,int>>> rank;
        rep(i,0,T){
            rank.pb(MP(-solve_count[i],MP(tim[i],-(i+1))));
        }
        Sort(rank);
        
        /*rep(i,0,T){
            cout<<rank[i].fi<<" "<<rank[i].se.fi<<" "<<-rank[i].se.se<<endl;
        }*/
    
        rep(i,0,T){
            if(i)cout<<",";
            cout<<-rank[i].se.se;
            while(i+1<T && rank[i].fi==rank[i+1].fi && rank[i].se.fi==rank[i+1].se.fi){
                i++;
                cout<<"=";
                cout<<-rank[i].se.se;
            }
        }
        cout<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3136
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <utility>

using namespace std;

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

int _rank[128];
char trump;
string card[4][13];

int main(){
    int i;
    for(i=2;i<10;i++) _rank['0'+i] = i;
    for(char c:"TJQKA") _rank[c]=i++;
    while(cin >> trump && trump!='#'){
        rep(i,4)rep(j,13)cin>>card[i][j];
        int next = 0;
        int score[] = {0,0};
        rep(i,13){
            int winner = 0, max = 0;
            bool used = false;
            char led = card[next][i][1];
            rep(j,4){
                int r = _rank[card[j][i][0]];
                char s = card[j][i][1];
                if(used){
                    if(s == trump && r > max){
                        tie(max,winner) = tie(r,j);
                    }
                }else{
                    if(s == trump){
                        used = 1;
                        tie(max,winner) = tie(r,j);
                    } else if(s == led && r > max){
                        tie(max,winner) = tie(r,j);
                    }
                }
            }
            next = winner;
            score[winner%2]++;
        }

        if(score[0] > score[1]) cout<<"NS "<<score[0]-6<<endl;
        else cout<<"EW "<<score[1]-6<<endl;
    }
}

Measured memory_bytes: 1188
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>	
#include <utility>
#include <cinttypes>
#include <string>
#include <iostream>
#include <cmath>
using namespace std;

int main(){
    int a,b;
    scanf("%02d%02d",&a,&b);
    if (1<=a && a<= 12 && 1<=b && b <= 12){
        printf("AMBIGUOUS\n");
    } else if (1<=a && a<= 12) {
        printf("MMYY\n");
    } else if (1<=b && b<= 12) {
        printf("YYMM\n");
    } else {
        printf("NA\n");
    }
}

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

using lli = long long int;
using Vint = std::vector<int>;
using Vlli = std::vector<lli>;
using Wint = std::vector<Vint>;
using Wlli = std::vector<Vlli>;
using Vbool = std::vector<bool>;
using pii = std::pair<int, int>;
using pll = std::pair<lli, lli>;
template <class T>
using Vec = std::vector<T>;

constexpr int MOD = 1e9 + 7;
constexpr int INFi = 2e9 + 1;
constexpr lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {std::make_pair(1, 0), std::make_pair(-1, 0), std::make_pair(0, 1), std::make_pair(0, -1)};
constexpr char BR = '\n';

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(ele, vec) for(auto &(ele) : (vec))
#define vREPcopy(ele, vec) for(auto (ele) : (vec))
#define SORT(A) std::sort((A).begin(), (A).end())
// 座標圧縮 (for vector) : ソートしてから使うのが一般的 ; SORT(A) => COORDINATE_COMPRESSION(A)
#define COORDINATE_COMPRESSION(A) (A).erase(unique((A).begin(),(A).end()),(A).end())



template <class T> inline int argmin(std::vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(std::vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}
inline int BitI(int k){return 1 << k;}
inline lli BitL(int k){return 1L << k;}
inline int toInt(string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline int toInt(const string s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res = "";
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;}
  std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





int main(void){
  int n, cnt_minus = 0;; scanf("%d", &n);
  Vint A(n); REP(i, n){
    scanf("%d", &A[i]);
    if(A[i] < 0){
      A[i] *= (-1);
      cnt_minus++;
    }
  }
  lli res = 0;
  if(cnt_minus % 2 == 0){
    REP(i, n) res += A[i];
    printf("%lld\n", res);
  }
  else{
    int mn = INFi;
    REP(i, n){
      res += A[i];
      if(A[i] < mn) mn = A[i];
    }
    printf("%lld\n", res - 2 * mn);
  }
  return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#define N 1000001
#define R register
#define ll long long

const int UP=15000000;
int home[N],next[N],to[N],cnt,vis[N];
ll sum[N],dis[N];
int q[20340001],l,r,tm,m,n,tot[N];

inline int read(){
	R int f=1,x=0;
	char ch;
	do{
		ch=getchar();
		if(ch=='-') f=-1;
	}while(!isdigit(ch));
	do{
		x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	}while(isdigit(ch));
	return f*x;
}

void add(int a,int b,ll c){
	next[++cnt]=home[a],home[a]=cnt,to[cnt]=b,sum[cnt]=c;
}

void bfs(int S){
	l=1,r=1,q[1]=S;
	vis[S]=1;
	while(l<=r){
		R int u=q[l++];
		for(R int i=home[u];i;i=next[i]){
			R int v=to[i];
			if(!vis[v]){
				dis[v]=dis[u]+sum[i];
				vis[v]=1;
				q[++r]=v;
			}
		}
	}
}

int main(){
	scanf("%d%d",&n,&m);
	for(R int i=1;i<=m;i++){
		R int a=read(),b=read(),c=read();
		//d[b] - d[a] >= c
		add(a,b,c);
		//d[b] - d[a] <= c
		//d[a] - d[b] >= -c
		add(b,a,-c);
	}
	for(R int i=1;i<=n;i++)
		if(!vis[i]) bfs(i);
	for(R int i=1;i<=n;i++)
		for(R int j=home[i];j;j=next[j]){
			R int v=to[j];
			R ll ds=sum[j];
			if(dis[v]!=dis[i]+ds)
				return puts("No"),0;
		}
	puts("Yes");
}

Measured memory_bytes: 24832
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 1000000

char hash_ary[MAX][14];

int ary_size = MAX;


int h1( int key );
int h2( int key );
int h( int key, int cnt );
int insert( char * str );
void init( );
int my_getchar( char ch );
int getkey( char * str );
int find( char * str );

int h1( int key ) {
	return key % ary_size;
}

int h2( int key ) {
	return 1 + key % ( ary_size -1 );
}

int h( int key, int cnt ) {
	return ( h1(key) + cnt * h2( key) ) % ary_size;
}

int insert( char * str ) {
	long long key, i = 0, my_h;	

	key = getkey( str );
	while ( 1 ) {
		my_h = h( key, i );
		if ( strcmp( hash_ary[my_h], str ) == 0 ) {
			return 1;
		} else if ( hash_ary[my_h][0] == -1 ) {
			strcpy( hash_ary[my_h], str );
			return 0;
		}
		i++;
	}
	return 0;
}

int find( char * str ) {
	long long key = getkey( str );
	long long i = 0;
	long long cnt = 0;
	long long my_h = 0;

	while ( 1 ) {
		my_h = h( key, cnt );
		if ( strcmp( str, hash_ary[my_h] ) == 0 ) {
			return 1;
		} else if ( hash_ary[my_h][0] == -1 || cnt > MAX ) {
			return 0;
		}
		cnt++;
	}
	return 0;
}

void init( ) {
	for ( int i = 0 ; i < MAX ; i++ ) {
		hash_ary[i][0] = -1;
	}
}

int my_getchar( char ch ) {
	if ( ch == 'A' ) {
		return 1;
	} else if ( ch == 'C' ) {
		return 2;
	} else if ( ch == 'G') {
		return 3;
	} else if ( ch == 'T' ) {
		return 4;
	}
	return 0;
}

int getkey( char * str ) {
	long long sum = 0;
	long long p = 1;
	for ( int i = 0 ; i < strlen( str ) ; i++ ) {
		sum += p * my_getchar( str[i] );
		p *= 5;
	}
	return sum;
}


int main(){
	int i = 0;
	int n = 0; 
	char command[10] = { 0 };
	char data[14] = { 0 };

	init();
	scanf( "%d", &n );
	while ( i < n ) {
		scanf( " %s %s", command, data );
		if ( command[0] == 'i' ) {
			insert( data );				
		} else if ( command[0] == 'f' ) {
			if ( find( data ) ) {
				fprintf( stdout, "yes\n" );
			} else {
				fprintf( stdout, "no\n" );
			}
		}
		i++;
	}
	return 0;
}



Measured memory_bytes: 15376
n = int(input())
a = list(map(int,input().split()))
a.append(10**10)
counter = 1
ans = 0
for i in range(n):
    if a[i] == a[i+1]:
        counter += 1
    else:
        if counter %2 == 0 and counter != 1 :
            ans += counter/2
        elif counter %2 != 0 and counter != 1:
            ans += int(counter/2)
        counter = 1
print(int(ans))

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

using namespace std;

typedef long long ll;

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

	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;

	string ans;
	ans.push_back(s1[0] - 'a' + 'A');
	ans.push_back(s2[0] - 'a' + 'A');
	ans.push_back(s3[0] - 'a' + 'A');

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define F first
#define S second
using namespace std;
int mod=1e15;


int32_t main() {
    int T;
    T=1;
    //cin>>T;
    while(T--){
        string a,b;
        cin>>a>>b;
        int n=a.size(), m=b.size();
        int dp[n+1][m+1];
        memset(dp,0,sizeof(dp));
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if(a[i-1]==b[j-1]){
                    dp[i][j]=dp[i-1][j-1]+1;
                }
                else{
                    dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
                }
            }
        }
        
        string ans="";
        int x=n, y=m;
        while(x>=1 && y>=1){
            if(a[x-1]==b[y-1]){
                ans+=a[x-1];
                x--, y--;
            }
            else if(dp[x-1][y]>dp[x][y-1]){
                x--;
            }
            else{
                y--;
            }
        }
        reverse(ans.begin(), ans.end());
        cout<<ans;
        cout<<'\n';
    }
	return 0;
}

Measured memory_bytes: 70656
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var k = int.Parse(line[1]);
        if (k % 2 == 0)
        {
            var k2 = k / 2;
            var a0 = 0;
            var a1 = 0;
            for (int i = 1; i <= n; i++)
            {
                if (i % k == 0) a0++;
                else if (i % k == k2) a1++;
            }
            var w1 = (long)Math.Pow(a0, 3) + (long)Math.Pow(a1, 3);
            Console.WriteLine(w1);
        }
        else
        {
            var a0 = 0;
            for (int i = 1; i <= n; i++)
                if (i % k == 0) a0++;
            var w2 = (long)Math.Pow(a0, 3);
            Console.WriteLine(w2);
        }
    }
}


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

ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    ll LCM = (C*D)/gcd(C, D);
    ll toA, toB;
    
    A--;
    toA = A/C + A/D - A/LCM;
    toA = A - toA;
    toB = B/C + B/D - B/LCM;
    toB = B - toB;
    
    cout << toB - toA << "\n";
    return 0;
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,d;
	int box[11][11];
	int i,j,k;
	int m;
	int sum1;
	double sum2;
	int cnt;
	int x;
	cin>>n>>d;
	for(i=0;i<n;i++){
		for(j=0;j<d;j++){
			cin>>m;
			box[i][j]=m;
		}
	}
	cnt=0;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(i<j){
				sum2=0.0;
				sum1=0;
				for(k=0;k<d;k++){
					sum2+=(double)pow(box[i][k]-box[j][k],2);
					sum1+=       pow(box[i][k]-box[j][k],2);
				}
				sum2=sqrt(sum2);
				sum1=sqrt(sum1);
				x=sum2*1000-sum1*1000;
				if(x==0)	cnt++;
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}

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

using namespace std;

/*
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/
typedef long long ll ;
const ll mk = 250055;
const ll logn  = 29;
const ll mod = 1e9 + 7;

#define endl             "\n"
#define IOS              ios::sync_with_stdio(0); cin.tie(0);
#define fi               first
#define se               second
#define pii              pair<ll,ll>
#define mp               make_pair
#define pq               priority_queue<int, std::vector<int>, std::greater<int> >
#define rep(i, n)        for(int i = 0 ; i < n ; i++)
#define pb               push_back

string s, t;
int q;
  
/*

the remainder of it for 3 never change 
111 -> 0
222 -> 0
1   -> 22
2   -> 11

*/
int main() {
  IOS;
  
  cin >> s >> t >> q;
  
  vector<int> x(s.size() + 1), y(t.size() + 1);
  
  for (int i = 1; i <= s.size(); i++) {
    x[i] = s[i -1] -'A' +1;
    x[i] +=x[i-1]; 
  }
  for (int i = 1; i <= t.size(); i++) {
    y[i] = t[i -1]-'A' +1;
    y[i] += y[i-1];
  }
  
  for (int i = 0; i < q; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if ((x[b] - x[a -1]) % 3 == (y[d]-y[c -1]) % 3) cout << "YES" << endl;
    else cout << "NO" <<endl;
  }
}

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
p = [I() for _ in range(n)]
s = sum(p)
ans = s - max(p)//2
print(ans)

Measured memory_bytes: 38384
import std.stdio;
import std.range;
import std.array;
import std.algorithm;
import std.string;
import std.conv;

void main(){
    auto ab = readln().chomp().split().map!(to!int);
    auto a = ab[0];
    auto b = ab[1];
    solve(a, b).writeln();
}

int solve(int a, int b){
    return max(a+b, a-b, a*b);
}

Measured memory_bytes: 256
N,K=map(int,input().split())
A=list(map(int,input().split()))
ANS=[-1 for i in range(N)]
a=0
count=1
for i in range(N):
  a=A[a]-1
  if ANS[a]==-1:
    ANS[a]=count
    count+=1
  else:
    roop=count-ANS[a]
    break
if K<count:
  ans=ANS.index(K)+1
else:
  b=(K-ANS[a])%roop+ANS[a]
  ans=ANS.index(b)+1
print(ans)

Measured memory_bytes: 32320
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

h,w = get_nums_l()

lines = sys.stdin.readlines()

xtable = [ [-1]*w for _ in range(h) ]
ytable = [ [-1]*w for _ in range(h) ]
yoko = [0] * (h*w)
tate = [0] * (h*w)

cur = 0
for y in range(h):
    for x in range(w):

        c = lines[y][x]

        if c == ".":
            yoko[cur] += 1
            xtable[y][x] = cur

            if x == (w-1):
                cur += 1
        else:
            cur += 1

cur = 0
for x in range(w):
    for y in range(h):

        c = lines[y][x]

        if c == ".":
            tate[cur] += 1
            ytable[y][x] = cur

            if y == (h-1):
                cur += 1
        else:
            cur += 1
        
ans = 0
for y in range(h):
    for x in range(w):
        if xtable[y][x] != -1:
            v = yoko[xtable[y][x]] + tate[ytable[y][x]] - 1
            
            if ans < v:
                ans = v

print(ans)

Measured memory_bytes: 178312
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <bits/stdc++.h>
using namespace std;

int main(){
    string s; cin >> s;
    int s_size = s.size();
    vector<int> count(26);
    string ans = "yes";
    
    for(int i = 0; i < s_size; i++){
        count.at(s.at(i) - 'a')++;
    }
    

    for(int i = 0; i < 26; i++){
        if(count.at(i) > 1){
            ans = "no";
        }
    }
   
    cout << ans << endl;
}



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

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static long Solve(long A, long B, long C, long K)
        {
            return (K % 2 == 0) ? A - B : B - A;
        }
        static void Main(string[] args)
        {
            var V = ReadLongs();
            Console.WriteLine(Solve(V[0], V[1], V[2], V[3]));
        }
    }
}


Measured memory_bytes: 13140
// AOJ Volume 0 Problem 0058

#include <stdio.h>

int main(void)
{
	double xa, ya, xb, yb, xc, yc, xd, yd;
	double a1, a2;
	
	while (scanf("%lf%lf%lf%lf%lf%lf%lf%lf",
					&xa, &ya, &xb, &yb, &xc, &yc, &xd, &yd) == 8){
		if (xa == xb){
			if (yc == yd){
				printf("YES\n");
			}
			else {
				printf("NO\n");
			}
		}
		else if (xc == xd){
			if (ya == yb){
				printf("YES\n");
			}
			else {
				printf("NO\n");
			}
		}
		else {
			a1 = (ya - yb) / (xa - xb);
			a2 = (yc - yd) / (xc - xd);
			
			if (a1 * a2 == -1){
				printf("YES\n");
			}
			else {
				printf("NO\n");
			}
		}
	}
	
	return (0);
}

	

Measured memory_bytes: 0
N, K = map(int, input().split())
A = list(map(lambda x:int(x)-1, input().split()))
db = [[0]*N for _ in range(100)]
db[0] = A[:]
for i in range(1,100):
  for j in range(N):
    db[i][j] = db[i-1][db[i-1][j]]
ans = p = 0
while K>0:
  if K%2==1:
    ans = db[p][ans]
  p += 1
  K >>= 1
print(ans+1)


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

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] ;
int n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	int cnt = 0 ;
	for(int i = 1 ; i <= n ; ++i)
	{
		int x ;
		cin>>x ;
		if((i & 1))
			cnt += (x & 1) ;
	}
	return cout<<cnt<<"\n" , 0 ;
}		

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

int main(){
    int d,t,s;
    cin >> d >> t >> s;
    if (d <= t*s){
        cout << "Yes" << '\n';
    }else{
        cout << "No" << '\n';
    }
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  string s1, s2; std::cin >> s1 >> s2;
  int len1 = s1.size(), len2 = s2.size();
  vvi dp(len1+1, vi(len2+1, inf));
  rep(i, len1+1) dp[i][0] = i;
  rep(i, len2+1) dp[0][i] = i;
  rrep(i, len1) rrep(j, len2) {
    if (i == 0 && j == 0) continue;
    if (i-1 >= 0) chmin(dp[i][j], dp[i-1][j] + 1);
    if (j-1 >= 0) chmin(dp[i][j], dp[i][j-1] + 1);
    if (i-1 >= 0 && j-1 >= 0) chmin(dp[i][j], dp[i-1][j-1] + (s1[i-1] != s2[j-1] ? 1 : 0));
  }
  std::cout << dp[len1][len2] << "\n";
}



Measured memory_bytes: 6688
n,m=map(int,input().split())
a=[input() for i in range(n)]
b=[input() for i in range(m)]
#print(a,b)
ans=0
cnt=0
for i in range(n-m+1):
  for j in range(n-m+1):
    cnt=0
    for k in range(m):
      if b[k]!=a[i+k][j:j+m]:
        break
      cnt+=1
      #print(a[i+k][j:j+m],b[k],a[i+k][j:j+m]==b[k])
    if cnt==m:
      ans+=1
    if ans>0:
      break
  if ans>0:
    break
  
print("Yes" if ans>0 else "No")








Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func isPalindrome(s string) bool {
	l := len(s)
	if l < 1 {
		return false
	}

	left := 0
	right := l - 1
	for left < right {
		if s[left] != s[right] {
			return false
		}
		left++
		right--
	}

	return true
}

func main() {

	var s string
	fmt.Scan(&s)

	s1 := s[0 : len(s)/2]
	s2 := s[len(s)/2+1:]
	if isPalindrome(s) && isPalindrome(s1) && isPalindrome(s2) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 512
#include <iostream>
#include <map>
#include <set>

using namespace std;

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

    map<char, set<int>>sm, tm;

    for(int i=0; i<s.length(); i++){
        sm[s[i]].insert(i);
    }
    for(int i=0; i<t.length(); i++){
        tm[t[i]].insert(i);
    }
    for(auto q : tm){
        if(sm[q.first].empty()){
            cout << -1 << endl;
            return 0;
        }
    }

    int prev = -1;
    long cnt = 1;
    for(int i=0; i<t.length(); i++){
        auto pos = sm[t[i]].lower_bound(prev+1);
        if(pos == sm[t[i]].end()){
            prev = *(sm[t[i]].begin());
            cnt++;
        }else{
            prev = *pos;
        }
    }

    long ans = s.length()*(cnt-1) + prev+1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 14464
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<ll>;

#define nextline() (std::cerr << "\n")
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
#define diup(a, b) (a % b == 0 ? a / b : a / b + 1)
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }

/*****/

void Main()
{
	char a, b;
	cin >> a >> b;
	if (a == 'H')
	{
		cout << b;
	}
	else
	{
		cout << (b == 'H' ? 'D' : 'H');
	}
}

/*****/

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

	std::cout << std::fixed << std::setprecision(10);


	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/


	Main();

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		int k = sc.nextInt();
		while(k>0){
		 if(a%2==0){
			 a = a/2;
			 b += a;
		 }
		 else{
			 a--;
			 a = a/2;
			 b += a;
		 }
		 k--;
		 if(k>0)
		 { if(b%2==0){
			 b = b/2;
			 a+=b;
		 }
		 else
			 {
			 b--;
			 b = b/2;
			 a+=b;
			 }
		 k--;}
		}
		System.out.println(a+" "+b);
	}

}


Measured memory_bytes: 22740
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>

using namespace std;
typedef long long int ll;

int h,w,a[10][10],vs=0;
string s;
bool r=false;

int main(){
    scanf("%d %d",&h,&w);
    for(int i=0;i<h;i++){
        cin>>s;
        for(int j=0;j<w;j++){
            a[i][j]=s[j]=='#';
            vs+=a[i][j];
        }
    }
    vector<vector<int>> st={{0,0,0}},stm;
    while(st.size()!=0){
        stm={};
        for(vector<int> itr:st){
            if(itr[2]==vs-1)r=true;
            //printf("%d\n",itr[2]);
            if(itr[0]<h){
                if(a[itr[0]+1][itr[1]])stm.push_back({itr[0]+1,itr[1],itr[2]+1});
            }
            if(itr[1]<w){
                if(a[itr[0]][itr[1]+1])stm.push_back({itr[0],itr[1]+1,itr[2]+1});
            }
        }
        if(r)break;
        st=stm;
    }
    printf(r ? "Possible\n":"Impossible\n");
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
//typedef long long ll;
typedef double ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=51001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
void outvi(vi v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
void outvvi(vvi v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
int main(){
    ll n,ans=inf;cin>>n;
    vvi mi(3,vi(2)),ma(3,vi(2));
    rep(i,3){
        rep(j,2){
            mi[i][j]=inf;
            ma[i][j]=-inf;
        }
    }
    rep(i,n){
        vi x(2);rep(i,2)cin>>x[i];
        vi xs(2);
        char c;cin>>c;
        if(c=='L'){
            xs[0]=-1;xs[1]=0;
        }
        if(c=='R'){
            xs[0]=1;xs[1]=0;
        }
        if(c=='D'){
            xs[0]=0;xs[1]=-1;
        }
        if(c=='U'){
            xs[0]=0;xs[1]=1;
        }
        rep(i,2){
            chmin(mi[xs[i]+1][i],x[i]);
            chmax(ma[xs[i]+1][i],x[i]);
        }
    }
    vi v;v.pb(0);v.pb(inf);
    rep(i,2){
        v.pb((mi[0][i]-mi[2][i])/2);
        v.pb(mi[1][i]-mi[2][i]);
        v.pb(mi[0][i]-mi[1][i]);
        v.pb((ma[0][i]-ma[2][i])/2);
        v.pb(ma[1][i]-ma[2][i]);
        v.pb(ma[0][i]-ma[1][i]);
    }
    for(ll k:v){
        if(k<0)continue;
        ll l=inf,r=-inf,d=inf,u=-inf;
        rep(i,3)chmin(l,mi[i][0]+k*(i-1));
        rep(i,3)chmax(r,ma[i][0]+k*(i-1));
        rep(i,3)chmin(d,mi[i][1]+k*(i-1));
        rep(i,3)chmax(u,ma[i][1]+k*(i-1));
        if((r-l)*(u-d)>=0)chmin(ans,(r-l)*(u-d));
    }
    cout<<fixed<<setprecision(15);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 1000

int main(){
  char c[N+1];
  int i;

  while(scanf("%s",&c) != EOF){
    for(i = 0 ; i < N ; i++){
      if(c[i] <= 'Z' && c[i] >='D')
	c[i] -= 3;
      else if(c[i] <= 'C' && c[i] >= 'A')
	c[i] += 23;
    }
    printf("%s\n",c);
  }

  return 0;

}

Measured memory_bytes: 524