akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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 (b<a) { a=b; return 1; } return 0; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};



int main() {
    while(1){
    ll n,w,d;
    cin>>n>>w>>d;
    if(n==0 && w==0&& d==0) break;
    vector<Pi> now;
    now.pb(mp(w,d));
    rep(i,n){
        ll p,s;
        cin>>p>>s;
        p--;
        ll W = now[p].first;
        ll D = now[p].second;
        //cout <<W<<" "<<D<<endl;
        s %= (W+D);
        Pi new1,new2;
        if(s<W){
            if(s<W-s){
                new1=mp(s,D);
                new2=mp(W-s,D);
            }else{
                new1=mp(W-s,D);
                new2=mp(s,D);
            }
        }else{
            s-=W;
            if(s<D-s){
                new1=mp(W,s);
                new2=mp(W,D-s);
            }else{
                new1=mp(W,D-s);
                new2=mp(W,s);
            }
        }
        vector<Pi> tmp;
        rep(i,now.size()){
            if(i!=p){
                tmp.pb(now[i]);
            }
        }
        tmp.pb(new1);
        tmp.pb(new2);
        now = tmp;
        //cout<<new2.first<<" "<<new2.second<<endl;
        //cout<<now[now.size()-1].first<<" "<<now[now.size()-1].second<<" "<<tmp.size()<<endl;

    

    }
    vector<ll> ans;
    rep(i,now.size()){
        ans.pb(now[i].first*now[i].second);

    }
    sort(all(ans));
    rep(i,ans.size()){
        //cout << now[i].first<<" "<<now[i].second<<endl;
        cout << ans[i];
        if(i == now.size()-1){
            cout<<endl;
        }else{
            cout<<" ";
        }
    }
    }

    
    return 0;
    

}



Measured memory_bytes: 3036
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&a!=b))
        printf("Yes");
    else
        printf("No");
}


Measured memory_bytes: 256
N,K = map(int,input().split(' '))
A = list(map(int,input().split(' ')))

# 戻ってくるまでのリスト
R=[]
Rs=set()
Now=1
cnt=0
for i in range(N):
    if Now in Rs:
        Start=R.index(Now)
        End = cnt
        break
    else:
        R.append(Now)
        Rs.add(Now)
        Now=A[Now-1]
        cnt+=1

if K < End:
    ans=R[K]
else:
    key=Start+(K-Start)%(End-Start)
    ans=R[key]

print(ans)
#print(Start,End)
#print(R)
#Start+K(End-Start)

Measured memory_bytes: 130592
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j,k;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int[] x = new int[n];
		int[] y = new int[n];
		for (i = 0; i < n; i++) {
			x[i] = parseInt(sc.next());
			y[i] = parseInt(sc.next());
		}
		sc.close();
		int fa = 1;
		for (i = 1; i < n; i++) {
			fa *= i;
		}
		double ll = 0.0d;
		for (i = 0; i < n-1; i++) {
			for (j = i+1; j < n; j++) {
				ll += sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])) * fa *2;
			}
		}
		out.println(ll/(fa*n));
	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, m;
    ll k;
    cin >> n >> m >> k;
    vector<ll> a(n+2, 0), b(m+2, 0);
    for(int i=1;i<=n;++i) {
        cin >> a[i];
        a[i] += a[i-1];
    }
    a[n+1] = LINF;
    for(int i=1;i<=m;++i) {
        cin >> b[i];
        b[i] += b[i-1];
    }
    b[m+1] = LINF;

    int ans = 0;
    for(int i=0;i<=n;++i) {
        if(a[i] > k) break;
        int j = upper_bound(b.begin(), b.end(), k-a[i]) - b.begin() - 1;
        ans = max(i+j, ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6364
#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 n;
  cin >> n;
  int ren = 0;
  rep(i,n) {
    int a, b;
    cin >> a >> b;
    if (a == b) ++ren;
    else ren = 0;
    if (ren == 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

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

ll mod=1e9+7;

ll mpow(ll a,ll b) {
    ll c=1;
    while (b) {
        if (b&1) c=c*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return c;
}

ll C(ll a,ll b) {
    ll f=1;
    for (ll i=a;i>a-b;i--)
        f=f*i%mod;
    ll f2=1;
    for (ll i=2;i<=b;i++)
        f2=f2*i%mod;
    return f*mpow(f2,mod-2)%mod;
}

int main() {
    ll n,a,b;cin>>n>>a>>b;
    cout<<((mpow(2,n)-1-C(n,a)-C(n,b))%mod+mod)%mod<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
from collections import defaultdict
d_blue = defaultdict(int)
strs = set()
for i in range(N):
    s = input()
    d_blue[s] += 1
    strs.add(s)
M = int(input())
d_red = defaultdict(int)
for j in range(M):
    t = input()
    d_red[t] += 1
    strs.add(t)

ans = 0
for s in strs:
    b = d_blue[s]
    t = d_red[s]
    ans = max(ans,b-t)

print(ans)

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

int main()
{

    vector<int>arr[3];
    for(int i=0; i<3; i++)
        {
            arr[i].resize(3);
            for(auto &j:arr[i])
                cin>>j;
        }
    int n,i,j;
    cin>>n;
    map<int,bool> m,temp;
    for(i=0; i<n; i++)
        cin>>j,m[j]=1;
    temp=m;
    bool flag=0;

    for(i=0; i<3; i++)
        {
            flag=0;
            for(j=0; j<3; j++)
                {
                    if(m[arr[i][j]])
                            continue;
                            flag=1;
                            break;

                }
        if(flag==0)
                {
                    cout<<"Yes"<<endl;
                    return 0;
                }

        }

    for(i=0; i<3; i++)
        {
            flag=0;
            for(j=0; j<3; j++)
                {
                    if(m[arr[j][i]])
                            continue;
                            flag=1;
                            break;

                }
        if(flag==0)
                {
                    cout<<"Yes"<<endl;
                    return 0;
                }

        }
    if(m[arr[0][0]] && m[arr[1][1]] && m[arr[2][2]])
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    else if (m[arr[0][2]] && m[arr[1][1]] && m[arr[2][0]])
        {
            cout<<"Yes"<<endl;
            return 0;
        }

    cout<<"No"<<endl;


    return 0;
}


Measured memory_bytes: 256
#define first f
#define second s
#define ll long long
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#include <bits/stdc++.h>
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
const int maxn=1e5+5;
const int MOD=1e9+7;
const double PI=acos(-1);
const double e=2.718281828459;

char s[maxn];
deque<char>q;

int main()
{
    int p;
    scanf("%s",s+1);
    scanf("%d",&p);
    for(int i=1;s[i];i++){
        q.pb(s[i]);
    }
    int t,f;
    char c;
    int flag=0;
    while(p--){
        scanf("%d",&t);
        if(t==1){
            flag^=1;
        }
        else{
            scanf("%d %c ",&f,&c);
            if(f==1){
                if(flag==0){q.pf(c);}
                else{q.pb(c);}
            }
            else{
                if(flag==0){q.pb(c);}
                else{q.pf(c);}
            }
        }
    }
    if(flag==0){
    for(int i=0;i<q.size();i++){
        printf("%c",q[i]);
    }}
    else{
            for(int i=q.size()-1;i>=0;i--){
        printf("%c",q[i]);}
    }
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
using namespace std;
static const int MAX = 200000;

int main()
{
  int n[2];
  cin >> n[0] >> n[1];
  if(n[0] == n[1])cout << "Yes" <<endl;
  else cout << "No"<<endl;
  return 0;
}


Measured memory_bytes: 384
n,i,a[100009];main(){
	scanf("%d",&n);for(i=0;i<n;i++)scanf("%d",&a[i]);
	for(i=n-1;i>=1;i--){
    	if(a[i]<a[i-1])a[i-1]--;
    	if(a[i]<a[i-1]){printf("No");return 0;}
	}
	printf("Yes");
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {
    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;

    for (int i = 0; i < ty-sy; i++)
        cout << 'U';
    for (int i = 0; i < tx-sx; i++)
        cout << 'R';
    for (int i = 0; i < ty-sy; i++)
        cout << 'D';
    for (int i = 0; i < tx-sx; i++)
        cout << 'L';
    cout << 'L';
    for (int i = 0; i <= ty-sy; i++)
        cout << 'U';
    for (int i = 0; i <= tx-sx; i++)
        cout << 'R';
    cout << 'D';
    cout << 'R';
    for (int i = 0; i <= ty-sy; i++)
        cout << 'D';
    for (int i = 0; i <= tx-sx; i++)
        cout << 'L';
    cout << 'U' << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    while (A >= B) {
        B *= 2;
        K -= 1;
    }
    while (B >= C) {
        C *= 2;
        K -= 1;
    }
    if (K >= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(void){
    int n;
    long long a[10001]={0};
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
        
    }
    
    long long min =1000000,max=-1000000,sum=0;

    for (int i=0;i<n;i++){
    if(a[i]<min){
        min = a[i];
    }
    
   if(a[i]>max){
       max= a[i];
   }
        sum = sum+a[i];
    }

    
    cout << min << " " << max << " " << sum << endl;
}



Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define so sizeof
#define cf cout.flush()
int main()
{
    ios;
    ll n ;
    cin >> n ;
    vector<ll > v;
    ll t= 2* n ;
    while(t--)
    {
        ll x;
         cin >> x;
         v.push_back(x);
    }
    sort(v.begin() , v.end() );
    vector<ll > vv;
    for(ll i = 0 ; i < v.size()-1 ; ++i){
        vv.push_back(min(v[i], v[i+1]));
        ++i;
    }
    ll foo = accumulate(vv.begin() , vv.end() , 0);
    cout<<foo<<endl;
    cf;
    return 0 ;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdio.h>
#include<vector>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>

using namespace std;

long long int A, a, n, m, y, s;
string str_1, str_2, str_3;
long long int x[2][30000];


int gcd(int m, int n){
	while (true) {
		if (m%n == 0)return n;
		m %= n;
		if (n%m == 0)return m;
		n %= m;
	}
}


int main() {
	cin >> n >> m;
	cin >> str_1 >> str_2;

	for (int i = 0; i < gcd(n, m); i++) {
		if (str_1[i*n / gcd(n, m)] != str_2[i*m / gcd(n, m)]) {
			cout << -1 << '\n';
			return 0;
		}
	}
	cout << n * m / gcd(n, m) << '\n';
	return 0;
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            calc();
        }

        static void calc()
        {
            long N = long.Parse(Console.ReadLine());
            Dictionary<long, bool> A = new Dictionary<long, bool>();
            for (int i = 0; i < N; i++)
            {
                long tmpA = long.Parse(Console.ReadLine());
                if (A.ContainsKey(tmpA))
                {
                    A[tmpA] = !A[tmpA];
                }
                else
                {
                    A.Add(tmpA, true);
                }
                
            }

            long ans = A.Count(b => b.Value == true);
            Console.WriteLine(ans);
            Console.ReadLine();


        
        }
    }
}


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

int minCost(int arr[],int n,int k)
{
  int dp[n+1];
  
  dp[1]=0;
  int minJump=INT_MAX;
  for(int i=2;i<=n;i++)
  {
   for(int j=1;j<=k;j++)
   {
     if(j>=i)
       break;
     minJump=min(minJump,abs(arr[i]-arr[i-j])+dp[i-j]);
   }
    dp[i]=minJump;
    minJump=INT_MAX;
    
  }
  
  return dp[n];
}
  
  
  

int main()
{
  int n,k;
  cin>>n>>k;
  int arr[n+1];
  for(int i=1;i<=n;i++)
  {
    cin>>arr[i];
  }
  
  int Cost=minCost(arr,n,k);
  cout<<Cost;
  
  return 0;
}
  

Measured memory_bytes: 4396
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

inline ll read(){
    ll Hashimoto=0;
	bool Kanna=1;
    char I_Love=getchar();
    while(I_Love<'0'||I_Love>'9'){
        if(I_Love=='-')Kanna=0;
        I_Love=getchar();
    }
    while(I_Love>='0'&&I_Love<='9'){
        Hashimoto=Hashimoto*10+I_Love-'0';
        I_Love=getchar();
    }
    return (Kanna?Hashimoto:-Hashimoto);
}
template<typename T1,typename T2> inline void Umax(T1 &a,T2 b){
	if(a<b)a=b;
}
template<typename T1,typename T2> inline void Umin(T1 &a,T2 b){
	if(a>b)a=b;
}

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<(Kanna);++I_Love)cout<<Hashimoto[I_Love]<<(I_Love==(Kanna)-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<(Kanna);++I_Love)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define UNIQUE(Kanna) Kanna.erase(unique(Kanna.begin(),Kanna.end()),Kanna.end());
#define inf (1000000000)
#define linf (1000000000000000000ll)
#define mod (1000000007)

long double ans=0;

int I_Love_Hashimoto_Kanna() {
	//完全想清楚了再开始写。
	//写不顺、不知道怎么写、很乱的时候，停下来好好想想。
	//做得慢总比做不出好。
	fastio;
	int n=read();
	while(n--){
		int x=read();
		long double y=x;
		ans+=1/y;
	}
	printf("%.10Lf\n",1/ans);
	
	return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)
for i in range(1,n):
    p = 0
    for j in range((n-2*i)//2):
        if s[j] != s[(n-2*i)//2 + j]:
            p = 1
            break
    if p == 0:
        print(n-2*i)
        exit()

Measured memory_bytes: 3060
#include <iostream>
#include "bits/stdc++.h"

using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i, a, b) for(ll i=a;i<b;i++)
#define REP(i, a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i, a) for(ll i=a;i>0;i--)
#define rrep(i, a, b) for(ll i=a-1;i>=b;i--)
#define printall(n, array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
typedef vector<vector<ll>> VVE;
const ll mod = 1e9 + 7; //10^9+7

ll n;
ll dp[102][5][5][5];

int main() {
    cin >> n;
    memset(dp, 0, sizeof(dp));
    //0 means A, 1 means G, 2 means C, 3 means T;
    dp[0][3][3][3] = 1;
    REP(i, n)REP(left, 4)REP(mid, 4)REP(right, 4)REP(now, 4) {
        if(mid == 0 and right == 1 and now == 2) continue;
        if(mid == 0 and right == 2 and now == 1) continue;
        if(mid == 1 and right == 0 and now == 2) continue;
        if(left == 0 and mid == 1 and now == 2) continue;
        if(left == 0 and right == 1 and now == 2) continue;
        (dp[i + 1][now][right][mid] += dp[i][right][mid][left]) %= mod;
    }
    ll ans = 0;
    REP(i, 4)REP(j, 4)REP(k, 4)ans += dp[n][i][j][k];
    print(ans % mod);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 #define endl '\n'
int main()

{

string s1,s2;
ll i,n,c=0;
cin>>s1>>s2;
for(i=0;i<s1.size();i++){
    if(s1[i]!=s2[i])c++;
}
cout<<c;
}


Measured memory_bytes: 3916
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define yo cout<<"i got here\n";
using namespace std;
const int mod = 1e9+7,siz = 3e5+5;
int n,m,k,a[siz];
int32_t main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);

   cin>>k>>n;
   for(int i = 1;i<=n;i++) cin>>a[i];
   int ans = 1e9;
   for(int i = 1;i<=n;i++)
   {
       int c,ac;
       c = a[n]-a[i];
       if(i!=1) c+=(k-a[n]+a[i-1]);
       ac = a[i];
       if(i!=n) ac+=(k-a[i+1]);
       ans = min(ans,min(c,ac));
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 5132
#include<bits/stdc++.h>
using namespace std;
int inv[5005];
int fac[5005];
int facinv[5005];

int mod = 1e9+7;
int f,t;
int main(){
  int n,k;
  cin>>n>>k;
  
  inv[0] = 1;
  inv[1] = 1;
  for(int i=2;i<=5005;++i){
      inv[i] = (mod-mod/i)*1LL*inv[mod % i]%mod;
  }
  
  fac[0] = 1;
  fac[1] = 1;
  for(int i=2;i<=5005;++i){
    fac[i] = fac[i-1] * 1LL* i % mod ;
  }
  
  facinv[0] = 1;
  facinv[1] = 1;
  for(int i=2;i<=5005;++i){
    facinv[i] = facinv[i-1] * 1LL* inv[i] % mod ;
  }
  
  for(int i=1;i<=k;++i){
    // C(k-1,i-1) * C(n-k+1,i)
    int a = ((1LL * fac[k-1] * facinv[i-1]) % mod * facinv[k-i])%mod;
    int b = 0;
    if(n-k-i+1>=0){
      b = ((1LL * fac[n-k+1] * facinv[i])%mod * facinv[n-k-i+1])%mod;
    }
    //cout<<a<<" "<<b<<endl;
    cout<<(1LL * a * b)%mod<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
using System;

namespace ABC158A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if (s == "AAA")
                Console.WriteLine("No");
            else if (s == "BBB")
                Console.WriteLine("No");
            else
                Console.WriteLine("Yes");
            Console.WriteLine();

        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((int)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;




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


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

    rep(i, 0, sz(s)){
        if(s == t){
            co("Yes");
            return 0;
        }
        string u = s.substr(0, sz(s)-1);
        s = s[sz(s)-1] + u;
    }
    co("No");

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

#define N 110000
#define INF 0x3f3f3f3f
#define _for(i, a, b) for (int i = (a); i < (b); ++i)

typedef long long ll;

int bit[N];
ll a[N];

void detail(ll x) {
    int n = 0;
    while (x) {
        if (x & 1) bit[n]++;
        x >>= 1;
        ++n;
    }
}

int main() {
    int n;
    ll k, tmp;
    while (scanf("%d%lld", &n, &k) != EOF) {
        int m = 0; tmp = k;
        while (k) m++, k = k >> 1;
        for (int i = 0; i < n; ++i) {
            scanf("%lld", &a[i]);
            detail(a[i]);
        }
        k = 0;
        for (int i = m - 1; i >= 0; --i) {
            k = k << 1;
            if (bit[i] <= n / 2 && ((k + 1) << i) <= tmp) k = k + 1;
        }
        ll res = 0;
        for (int i = 0; i < n; ++i) res += k ^ a[i];
        printf("%lld\n", res);
    }
    return 0;
}


Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P  = pair <int, int>;

#define rep(i, n)     for (int i = 0; i < (int) (n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp)   for (auto &i : mp)

const int INF = 1001001001;
const ll MOD = 1000000007;
int main()
{
  int n;
  cin >> n;
  vector <ll> a(n);
  rep(i, n) cin >> a[i];

  ll ans = 0;
  // for (int i = 0; i < a.size() - 1; i++) {
  //   for (int j = i + 1; j < a.size(); j++) {
  //     ans += a[i] * a[j];
  //     ans %= MOD;
  //   }
  // }
  // vector <int> s(n + 1, 0); // s[0] = 0 になる
  // string s[n + 1];
  // for (int i = 0; i < n; ++i) { s[i + 1] =  atoi(s[i].c_str()) + atoi(a[i]); }
  // // reverse(s.begin(), s.end());
  // for (int i = 0; i < a.size() - 1; i++) {
  //   ans += a[i] * (stoi(s[n]) - stoi(s[i + 1]));
  //   ans %= MOD;
  // }

  vector <ll> s(n + 1, 0); // s[0] = 0 になる
  vector <ll> tmp(n);
  rep(i, n) tmp[i] = a[i];
  reverse(tmp.begin(), tmp.end());
  for (int i = 0; i < n; ++i) { s[i + 1] = (s[i] + (tmp[i] % MOD)) % MOD; }
  // for (int i = 0; i < n; ++i) { s[i + 1] = (s[i] + (a[i] % MOD)) % MOD; }
  for (int i = 0; i < n - 1; i++) {
    // ans += (a[i] % MOD) * (s[n] - s[i + 1]);
    ans += (a[i] % MOD) * (s[n - (i + 1)]);
    ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
    char a,b;
    cin >> a >> b;
    if(a =='H' ){
      cout << b << endl;
    }
    else {
    if(b =='H') {
      cout <<'D'<< endl;
    }
    else{
      cout <<'H'<< endl;
    }
    }
}



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

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

    if(abs(a-x)<abs(b-x)){
        cout << 'A' << endl;
    }
    else{
        cout << 'B' << endl;
    }
    return 0;
}

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

char s[MAX], t[MAX];
int sx[2][MAX], sy[2][MAX];
int memo[3][3], n;

int main(){
	memo[0][0] = memo[1][1] = memo[2][2] = 1;
	memo[1][0] = memo[0][2] = memo[2][1] = 2;
	memo[2][0] = memo[0][1] = memo[1][2] = 3;
	scanf("%s%s", s, t);
	int sn = strlen(s), tn = strlen(t);
	
	for(int i = 1;i <= sn;i++){
		if(s[i-1] == 'A')sx[0][i]++;
		else sx[1][i]++;
		sx[0][i] += sx[0][i-1];
		sx[1][i] += sx[1][i-1];
	}
	for(int i = 0;i <= tn;i++){
		if(t[i-1] == 'A')sy[0][i]++;
		else sy[1][i]++;
		sy[0][i] += sy[0][i-1];
		sy[1][i] += sy[1][i-1];
	}
	
	scanf("%d", &n);
	for(int i = 0;i < n;i++){
		int x[2], y[2];
		for(int j = 0;j < 2;j++)scanf("%d", &x[j]);
		for(int j = 0;j < 2;j++)scanf("%d", &y[j]);
		int a1 = (sx[0][x[1]]-sx[0][x[0]-1])%3;
		int b1 = (sx[1][x[1]]-sx[1][x[0]-1])%3;
		int a2 = (sy[0][y[1]]-sy[0][y[0]-1])%3;
		int b2 = (sy[1][y[1]]-sy[1][y[0]-1])%3;
		if(memo[a1][b1] == memo[a2][b2])printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


Measured memory_bytes: 2304
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main(){
    input!{
        a:i64,
        b:i64,
        c:i64,
    }
    let mut v = vec![];
    for i in 1..101 {
        if a % i == 0 && b % i == 0{
            v.push(i);
        } 
    }
    v.reverse();
    println!("{}",v[c as usize - 1]);
}


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

int main(){
    
    // 1. 入力情報.
    char c[22];
    scanf("%s", c);
    
    // 2. 出力.
    rep(i, 12){
        printf("%c", c[i]);
        if(i == 3) printf(" ");
    }
    puts("");
    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    int s[n];
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        s[i]=a;
    }
    int ans=-1,b;
    sort(s,s+n);
    int ch=s[n-1];
    for(int i=0;i<n-1;i++){
        int p=min(s[i],ch-s[i]);
        if(ans<p){
            ans=p;
            b=s[i];
        }
    }
    cout<<ch<<" "<<b<<endl;
}


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

using namespace std;

int main(){
    int n;
    cin>>n;
    int x=0,y=0;
    int t=0;
    int a,b,c;
    for(int i=1;i<=n;i++)
    {
        cin>>c>>a>>b;
        if(abs(x-a)+abs(y-b)>c-t)
        {
            cout<<"No"<<endl;
            return 0;
        }
        if((abs(x-a)+abs(y-b))%2==0 &&(c-t)%2==1)
        {
            cout<<"No"<<endl;
            return 0;
        }
        if((abs(x-a)+abs(y-b))%2==1 &&(c-t)%2==0)
        {
            cout<<"No"<<endl;
            return 0;
        }
        x=a;y=b;t=c;
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<stack>
#include<cstdlib> 
#include<fstream> 
using namespace std;
int main(){
	int n,a;
	cin>>n>>a; 
	cout<<n*n-a<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>
#include<utility>
#include<map>

using namespace std;

int main() {
	int n, a;
	cin >> n >> a;
	if (n % 500 <= a)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define N 100005
#define M 65540
using namespace std;
int n,s[N],S,ans,f[M],inf,sum[20];

int dfs(int S)
{
  if(!S)return 0; 
  if(f[S]<inf)return f[S];
  for(int i=0;i<16;i++)if((S>>i)&1)
    for(int j=0;j<16;j++)if(i!=j&&(S>>j)&1)
    {
      int p=i^j,x=S^(1<<i)^(1<<j)^(1<<p);
	  if(S>>p&1)f[S]=min(f[S],dfs(x)+2);
	  else f[S]=min(f[S],dfs(x)+1);
	  //枚举每次异或的两个节点i,j,i异或掉j,j异或掉j,还剩下p=i^j
	  //如果p本身存在那两个p直接消掉 
	}
  return f[S];
}

int main()
{
  int a,b,c;
  scanf("%d",&n);
  for(int i=1;i<n;i++)
    scanf("%d%d%d",&a,&b,&c),s[a]^=c,s[b]^=c;
  for(int i=0;i<n;i++)sum[s[i]]++;
  for(int i=1;i<16;i++)
    ans+=(sum[i]>>1),S+=(1<<i)*(sum[i]&1);
  memset(f,127,sizeof(f));inf=f[0];
  printf("%d\n",ans+dfs(S));
  return 0;
} 

Measured memory_bytes: 896
#include"bits/stdc++.h"
using namespace std;

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

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

int query(int i){
    cout << i << endl;
    string s;
    cin >> s;
    if(s == "Male") return 1;
    else if(s == "Female") return 2;
    else {
        exit(0);
        return 0;
    }
}

void Main() {
    int n; cin >> n;
    vi s(n, -1);
    
    int l = 0;
    int r = n-1;

    s[l] = query(l);
    s[r] = query(r);

    int mid;

    // 常に next > now で, 
    // s[now] != s[next] && (next - now) % 2 == 0
    // s[now] == s[next] && (next - now) % 2 == 1
    // のどちらかが成立    

    while(1){
        mid = (l + r) / 2;

        s[mid] = query(mid);

        if(s[l] != s[mid] && (mid - l) % 2 == 0) {
            r = mid;    
        }
        else if(s[l] == s[mid] && (mid - l) % 2 == 1){
            r = mid;
        }
        else{
            l = mid;
        }
    }
    return;
}

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

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios_base::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

int main()
{
  while (int N = in()){
    int bucket[128] = {};
    set<int> player[128];
    for (int i = 1; i <= N; i++){
      for (int M = in(); M--; ){
        int v = in();
        bucket[v]++;
        player[i].insert(v);
      }
    }
    vector<int> L;
    inpt(L, in(), in);
    vector<int> cand;
    for (int i = 1; i <= N; i++){
      bool ok = true;
      for (int l : L){
        if (!player[i].count(l)){
          ok = false;
          break;
        }
      }
      if (ok) cand.emplace_back(i);
    }
    if (cand.size() == 1){
      printf("%d\n", cand[0]);
    }
    else {
      printf("-1\n");
    }
  }
  return 0;
}

Measured memory_bytes: 1588
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
#define debug(a) cout<<#a<<" --> "<<(a)<<endl;
#define fastInput ios_base::sync_with_stdio(false);cin.tie(0)
#define INPUT freopen("input.txt","r",stdin)
#define OUTPUT freopen("output.txt","w",stdout)
#define Error  1e-9
#define pi (2*acos(0))
const ll mod =1e9 +7;
const int N = 1e5 +5;

void Solve(int cas)
{
    int n,base;
    scanf("%d",&n);
    int sum =0;
    vector<int>a(n);
    for(int i=0;i<n;i++)
    {
        int x;
        scanf("%d",&x);
        a[i]=x;
        sum+=x;
    }
    sum/=n;
    //debug(sum);
    ll ans =0,ans2=0;
    for(int i=0;i<n;i++)
    {
        ll tmp =(ll)(a[i]-sum);
        ans+= tmp*tmp;
    }
    sum++;
    for(int i=0;i<n;i++)
    {
        ll tmp =(ll)(a[i]-sum);
        ans2+= tmp*tmp;
    }
    printf("%lld\n",min(ans,ans2));




}



int main()
{
    //fastInput;
    //cout.tie(0);
    //INPUT;
    //OUTPUT;
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        Solve(++cas);
    }
    return 0;
}
/*

*/


//os.order_of_key(v): returns how many elements strictly less than v
//os.find_by_order()

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}


Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int k = int.Parse(input[1]);
		if(k != 1) Console.WriteLine(n-k);
    else Console.WriteLine(0);
	}
}

Measured memory_bytes: 11092
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;

void main()
{
	
	while (1) {
		auto rn = readln.split.map!(to!int);
		auto r = rn[0];
		auto n = rn[1];
		if (r == 0 && n == 0) break;

		int hs[int];
		foreach (i; 0..n) {
			auto xh = readln.split.map!(to!int);
			foreach (j; xh[0]..xh[1]) {
				hs[j] = max(hs.get(j, 0), xh[2]);
			} 
		}

		auto res = double.max;
		foreach (i; -r..r) {
			res = min(res, hs.get(i, 0) - (r^^2 - i^^2).to!double.sqrt + r);
			res = min(res, hs.get(i, 0) - (r^^2 - (i+1)^^2).to!double.sqrt + r);
		}

		res.writeln;
	}
}

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

int main()
{
  int len=0;
  char str[1003];
  cin>>str;
  len=strlen(str);
  if(str[len-1]=='s')
    {
        str[len]='e';
        str[len+1]='s';
        str[len+2]='\0';
    }
  else
    {
        str[len]='s';
        str[len+1]='\0';
    }
  cout<<str<<endl;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main(){
	fast;
	int n;cin>>n;
	int v[n];
	for(int i=0;i<n;i++) cin>>v[i];
	vector<int> dp(n,0);
	dp[0]=0;
	dp[1]=abs(v[1]-v[0]);
	for(int i=2;i<n;i++) dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i-2]-v[i]));
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 4016
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)

int main() {
  int n,m;cin >>n>>m;
  vector<int> h(n);
  for(int i=0;i<n;++i) cin >> h[i];
  vector<bool> isgood(n,true);
  for(int j=0;j<m;++j){
    int a,b;cin>>a>>b;
    if(h[a-1]>h[b-1]){
      isgood[b-1] = false;
    } else if(h[a-1]<h[b-1]) {
      isgood[a-1] = false;
    } else {
      isgood[a-1] = false;
      isgood[b-1] = false;
    }
  }
  int out =0;
  cout << count(isgood.begin(), isgood.end(), true) << endl;
  return 0;
}

Measured memory_bytes: 3780
#include <stdio.h>
int main(void){
	int a,b,c,i,tmp,cnt;
	char str[100];

	for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
		sscanf(str,"%d %d %d",&a,&b,&c);
		tmp=a+b; cnt=0;
		for(i=1;i<11;i++){
			if(i==a || i==b || i==c)
				continue;
			if(i+tmp<=20)
				cnt++;
		}
		if(cnt>=4)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

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

int main(){
  int pnt_a = 0;
  int pnt_b = 0;
  int car_a;
  int car_b;
  int num;

  while(cin >> num){
    if(!num) break;
    for(; num; num--){
      cin >> car_a;
      cin >> car_b;
      if(car_a < car_b) pnt_b += (car_a + car_b);
      else if (car_a > car_b) pnt_a += (car_a + car_b);
      else {pnt_a += car_a; pnt_b += car_b;}
    }

    cout << pnt_a << " " << pnt_b << "\n";
    pnt_a = pnt_b = 0;
  }

return 0;
}

Measured memory_bytes: 3076
package main

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

func solve() {
	var n int
	fmt.Scan(&n)

	h := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	buffer := make([]byte, 10*200001)
	sc.Buffer(buffer, 10000)
	sc.Scan()
	args := strings.Split(sc.Text(), " ")
	for i := 0; i < n; i++ {
		h[i], _ = strconv.Atoi(args[i])
	}

	able := true
	b := h[0] - 1
	for i := 1; i < n; i++ {
		if b <= h[i]-1 {
			b = h[i] - 1
		} else if b <= h[i] {
			b = h[i]
		} else {
			able = false
			break
		}
	}

	if able {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func main() {
	solve()
}


Measured memory_bytes: 5376
// #include<bits/stdc++.h>
// using namespace std;
 
// const int N = 10000, MAXI = 100000, D = 10;
 
// int main() {
//     freopen("output.txt", "r", stdin);
//     freopen("input.txt", "w", stdout);
//     srand(time(nullptr));
//     int tc = 100, flag = 1;
//     cout << tc << "\n";
//     while (tc--)
//     {
//     	cout << rand()%D + 1 << " " << rand()%D + 1 << " " << rand()%D + 1 << " " << rand()%D + 1;

//     	cout << "\n~\n";
    	
//     }
 
//     return 0;
// }
 
 
 
 
 
 
 
 
//---------------------------------------------//
 
 
 
/*
#define int long long 
#define mod (int)(1e9+9)
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 200005
 */ 
 
 
 
 
 
 
//  /* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
//#define int long long
#define mod (int)(1e9+7)
#define N 100005


// Driver code to test above functions
int32_t main()
{
    
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);


    int n, m;
    cin >> n >> m;

    char arr[n+1][m+1];
    for(int i=1;i<=n;i++)
    	for(int j=1;j<=m;j++)
    		cin >> arr[i][j];

    int dp[n+1][m+1] = {{0}};
    for(int i=1;i<=n;i++)
    {
    	if(arr[i][1]=='.')
    		dp[i][1] = 1;
    	else
    		break;
    }

    for(int i=1;i<=m;i++)
    {
    	if(arr[1][i]=='.')
    		dp[1][i] = 1;
    	else
    		break;
    }

    for(int i=2;i<=n;i++)
    {
    	for(int j=2;j<=m;j++)
    	{
    		if(arr[i][j]=='.')
    			dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
    		else
    			dp[i][j] = 0;
    	}
    }

    cout << dp[n][m];
    
    return 0;
 
} 

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define reps(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) reps(i, 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

int main() {
	int a, b, c; cin >> a >> b >> c;
	if (b - a == c - b) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 256
N = int(input())

F = 1
F_min = 10**10

for A in range(1,int((N+1)**(1/2))+1):
  if N%A == 0:
    F = max(len(str(A)),len(str(int(N/A))))
    if F_min > F:
      F_min = F
            
print(F_min)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

ll cnt[200005];
int N;
int A[200005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        cnt[A[i]]++;
    }
    ll all = 0;
    for(int i = 1; i <= N; i++){
        all += (cnt[i]*(cnt[i]-1))/2;
    }
    for(int i = 0; i < N; i++){
        cout << all-cnt[A[i]]+1 << endl;
    }
}

Measured memory_bytes: 3968
import sys
N = int(input())

ts = 0
xs = 0
ys = 0

for i in range(N):
    t, x, y = [int(c) for c in input().split()]
    min_len = x-xs + y-ys
    dt = t-ts
    if min_len > dt or (dt - min_len) % 2 == 1:
        print('No')
        sys.exit()
    ts = t
    xs = x
    ys = y

print('Yes')


Measured memory_bytes: 3060
/*

 Remember, Hope is a good thing... May be the best of things... and No Good thing ever Dies !!!

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios::sync_with_stdio(0); cout.tie(0);
#define endl "\n"
#define MOD 1000000007
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define N 2010
char st[N];
ll mat[N][N],sumR[N][N],sumC[N][N];
typedef long double ld;
const ll inf=(1LL<<60)-1;
const ll mxn=1e5;
int dx[]= {-1,1,0,0};
int dy[]= {0,0,-1,1};
map<ll,ll>mp;
vector<ll>divs;
void div(ll x)
{
    for(ll i=1; i*i<=x; i++)
    {
        if(x%i==0)
        {
            if(x/i==i)
                divs.push_back(i);
            else
            {
                divs.push_back(x/i);
                divs.push_back(i);
            }
        }
    }
}
void solve()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    ll a,b,c,d,cnt=0;
    cin>>a>>b>>c>>d;
    cout<<max(max(a*c,a*d),max(b*c,b*d))<<endl;

}
int main()
{
    IOS;
    //ll t;
    //cin>>t;
    //while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3632
/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <ll , ll>;
void in(ll &x);
// const ll N = ;
ll a, b, c, d;

int main() {
  vector <ll> v(4);
  for (int i = 0 ; i < 4 ; i++) {
    in(v[i]);
  }
  ll sol = LLONG_MIN;
  for (int i = 0 ; i < 2 ; i++) {
    for (int j = 2 ; j < 4 ; j++) {
      sol = max(sol , v[i] * v[j]);
    }
  }
  printf("%lld\n" , sol);
  return 0;
}

void in(ll &x){
	bool neg = false;
	register ll c;
	x = 0;
	c = getchar();
	if(c == '-'){
		neg = true;
		c = getchar();
	}
	for (; c > 47 && c < 58; c = getchar())
	x = (x << 1) + (x << 3) + c - 48;
	if (neg) x *= -1;
}


Measured memory_bytes: 3720
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0 for i in range(n)]

for i in range(1, n):
    temp = []
    limit = max(i-k, 0)
    for j in range(limit, i):
        temp.append(dp[j] + abs(h[i] - h[j]))

    dp[i] = min(temp)

print(dp[-1])


Measured memory_bytes: 56544
#include<stdio.h>
#include<stdlib.h>
struct node {
	int key;
	struct node *right;
	struct node *left;
	struct node *parent;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insert(int k) {
	Node y = NIL;
	Node x = root;
	Node z;

	z = malloc(sizeof(struct node));
	z->key = k;
	z->left= NIL;
	z->right= NIL;

	while (x != NIL) {
		y = x;
		if ((z->key) < (x->key)) {
			x = x->left;
		}else {
			x=x->right;
		}
	}
	z->parent = y;
	if (y == NIL) {
		root = z;
	}else {
		if ((z->key) < (y->key)) {
			y->left = z;
		}else {
			y->right = z;
		}
	}
}

void inorder(Node u) {
	if (u == NIL) {
		return;
	}
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
}

void preorder(Node u) {
	if (u == NIL) {
		return;
	}
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
}


int main() {
	int n, i, x;
	char com[20];
	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%s", com);
		if (com[0] == 'i') {
			scanf("%d", &x);
			insert(x);
		}
		else if (com[0] == 'p') {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}


Measured memory_bytes: 25140
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
using namespace std;

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

    cout<<ans<<endl;
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main(){
    int a,b,c,t;
    cin>>a>>b>>c;
    if(a>b){
        t=a;
        a=b;
        b=t;
    }
    if(b>c){
        t=b;
        b=c;
        c=t;
    }
    if(a>b){
        t=a;
        a=b;
        b=t;
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}



Measured memory_bytes: 3088
/* ABC142-B
   Takatan */

#include<stdio.h>
int main(void){
    int number, limit, height, count, i;
    count = 0;

    scanf( "%d %d" , &number, &limit);
    for(i=0; i < number; i++){
        scanf( "%d" , &height);
        if(height>=limit){ /* 乗車可能な時 */
            count++; /* 加算 */
        }
    }
    printf( "%d\n" , count);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <stack>
#include <list>

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,b,n) for(int i=b;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

const float PI = 3.1415926;
static const int INFTY = (1<<30);

using namespace std;

typedef long long ll;
typedef long double ld;

int w[102][102], p0[102][102], p90[102][102], p180[102][102], p270[102][102], n, m, res[2];

void solve(int y, int x, int num) {
  int xt, yt;
  xt = 1000;
  
  for(int i = y; i < y+m; i++) {
    for(int j = x; j < x+m; j++) {
      if(num == 0) {
        if(p0[i-y][j-x] != -1 && xt == 1000) {
          xt=j; yt=i;
        }
        if(p0[i-y][j-x] != -1 && p0[i-y][j-x] != w[i][j]) {
          return;
        }
      }
      if(num == 90) {
        if(p90[i-y][j-x] != -1 && xt == 1000) {
          xt=j; yt=i;
        }
        if(p90[i-y][j-x] != -1 && p90[i-y][j-x] != w[i][j]) {
          return;
        }
      }
      if(num == 180) {
        if(p180[i-y][j-x] != -1 && xt == 1000) {
          xt=j; yt=i;
        }
        if(p180[i-y][j-x] != -1 && p180[i-y][j-x] != w[i][j]) {
          return;
        }
      }
      if(num == 270) {
        if(p270[i-y][j-x] != -1 && xt == 1000) {
          xt=j; yt=i;
        }
        if(p270[i-y][j-x] != -1 && p270[i-y][j-x] != w[i][j]) {
          return;
        }
      }
    }
  }

  if(res[1] > yt+1) {
    res[0] = xt+1;
    res[1] = yt+1;
  }else if(res[1] == yt+1) {
    if(res[0] > xt+1) {
      res[0] = xt+1;
    }
  }
}

int main() {
  while(cin >> n >> m, n) {
    res[0] = 1000;
    res[1] = 1000;
    rep(i, n) {
      rep(j, n) {
        cin >> w[i][j];
      }
    }
    rep(i, m) {
      rep(j, m) {
        int t;
        cin >> t;
        p0[i][j] = t;
        p90[j][m-1-i] = t;
        p180[m-1-i][m-1-j] = t;
        p270[m-1-j][i] = t;
      }
    }

    for(int i=0; i+m <= n; i++) {
      for(int j=0; j+m <= n; j++) {
        solve(i, j, 0);
        solve(i, j, 90);
        solve(i, j, 180);
        solve(i, j, 270);
      }
    }

    if(res[0] == 1000)
      cout << "NA" << endl;
    else
      cout << res[0] << " " << res[1] << endl;
  }
        
  return 0;
}

Measured memory_bytes: 3144