akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define eps (1e-10)
#define equals(a,b) (fabs((a)-(b))<eps)
struct point{
    double x,y;
    point(){}
    point(double x,double y):x(x),y(y){}
    point operator + (point &p){return point(x+p.x,y+p.y);}
    point operator - (point &p){return point(x-p.x,y-p.y);}
    point operator * (double k){return point(x*k,y*k);}
    point operator / (double k){return point(x/k,y/k);}

    double norm(){return x*x+y*y;}
    double abs(){return sqrt(norm());}

    bool operator < (const point &p){
        return x!=p.x?x<p.x:y<p.y;
    }
    bool operator == (const point &p){
        return fabs(x-p.x)<eps&&fabs(y-p.y)<eps;
    }
};
//内积
double dot(point a,point b)
{
    return a.x*b.x+a.y*b.y;
}
//外积
double cross(point a,point b){
    return a.x*b.y-a.y*b.x;
}

int isorthogonal(point a,point a1,point b,point b1)
{
    return fabs(dot(a1-a,b1-b)-0.0)<eps;
}

int isparallel(point a,point a1,point b,point b1)
{
    return fabs(cross(a1-a,b1-b)-0.0)<eps;
}

int main()
{
    int n;
    point a,a1,b,b1;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a.x>>a.y>>a1.x>>a1.y>>b.x>>b.y>>b1.x>>b1.y;
        if(isorthogonal(a,a1,b,b1)){
            printf("1\n");
        }else if(isparallel(a,a1,b,b1)){
            printf("2\n");
        }else{
            printf("0\n");
        }
    }
    return 0;
}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ld long double
#define mem(a,b) memset(a,b,sizeof(a) )
#define M 4000010
#define md 1000000007

ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}
/*inline ll add(ll a,ll b){return (a+b)%md;}
inline ll mul(ll a,ll b){return (a*b)%md;}
ll f[M],iv[M];
ll C(ll n,ll r){return mul(f[n],mul(iv[r],iv[n-r]));}
void prep_fac(){
    f[0]=1;
    rep(i,1,M)f[i]=mul(i,f[i-1]);
    iv[M-1]=power(f[M-1],md-2,md);
    for(ll i=M-2;i>=0;--i)iv[i]=mul(i+1,iv[i+1]);
}*/



int main()
{
	IOS;
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll ans=max(a*c,b*d);
	ans=max(ans,max(a*d,b*c));
	cout<<ans;
}



Measured memory_bytes: 3572
#ifndef bhartiya
    // #pragma GCC optimize("Ofast")
    // #pragma GCC optimize("unroll-loops")
    // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
// not that imp
typedef pair<pll, ll> plll;
typedef vector<ll> vl;
typedef vector<pll> vll;

#ifdef bhartiya
#define endl '\n'
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


#define pb push_back
#define bitc  __builtin_popcountl
#define mp make_pair
#define ff first
#define ss second

#define swap(a,b) {a=a^b;b=a^b;a=a^b;}
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define inf 200000000000000ll
// #define inf 10000000000ll
#define mod 1000000007ll
// #define mod 998244353ll
#define eps 1e-7

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

const ll maxn = 212345;
// ll n;
ll a[maxn];
ll b[maxn];
ll c[maxn];
ll dp[maxn][3];


int main() 
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.precision(10);
    // cin.exceptions(cin.failbit);
    #ifdef bhartiya
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin>>t;
    while(t--){
        ll n;
        cin>>n;
        rep(i,n){
            cin>>a[i]>>b[i]>>c[i];
        }
        dp[0][0] = a[0];
        dp[0][1] = b[0];
        dp[0][2] = c[0];
        fr(i,1,n-1){
            dp[i][0] = a[i] + max(dp[i-1][1],dp[i-1][2]);
            dp[i][1] = b[i] + max(dp[i-1][0],dp[i-1][2]);
            dp[i][2] = c[i] + max(dp[i-1][1],dp[i-1][0]);
        }
        cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
    }
}

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

#define rint register int
inline int read(){int r;int s=0,c;for(;!isdigit(c=getchar());s=c);for(r=c^48;isdigit(c=getchar());(r*=10)+=c^48);return s^45?r:-r;}
string S; set<string> Q;
int main()
{
	cin >> S; for(rint r = 0, l; r < S.length(); r++) for(l = max(0,r-5); l <= r; Q.insert(S.substr(l,r-l+1)), l++);
	for(rint i = 1, K = read(); i < K; Q.erase(Q.begin()), i++);  cout << *Q.begin() << endl; return 0;
}

Measured memory_bytes: 2176
#include<stdio.h>
#include<string.h>
int main(){
  while(1){
    int a, b, n, dp[20][20], i, j;
    scanf("%d%d%d", &a, &b, &n);
    if(a == 0 && b == 0) return 0;
    memset(dp, 0, sizeof(dp));
    for(i = 0;i < n;i++){
      int x, y;
      scanf("%d%d", &x, &y);
      dp[x][y] = -1;
    }
    dp[1][1] = 1;
    for(i = 1;i <= a;i++){
      for(j = 1;j <= b;j++){
	if(dp[i][j] == -1)dp[i][j] = 0;
	else dp[i][j]+= dp[i - 1][j] + dp[i][j - 1];
      }
    }
    printf("%d\n", dp[a][b]);
  }
}

Measured memory_bytes: 600
N,P=map(int,input().split())
A=list(map(int,input().split()))

ODD=0
EVE=0

for i in range(N):
    if A[i]%2==1:
        ODD+=1
    else:
        EVE+=1
        
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**15+7 #出力の制限
N = 10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

if P==1:
    O=0
    E=1
    for i in range(EVE):
        E+=cmb(EVE,i,mod)
        E%=(10**15+7)
        
    for i in range((ODD+1)//2):
        O+=cmb(ODD,1+2*i,mod)
        
        
    ans=(E*O)%(10**15+7)
    print(ans)
else:
    O=0
    E=1
    for i in range(EVE):
        E+=cmb(EVE,i,mod)
        E%=(10**15+7)
        
    for i in range((ODD)//2+1):
        O+=cmb(ODD,2*i,mod)
        #print(O)
        
    ans=(E*O)%(10**15+7)
    print(ans)

Measured memory_bytes: 11192
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main {

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String num1 = br.readLine();

		StringBuilder bf = new StringBuilder();

		int[] num = new int[3];

		for(int i=0; i<Integer.parseInt(num1);i++){


		String[] str = br.readLine().split(" ");

		for(int k=0; k<3; k++){
			num[k] = Integer.parseInt(str[k]);
		}

		Arrays.sort(num);


		if(num[2]*num[2] == (num[1]*num[1])+(num[0]*num[0])){
			bf.append("YES").append("\n");
		}else {
			bf.append("NO").append("\n");

		}

		}

		System.out.print(bf);


	}

}

Measured memory_bytes: 25744
#include <iostream>
#include <stdio.h>
#include <numeric>
#include <algorithm>
using namespace std;
int main(){
    int n,m,l;
    cin>>n>>m>>l;
    long long a[n][m],b[m][l],c[100][100]={};
    for(int i=0;i<n;++i){
        for(int j=0;j<m;++j){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<m;++i){
        for(int j=0;j<l;++j){
            cin>>b[i][j];
        }
    }
    for(int i=0;i<n;++i){
        for(int j=0;j<l;++j){
            for(int k=0;k<m;++k){
                c[i][j]+=a[i][k]*b[k][j];
            }
        }
    }
    for(int i=0;i<n;++i){
        for(int j=0;j<l;++j){
            cout<<c[i][j];
            if(j!=l-1){
                cout<<" ";
            }
        }
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 3312
#include <bits/stdc++.h>
using namespace std ;
inline long long Readin() {
	long long K = 0 , F = 1 ; char C = ' ' ;
	while( C < '0' or C > '9' ) F = C == '-' ? -1 : 1 , C = getchar() ;
	while( C <= '9' and C >= '0' ) K = ( K << 1 ) + ( K << 3 ) + C - '0' , C = getchar() ;
	return F * K ;
}
int N , M ;
char S[1005][1005] ;
int Map[1005][1005] ;
bool Vis[1005][1005] ;
const int Mx[6] = { 0 , 1 , 0 , 0 , -1 , 0 } ;
const int My[6] = { 0 , 0 , 1 , -1 , 0 , 0 } ;
long long Ans[5] , Tot ;
void Dfs( int X , int Y ) {
	if( X < 1 or Y < 1 or X > N or Y > M or Vis[X][Y] ) return ;
	Vis[X][Y] = true ;
	++Ans[Map[X][Y]] ;
	for(int i = 1 ; i <= 4 ; ++i ) if( S[X][Y] != S[X+Mx[i]][Y+My[i]] ) Dfs( X+Mx[i] , Y+My[i] ) ;
}
inline char Getchar() {
	register char C = getchar() ;
	while( C != '.' and C != '#' ) C = getchar() ;
	return C ;
}
int main() {
	N = Readin() ;
	M = Readin() ;
	for(register int i = 0 ; ++i <= N ; )
		for(register int j = 0 ; ++j <= M ; )
			S[i][j] = Getchar() , Map[i][j] = ( S[i][j] == '#' ) ;
	for(register int i = 0 ; ++i <= N ; )
		for(register int j = 0 ; ++j <= M ; )
			if( not Vis[i][j] ) {
				Ans[0] = Ans[1] = 0 ;
				Dfs( i , j ) ;
				Tot += Ans[0] * Ans[1] ;
			}
	return not printf( "%lld\n" , Tot ) ;
}

Measured memory_bytes: 11648
mod reader {
    use std;

    macro_rules! read_line((  ) => {
                           {
                           let mut input = String :: new (  ) ; std :: io ::
                           stdin (  ) . read_line ( & mut input ) . unwrap (
                           ) ; input } } ;);

    pub fn read_to_vec<T: std::str::FromStr>() -> Vec<T> {
        read_line!().split_whitespace().map(|e|
                                                e.parse().ok().unwrap()).collect()
    }

    pub fn read_and_parse<T: std::str::FromStr>() -> T {
        read_line!().trim().parse().ok().unwrap()
    }
}
use reader::*;

fn main() {
    let n: usize = read_and_parse();
    let a: Vec<i64> = read_to_vec();

    let mut last_not_flipped = a[0] + a[1];
    let mut last_flipped = -(a[0] + a[1]);

    for i in 1..n - 1 {
        let (pos, neg) = (last_not_flipped, last_flipped);

        last_not_flipped = std::cmp::max(pos + a[i + 1], neg + a[i + 1]);
        last_flipped =
            std::cmp::max(pos - 2 * a[i] - a[i + 1],
                          neg + 2 * a[i] - a[i + 1]);
    }

    println!("{}" , std :: cmp :: max ( last_not_flipped , last_flipped ));
}


Measured memory_bytes: 8444
w = input()
d = {}
for ww in w:
    if ww not in d.keys():
        d[ww] = 1
    else:
        d[ww] += 1

def solve(d):
    for key, item in d.items():
        if item%2 == 1:
            print('No')
            return
        
    print('Yes')
    return

solve(d)



Measured memory_bytes: 2940
#include <iostream>
#include <list>
using namespace std;

using ll = long long;

#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_(i,0,(n))
#define rrep(i,n) rfor_(i,0,(n))

using li = list<int>;

li a;

int main(){
	cin.tie(0);
	
	auto cur = a.end();
	
	int q;
	cin>>q;
	rep(i, q) {
		int c, x;
		cin>>c;
		if(c==0) {
			cin>>x;
			cur = a.insert(cur, x);
		}else if(c==1) {
			cin>>x;
			rep(i, (x<0?-x:x)) {
				if(x>0)cur++;
				else cur--;
			}
		}else {
			cur = a.erase(cur);
		}
	}
	
	 for(auto itr = a.begin(); itr != a.end(); itr++) {
	 	cout<<*itr<<endl;
    }

	return 0;
}



Measured memory_bytes: 18640
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main(void) {
    vector<int> t = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;

    cout << t[k - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
while True:
    n = int(input())
    if n == 0:
        break
    s = []
    for _ in range(n):
        s.append(list(map(int, input().split())))
    m = int(input())
    p = [10, 10]
    if p in s:
        s.remove(p)
    for _ in range(m):
        d, l = input().split()
        l = int(l)
        for a in range(l):
            if d == 'E':
                p[0] = p[0] + 1
            elif d == 'W':
                p[0] = p[0] - 1
            elif d == 'N':
                p[1] = p[1] + 1
            else:
                p[1] = p[1] - 1
            if p in s:
                s.remove(p)
    if s == []:
        print('Yes')
    else:
        print('No')

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> C(3, 0);
  for (int i = 0; i < N; i++) {
    int a, cnt = 0;
    cin >> a;
    while (a % 2 == 0) {
      cnt++;
      a /= 2;
      if (cnt == 2) break;
    }
    C[cnt]++;
  }
  if ((C[0] <= C[2]) || (C[1] == 0 && C[0] <= C[2] + 1))
    cout << "Yes" << '\n';
  else
    cout << "No" << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int k = sc.nextInt();
        int n = sc.nextInt();
        int[] param = new int[n];
        int[] param1 = new int[n];
        
        for(int i=0 ; i<n ; i++){
            param[i] = sc.nextInt();
        }
        
        for(int i=0 ; i<n-1 ; i++){
            param1[i] = param[i+1]-param[i]; 
        }
        
        param1[n-1] = (k-param[n-1]) + (param[0]);
        
        
       Arrays.sort(param1);
       
       int dis = k-param1[n-1];
       
       System.out.println(dis);
      }
    }

Measured memory_bytes: 89708
$S=<>;
chop$S;
($c)=grep$S!~$_,a..z;
print$S=~/zyxwvutsrqponmlkjihgfedcba/?-1:$c?$S.$c:~~reverse((reverse$S)=~s/^a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?(.)/($c)=grep$_ gt$1,split'',$&;$c/er),$/


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

template<class T>T gcd(T a, T b){if(a<b){a^=b;b^=a;a^=b;}return b?gcd(b,a%b):a;}
template<class T>T lcm(T a, T b){return a*b/gcd(a,b);}

ll A,B;

int main(){
    cin>>A>>B;

    ll g=gcd(A,B);
    ll sg=sqrt(g);
    ll div=1;
    ll ans=1;
    bool b;
    while(div<sg){
        div++;
        if(g%div==0){
            ans++;
            while(g%div==0) g/=div;
        }
    }
    if(g!=1) ans++;

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
signed main(){
	int x,n,p[105];
	int i;
	scanf("%d %d", &x,&n);
	for(i=0;i<n;i++){
		scanf("%d", &p[i]);
	}
	int flag[105]={};
	int ans=0;
	for(i=0;i<n;i++){
		flag[p[i]]=1;
	}
	for(i=1;i<=101;i++){
		if(flag[i]==0){
			int abs1,abs2;
			abs1=x-ans;
			abs2=x-i;
			if(abs1<0) abs1=-abs1;
			if(abs2<0) abs2=-abs2;
			if(abs1>abs2) ans=i;
		}
	}
	printf("%d\n", ans);
	return (0);
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
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; }

using Lint=long long;
using Graph=vector<vector<int>>;

const int INF=1e9;

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

    int N; cin>>N;
    Graph G(N);
    for(int i=0;i<N;i++){
        int u,k; cin>>u>>k;
        u--;
        while(k--){
            int v; cin>>v;
            v--;
            G[u].push_back(v);
        }
    }

    vector<int> dist(N,INF);
    dist[0]=0;
    queue<int> Q;
    Q.push(0);
    while(!Q.empty()){
        int v=Q.front(); Q.pop();
        for(int u:G[v]){
            if(chmin(dist[u],dist[v]+1)) Q.push(u);
        }
    }
    for(int i=0;i<N;i++){
        cout<<i+1<<' '<<(dist[i]==INF? -1:dist[i])<<endl;
    }
    return 0;
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, W, v[100], w[100], dp[10001];
  fill_n( dp, 10001, -1);

  cin >> N >> W;
  for(int i = 0; i < N; i++){
    cin >> v[i] >> w[i];
  }
  dp[0] = 0;
  for(int i = 0; i < N; i++){
    for(int j = W; j >= w[i]; j--){
      dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
    }
  }
  cout << *max_element(dp, dp + W + 1) << endl;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int par[100010];
int depth[100010];
void init(int n){
  for(int i=0;i<=n;i++){
      par[i]=i;
      depth[i]=0;
  }
}
int root(int x){
  return par[x]==x?x:par[x]=root(par[x]);
}
bool same(int x,int y){
  return root(x)==root(y);
}
void unite(int x,int y){
  x=root(x);
  y=root(y);
  if(x==y)return;
  if(depth[x]<depth[y]){
      par[x]=y;
  }else{
      par[y]=x;
      if(depth[x]==depth[y])depth[x]++;
  }
}
int main(){
    ll n,m;cin>>n>>m;
    init(n);
    rep(i,m){
        ll x,y,z;cin>>x>>y>>z;
        unite(x,y);
    }
    vector<bool>used(n+1);
    ll cnt=0;
    rep(i,n){
        if(!used[root(i+1)]){
            cnt++;
            used[root(i+1)]=1;
        }
    }
    cout<<cnt<<endl;
}

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

int main(void){
  int r, g, b;
  int value;
  cin >> r >> g >> b;
  value = 100 * r + 10 * g + b;
  if(value % 4 == 0)
    cout << "YES" << "\n";
  else
    cout << "NO" << "\n";
  return 0;
}


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

void z_algorithm(string s, vector<int> &prefix) {
    int j = 0;
    for (int i = 1; i < s.size(); i++) {
        if (i + prefix[i - j] < j + prefix[j]) {
            prefix[i] = prefix[i - j];
        } else {
            int k = max(0, j + prefix[j] - i);
            while (i + k < s.size() && s[k] == s[i + k]) k++;
            prefix[i] = k;
            j = i;
        }
    }
    prefix[0] = s.size();
}

int main() {
    int n, ans = 0;
    string s;
    cin >> n >> s;
    for (int i = 0; i < n; i++) {
        string s1 = s.substr(i, s.size() - i);
        vector<int> v(s1.size());
        z_algorithm(s1, v);
        for (int i = 0; i < s1.size(); i++) {
            if (v[i] <= i) ans = max(ans, v[i]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last){
    reverse(middle, last);
    return next_permutation(first,last);
}
 
int main(){
    while(1){
        int n;
        cin >> n;
        if(n==0) break;

        vector<string> str(n);
        vector<char> clist;
        vector<bool> nonzero(26, false);
        for(int i=0; i<n; i++){
            cin >> str[i];
            for(int j=0; j<(int)str[i].length(); j++){
                clist.push_back(str[i][j]);
            }
            if((int)str[i].length()!=1){
                nonzero[str[i][0]-'A'] = true;
            }
        }
        sort(clist.begin(), clist.end());
        clist.erase(unique(clist.begin(), clist.end()), clist.end());
         
        int numc = clist.size();
        vector<long long int> num(numc, 0);
        for(int d=0; d<numc; d++){
            for(int i=0; i<n; i++){
                long long int sub = 0;
                for(int j=0; j<(int)str[i].length(); j++){
                    sub *= 10;
                    if(str[i][j] == clist[d]) sub+=1;
                }
                if(i==n-1) num[d] -= sub;
                else num[d] += sub;
            }
        }
        
        vector<int> perm(10);
        for(int i=0; i<10; i++) perm[i] = i;
        int ans = 0;
        do{
            long long int sum=0;
            for(int i=0; i<numc; i++){
                sum += perm[i]*num[i];
                if(perm[i]==0 && nonzero[clist[i]-'A']){
                    sum = -1;
                    break;
                }
            }
            if(sum==0) ans++;              
        }while(next_partial_permutation(perm.begin(), perm.begin()+numc, perm.end()));
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3148
print("?za")
use=["za"]
can=[chr(i) for i in range(98, 98+24)]
can.extend(["a"+chr(i) for i in range(97, 97+26)])
while 1:
    s=input()
    if s[0]!="a" or s in use:
        print("!OUT")
        break
    use.append(s)
    if s=="a":
        p="aa"
    elif s=="aa":
        p="a"
    else:
        p=s[-1]+can.pop(0)+"a"
    print("?"+p)
    use.append(p)


Measured memory_bytes: 5568
def getFreequencyStr(arr):
    datas = [0] * 101
    arr2 = [0] * len(arr)
    # 数を数える
    for i in range(0,len(arr)):
        datas[arr[i]] += 1
    # 頻出を配列にする
    for i in range(0,len(arr)):
        arr2[i] = datas[arr[i]]
    return arr2
        
while(1):
    n = int(input())
    changeNum = 0
    if n == 0:
        break
    arr = list(int(x) for x in input().split())
    while(1):
        arr2 = getFreequencyStr(arr)
        changeNum += 1
        if arr == arr2:
            break
        arr = arr2
    
    print(changeNum - 1)
    for i in range(0,len(arr)):
        if i :
            print(" ",end="")
        print(arr[i],end="")
    print()


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


int check(string str)
{

    int n = str.length();
    int digitSum = 0;
    for (int i=0; i<n; i++)
        digitSum += (str[i]-'0');


    return (digitSum % 9 == 0);
}
int main()
{

    string str;
    cin>>str;
    check(str)?  cout << "Yes" : cout << "No ";
    return 0;
    return 0;
}


Measured memory_bytes: 3804
s,_,*q=open(0)
a='%s'
p=1
for q in q:
  try:
    q,f,c=q.split()
    if(f<'2')^p:a+=c
    else:a=c+a
  except:p^=1
print((a%s[:-1])[::p or-1])

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define cinv(n,vec) VL (vec)(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t make_tuple
#define eb emplace_back
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (ll)(a.size())
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define cont const auto
#define fi first
#define se second
#define V vector
#define P pair
#define T tuple
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
#define PQ priority_queue
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<pair<ll,ll>> VP;
typedef tuple<ll,ll,ll> T3;
typedef tuple<ll,ll,ll,ll> T4;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  str s;
  cin>>s;
  int ans=INF;
  for(char c='a';c<='z';++c){
    int res=0;
    str t=s;
    int cnt=0;
    while(1){
      bool flg=true;
      for(auto i:t)if(i!=c)flg=false;
      if(flg)break;
      cnt++;
      if(cnt>110){
        res=INF;break;
      }
      res++;
      str p=t;
      rep(i,SZ(p)-2){
        if(p[i+1]==c)p[i]=c;
      }
      p.erase(p.end()-1);
      t=p;
    }
    chmin(ans,res);
  }
  out(ans);
  
  
  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)

long mod(long a){
    long long c=a%998244353;
    if(c>=0)return c;
    return c+998244353;
}
using namespace std;

//typedef long long ll;
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

//配列のSIZEは問題ごとに定義する必要がある。
const int SIZE=300'010;
long long inv[SIZE+1];//各iの逆元を格納する配列。
long long kai[SIZE+1];//i!のmodを格納する配列。
long long invkai[SIZE+1];//各i!の逆元を格納する配列。
const int MOD=998244353;
void invinit(){//上の配列を初期化する関数。
    inv[1]=1;
    for(int i=2;i<=SIZE;i++){
        inv[i] = MOD - ((MOD/i)*inv[MOD%i])%MOD;
    }
    
    kai[0]=invkai[0]=1;
    for(int i=1;i<=SIZE;i++){
        kai[i]=(kai[i-1]*i)%MOD;
        invkai[i]=(invkai[i-1]*inv[i])%MOD;
    }
}

long long comb(long long a, long long b){
    if(b<0 || a<b){
        return 0;
    }
    return mod(kai[a]*mod(invkai[b]*invkai[a-b]));
}

int main(){
    invinit();
    long long n,a,b,k;
    cin>>n>>a>>b>>k;
    long long y;
    long long ans=0;
    for(long long x=0;x<=n;x++){
      if(k-a*x<0)break;
      if((k-a*x)%b!=0)continue;
      y = (k-a*x)/b;
      ans += mod(comb(n,x)*comb(n,y));
      ans = mod(ans);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 7296
/*
  
  Author: Arnab Sinha
	
  ███████╗██╗  ██╗███████╗██████╗         ██╗      ██████╗  ██████╗██╗  ██╗███████╗██████╗  █████╗  █████╗ 
  ██╔════╝██║  ██║██╔════╝██╔══██╗        ██║     ██╔═══██╗██╔════╝██║ ██╔╝██╔════╝██╔══██╗██╔══██╗██╔══██╗
  ███████╗███████║█████╗  ██████╔╝        ██║     ██║   ██║██║     █████╔╝ █████╗  ██║  ██║╚██████║╚██████║
  ╚════ █║██╔══██║██╔══╝  ██╔══██╗        ██║     ██║   ██║██║     ██╔═██╗ ██╔══╝  ██║  ██║ ╚═══██║ ╚═══██║
  ███████║██║  ██║███████╗██║  ██║███████╗███████╗╚██████╔╝╚██████╗██║  ██╗███████╗██████╔╝ █████╔╝ █████╔╝
  ╚══════╝╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝╚══════╝╚══════╝ ╚═════╝  ╚═════╝╚═╝  ╚═╝╚══════╝╚═════╝  ╚════╝  ╚════╝                                                                                                        
*/

#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define li long long int
#define ld long long double
#define all(v) v.begin(),v.end()
#define sort(a) sort(all(a))
#define rev(a) reverse(all(a))
#define pb push_back
#define INF 1e18+10
#define MINF -1e18-10
#define rep(i,a,b) for(li i=a;i<b;i++)
#define vli vector<li>
#define MAXN 1e5+10
const li mod = 1e9+7;
using namespace std;

li power(li a, li b) { a%=mod; li ret = 1; while(b){ if(b&1) ret*=a; a*=a;; if(ret>=mod) ret%=mod; if(a>=mod) a%=mod; b>>=1; } return ret; }

template <class T> void read(T& x){
	cin>>x;
}

template <class T, class... U> void read(T& x, U&... u){
	read(x);
	read(u...);
}

template <class A> void read(vector<A>& v){
	for(auto &it:v)
		read(it);
}

template <class A> void print(A x){
	cout<<x;
}

template <class A> void printl(A x){
	cout<<x<<endl;
}

template <class A> void print(vector<A>& v)
{
	for(auto &it:v){
		print(it);
		cout<<' ';
	}
	cout<<'\n';
}

void solve()
{
	string s,t;
	cin>>s>>t;

	li ans = INF;
	for(li i=0;i<s.size() - t.size() + 1;i++)
	{
		string temp = s.substr(i,t.size());
		li count = 0;

		// cout<<temp<<endl;

		for(int j=0;j<t.size();j++)
		{
			if(temp[j]!=t[j])
				count++;
		}
		ans = min(ans,count);
	}

	cout<<ans<<endl;
}

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

	IOS;

	solve();
	return 0;
}

Measured memory_bytes: 3576
Sx,Sy,Tx,Ty = map(int,input().split())
Dx,Dy = abs(Tx-Sx),abs(Ty-Sy)
S = ""

moveX,moveY = [],[]
if Dx > 0:
    moveX = ["R","L","R","L"] 
elif Dx < 0:
    moveX = ["L","R","L","R"]
if Dy > 0:
    moveY = ["U","D","U","D"]
elif Dy < 0:
    moveY = ["D","U","D","U"]

S += moveY[0]*Dy + moveX[0]*Dx
S += moveY[1]*Dy + moveX[1]*Dx
S += moveX[1] + moveY[0]*(Dy+1) + moveX[0]*(Dx+1) + moveY[1]
S += moveX[0] + moveY[1]*(Dy+1) + moveX[1]*(Dx+1) + moveY[0]

print(S)


Measured memory_bytes: 3064
import java.util.*;
 
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
 
		if (A == B){
			 System.out.println(C);	
		}else if (A == C){
			 System.out.println(B);
		}else if (B == C){
			System.out.println(A);
		}
	}
	
}
	    
		
		

Measured memory_bytes: 23252
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pl;

#define FST first
#define SND second

const int MAX_N = 200000;                  // 10^5
// const int MAX_N = 100000;                  // 10^5
// const int MAX_N = 1000000000;              // 10^9
// const ll  MAX_N = 1000000000000000000;     // 10^18
// const int BASE  = 1000000000 + 7;          // 10^9 + 7
// const int INFI  = 1000000000 + 7;          // 10^9 + 7
// const ll INFL  = 1000000000000000000 + 7; // 10^18 + 7

ll MOD(ll x, ll y) { return (x % y + y) % y; }
ll DIV(ll x, ll y) { return (x - MOD(x, y)) / y; }

ll N, D[MAX_N], M, T[MAX_N];

bool check() {
  int j = 0;
  for (int i = 0; i < M; i++) {
    while(j < N && D[j] < T[i]) j++;
    if (j >= N) return false;
    if (D[j] != T[i]) return false;
    j++;
  }
  return true;
}

void solve() {
  sort(D, D + N);
  sort(T, T + M);
  if (check()) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> D[i];
  cin >> M;
  for (int i = 0; i < M; i++) cin >> T[i];

  solve();

  return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    
    int n,k;
    cin >> n >> k;
    ll a[n];
    inrep(n,a);

    ll dp[n] = {};
    rep(i,0,n)dp[i]= linf;
    dp[0] = 0;
    rep(i,0,n-1){
	rep(j,1,k+1){
	    if(i+j >= n)break;
	    dp[i+j] = min(dp[i+j],dp[i] + abs(a[i+j] - a[i])); 
	}
    }
     
    P(dp[n-1]);
    return  0;
}


Measured memory_bytes: 1792
#include<iostream>
#include <vector> 
#include <string>
using namespace std;
 
int main()
{
    int N;
    cin>>N;
    vector<string>v;
    vector<int>num(4,0);
    string n[4]={"AC","WA","TLE","RE"};
    vector<string>m(n,n+4);
    string k;

    for(int i=0;i<N;i++){
    		cin>>k;
    		v.push_back(k);
	}
	
	for(int i=0;i<N;i++){
		for(int j=0;j<4;j++){
			if(v[i]==m[j]){
				num[j]++;
			}
		}
	}

	for(int i=0;i<4;i++){
		cout<<m[i]<<" "<<"x"<<" "<<num[i]<<endl;
	}
    return 0;
}

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

typedef long long ll;
#define PI 3.1415926535897932384626433
#define mod 1000000007

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

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

int main(){
    ll a, b;
    cin >> a >> b;
    if(a > 0 && b > 0){
        cout << "Positive" << endl;
    }else if(a < 0 && b < 0){
        if((b - a + 1) % 2 == 0){
            cout << "Positive" << endl;
        }else{
            cout << "Negative" << endl;
        }
    }else if(a <= 0 && b >= 0){
        cout << "Zero" << endl;
    }
    return 0;
}


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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

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

  int n, x;
  cin >> n >> x;
  VI m(n);
  REP(i, n) cin >> m[i];

  int sum = 0, mi = INF;
  REP(i, n) sum += m[i], chmin(mi, m[i]);

  cout << n + (x-sum)/mi << endl;

  return 0;
}


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

int main(void) {
  int n;
  cin >> n;
  set<int> st;
  for (int i=0;i<n;i++) {
    int a;
    cin >> a;
	if (st.find(a) == st.end())
      st.insert(a);
    else
      st.erase(a);
  }
  cout << st.size() << endl;
  return 0; 
}

Measured memory_bytes: 4864
n = int(input())
a = list(input())
b = []
cou1=0

for i in a:
    if i=="(":
        cou1 += 1
        b.append("(")
    else:
        b.append(")")
        if cou1==0:
            b.insert(0,"(")
            continue
        cou1 -= 1

for _ in range(cou1):
    b.append(")")

print(*b,sep='')

Measured memory_bytes: 3064
#define Z 100
M[Z][Z][2],l=100000;main(w,h,i,j){
	M[0][0][0]=M[0][0][1]=M[1][1][0]=M[1][1][1]=1;
	for(j=1;j<Z;j++)M[0][j][0]=0,M[0][j][1]=M[0][j-1][1];
	for(i=1;i<Z;i++)for(M[i][0][0]=M[i-1][0][0],M[i][0][1]=0,j=1;j<Z;j++)M[i][j][0]=(M[i-1][j][0]+M[i-1][j-1][1])%l,M[i][j][1]=(M[i][j-1][1]+M[i-1][j-1][0])%l;
	for(;scanf("%d%d",&w,&h),w;)printf("%d\n",(M[h-1][w-1][0]+M[h-1][w-1][1])%l);exit(0);
}

Measured memory_bytes: 676
import math
a,b,x=map(int,input().split())
Q=x/a
if Q>a*b/2:
    s=a*b-Q
    Ans=math.degrees(math.atan2(2*s,a**2))
else:
    Ans=90-math.degrees(math.atan2(2*Q,b**2))
print(Ans)

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

int main(){
  string S, T;
  cin >> S >> T;
  for(int i = 0; i < S.size(); i++){
    if(S[0] == T[i]){
      bool flag = 1;
      for(int j = 1; j < S.size(); j++){
      	 if(S[j] != T[(i+j) % S.size()]){
           flag = 0;
           break;
         }
      }
      if(flag){
        cout << "Yes\n";
        return 0;
      }
    }
  }
  cout << "No\n";
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

//Sliceconvtof ...
func Sliceconvtof() []float64 {
	strs := strings.Split(sc.Text(), " ")

	var flts []float64
	var x int

	for _, s := range strs {
		x, _ = strconv.Atoi(s)
		xf := float64(x)
		flts = append(flts, xf)
	}

	return flts
}

//ThirdRoot .
func ThirdRoot(f float64) float64 {
	xn := f / 2
	var dmt float64

	for {
		dmt = math.Pow(xn, 3) - f
		if math.Abs(dmt) < 0.00001*f {
			break
		}

		xn = xn - (dmt / (3 * math.Pow(xn, 2)))
	}

	return xn
}

func main() {

	for sc.Scan() {
		i := Sliceconvtof()
		if i[0] == -1.0 {
			break
		}
		fmt.Printf("%6f\n", ThirdRoot(i[0]))
	}

}



Measured memory_bytes: 1124
class UF():
  def __init__(self, N):
    self.par = [-1] * N

  def union(self, x, y):
    p1,p2 = self.find(x), self.find(y)
    if p1 == p2: return

    if self.par[p1] > self.par[p2]:
      p1,p2 = p2,p1
    self.par[p1] += self.par[p2]
    self.par[p2] = p1

  def find(self, x):
    if self.par[x] < 0:
      return x
    else:
      self.par[x] = self.find(self.par[x])
      return self.par[x]

  def size(self, x):
    return -self.par[self.find(x)]

  def same(self, x, y):
    return self.find(x) == self.find(y)

N,M,K = map(int,input().split())
uf = UF(N)
adj = [ [] for _ in range(N)]
for _ in range(M):
  u,v = map(int,input().split())
  u -= 1
  v -= 1
  adj[u].append(v)
  adj[v].append(u)
  uf.union(u,v)

res = []
for n in range(N):
  res.append(uf.size(n) - 1 - len(adj[n]))

for _ in range(K):
  u,v = map(int,input().split())
  u -= 1
  v -= 1
  if uf.same(u,v):
    res[u] -= 1
    res[v] -= 1

print(" ".join(map(str, res)))


Measured memory_bytes: 114848
// Header {{{
#include <bits/stdc++.h>

using namespace std;
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;
typedef unsigned long long int ull;
typedef long long int ll;
#define rep(i,a,b) for (ll i=(a); i<(b); i++)
typedef pair<ll,ll> PLL;
// }}}

bool isset(ull bit, ll index){
    return (bit>>index)&1;
}

signed main() {
    ll n, ans=-1e10;
    cin>>n;
    vector<vector<ll>> f(n, vector<ll>(10));
    vector<vector<ll>> p(n, vector<ll>(11));
    rep(i,0,n) rep(j,0,10) cin>>f[i][j];
    rep(i,0,n) rep(j,0,11) cin>>p[i][j];

    for (ull bit=1; bit<(1ull<<10); bit++){
        ll t = 0;
        rep(i,0,n){
            ll c = 0;
            rep(j,0,10){
                if (f[i][j]==1 && isset(bit,j))
                    c++;
            }
            t += p[i][c];
        }
        ans=max(ans,t);
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

#define INF 999999999

int main(){
	int ans, N, sum, now;
	while(1){
		cin >> N;
		if(!N)break;
		ans = 0;
		now = 1;
		sum = 1;
		while((N-sum)>0){
			if((N-sum)%(now+1)==0){
				ans++;
			}
			now ++;
			sum += now;
		}
		
		cout << ans << endl;
		now++;
	}
	return 0;
}

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

int main(void){
    int n;
    int ac=0, wa=0, tle=0, re=0;

    scanf("%d",&n);

    char s[4];
    for(int i = 1; i<=n; i++){
        scanf("%s",s);
        if(strcmp(s,"AC")==0)   ac++;
        if(strcmp(s,"WA")==0)   wa++;
        if(strcmp(s,"TLE")==0)  tle++;
        if(strcmp(s,"RE")==0)   re++;

    }

    printf("AC x %d\n"  ,ac);
    printf("WA x %d\n"  ,wa);
    printf("TLE x %d\n" ,tle);
    printf("RE x %d\n"  ,re);
    return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fr first
#define sc second
const int mod = 1e9+7;
const int N = 1e6+6;
ll a[N];
int main(){
    int n;
    ll k ;
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>a[i];
    ll lst = 0;
    ll trt = 0;
    for(ll j=50;j>=0;j--){
        int cnt0 = 0;
        int cnt1 = 0;
        for(int i=1;i<=n;i++){
            if(a[i]&(1ll<<j))cnt1++;
            else cnt0++;
        }
        int idk = 0;
        if(k&(1ll<<j))idk =1 ;
        if(idk==1){
            if(cnt0==cnt1){
                lst = 1;
            }
            else if(cnt0>cnt1){
               trt+=(1ll<<j);
            }
            else if(cnt1>cnt0){
                lst = 1;
            }
        }
        else{
            if(cnt0==cnt1){
                /// do nothing
            }
            else if(cnt0>cnt1){
                if(lst){
                    trt+=(1ll<<j);
                }
            }
            else if(cnt1>cnt0){
                /// do nothing
            }

        }
    }
    ll ans = 0;
    for(int i=1;i<=n;i++){
        ans+=(trt^a[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4332
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
using namespace std;
#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)


int main() {
	int n;
	while(cin >> n, n) {
		vector<vector<int> > ms(n, vector<int>());
		for(int i = 0; i < n; i++) {
			int m;
			cin >> m;
			for(int j = 0; j < m; j++) {
				int mss;
				cin >> mss;
				mss--;
				ms[i].push_back(mss);
			}
		}
		int k;
		cin >> k;
		vector<int> led(n);
		for(int i = 0; i < k; i++) {
			int j;
			cin >> j;
			j--;
			led[j] = 1;
		}
		bool summable = true;
		// fill one
		int kouho = -1;
		for(int i = 0; i < n; i++) {
			int count = 0;
			for(int j = 0; j < ms[i].size(); j++) {
				if(led[ms[i][j]]) count++;
			}
			if (count == k) {
				if (kouho != -1) {
					cout << -1 << endl;
					goto end_loop;
				}
				kouho = i;
			}
		}
		// fill some
		for(int i = 0; i < n; i++) {
			if (i == kouho) continue;
			int count = 0;
			for(int j = 0; j < ms[i].size(); j++) {
				if(led[ms[i][j]]) count++;
			}
			if (count == ms[i].size()) {
				for(int j = 0; j < ms[i].size(); j++) {
					led[ms[i][j]] = 2;
					//cout << "sum" << ms[i][j] << endl;
				}
			}
		}
		
		for(int i = 0; i < n; i++) {
			if (led[i] == 1) {
				summable = false;
				break;
			}
		}
		if (summable || kouho == -1) {
			cout << -1 << endl;
		}
		else {
			cout << kouho+1 << endl;
		}
		
		end_loop: {}
	}
	
	return 0;
}

Measured memory_bytes: 952
n, d, a = map(int, input().split())
m = [tuple(map(int, input().split())) for _ in range(n)]

m.sort()

x = [s[0] for s in m]
h = [s[1] for s in m]

dh = [0] * (n+1)
dh[0] = h[0]
for i in range(n-1):
    dh[i+1] = h[i+1] - h[i]

import bisect
ans = 0
health = 0
for i in range(n):
    health += dh[i]
    if health > 0:
        count = (health + a - 1) // a
        damage = count * a
        ans += count
        health -= damage
        r = bisect.bisect_right(x, x[i] + 2 * d)
        dh[r] += damage
print(ans)

Measured memory_bytes: 92272
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end(),greater<ll>())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000000000000003 //1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  string s;
  cin>>s;

  rep(i,s.length()){
    if(i%2==0) cout<<s[i];
  }

}

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


Measured memory_bytes: 592
// Aizu Vol-1 0184: Tsuruga Castle
// 2017.8.2

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

char *gets(char *);
char buf[100], *p;

int getInt(void)
{
	int n = 0;
	//	while (isspace(*p)) p++;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0');
	return n;
}

void putInt(int n)
{
	char s[22], *p;

	if (n) {
		p = s + 20, *p = 0;
		while (n) *--p = (n % 10) + '0', n /= 10;
		puts(p);
	} else putchar('0'), putchar('\n');
}

int cnt[15];

int main()
{
	int i, n, k;

	while (1) {
		gets(p = buf);
		if (!(n = getInt())) break;
		memset(cnt, 0, sizeof(cnt));
		i = n;
		while (i--) {
			gets(p = buf);
			k = *p++ - '0';
			if (*p >= '0') {
				if (*++p < '0') cnt[k]++;
			} else cnt[0]++;
		}
		for (i = k = 0; i < 6; i++) putInt(cnt[i]), k += cnt[i];
		putInt(n - k);
	}
	return 0;
}

Measured memory_bytes: 524
# C

A, B, H, M = list(map(int, input().split()))

import math
A_x = A * math.cos(2 * math.pi * (H + M / 60.) / 12.)
A_y = A * math.sin(2 * math.pi * (H + M / 60.) / 12.)
B_x = B * math.cos(2 * math.pi * M / 60.)
B_y = B * math.sin(2 * math.pi * M / 60.)

print('{:.15f}'.format(math.sqrt((A_x - B_x) ** 2 + (A_y - B_y) ** 2)))

Measured memory_bytes: 9516
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner in=new Scanner(System.in);
		int flag=0;
		int n=in.nextInt();
		int m=in.nextInt();
		int c1=77,c2=77,c3=77;
		if(m==0&&n==1) System.out.print(0);
		else if(m==0&&n==2) System.out.print(10);
		else if(m==0&&n==3) System.out.print(100);
		else if(n==1)
		{
			for(int i=0;i<m;i++)
			{
				int s=in.nextInt();
				int c=in.nextInt();
				if((s==1&&c1==77)||(s==1&&c==c1)) c1=c;
				else flag=1;
			}
			if(flag==1) System.out.print(-1);
			else System.out.print(c1);
		}
		else
		{
			for(int i=0;i<m;i++)
			{
				int s=in.nextInt();
				int c=in.nextInt();
				if((s==1&&c1==77)||(s==1&&c==c1))
				{
					if(c==0) flag=1;
					else c1=c;
				}
				else if((s==2&&c2==77)||(s==2&&c==c2)) c2=c;
				else if((s==3&&c3==77)||(s==3&&c==c3)) c3=c;
				else flag=1;
			}
			if(flag==1) System.out.print(-1);
			else
			{
				for(int i=1;i<=n;i++)
			{
					if(i==1&&c1!=77) System.out.print(c1);
					if(i==1&&c1==77) System.out.print(1);
					if(i==2&&c2!=77) System.out.print(c2);
					if(i==2&&c2==77) System.out.print(0);
					if(i==3&&c3!=77) System.out.print(c3);
					if(i==3&&c3==77) System.out.print(0);
			    }
			}
		}
        in.close();
	}
}

Measured memory_bytes: 23892