akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc159/tasks/abc159_b

#include <iostream>
#include<string>
#define ll long long
using namespace std;

int toggle(string& str) 
{ 
    ll length = str.length(); 
    ll cou=0;
    for (ll i = 0; i < length; i++) { 
        ll c = str[i]; 
        if (islower(c)) 
            cou+=1;
	}                                                 
    if((cou==length && (length%2)!=0)){return 1;}
        else{return 0;}
     
} 

int pallindrome(int x,int y,string &str)
{ll count=0;
ll n=str.length();
	for(ll it=x;it<y;it++)
    {
        if(str[it]==str[y-it-1]){count +=1;}
    }
    if(count==(y-x)){return 1;}
    else{return 0;}
}

int main()
{
    string str;
    cin>>str;
    ll n=str.length();
    ll s1=(n-1)/2-1;
    ll s2=(n+3)/2-1;
    int y=toggle(str);
    int a=pallindrome(0,n,str);
    int b=pallindrome(0,s1+1,str);
    int c=pallindrome(s2,n,str);
    int z=(((a&&b)&&c)&&y);
    //cout<<y<<a<<b<<c<<z<<endl;
    if(z==1){cout<<"Yes";}
    else{cout<<"No";}
}
    



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

using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF (1<<28)
#define int long long
#define floot10 cout<<fixed<<setprecision(10);
int a[1002][1002];

signed main(){
  int n;
  cin>>n;
  lp(i,n){
    int x1,x2,y1,y2;
    cin>>x1>>y1>>x2>>y2;
    x2--;
    y2--;
    a[x1][y1]+=1;
    a[x2+1][y1]-=1;
    a[x1][y2+1]-=1;
    a[x2+1][y2+1]+=1;
  }
  lp(i,1001){
    lp(j,1001){
      if(j==0) continue;
      a[j][i]+=a[j-1][i];
    }
  }
  int ans=0;
  lp(i,1001){
    lp(j,1001){
      if(j==0) {
	//ans=max(a[i][j],ans);
	continue;
      }
      a[i][j]+=a[i][j-1];
      // ans=max(a[i][j],ans);
    }
  }/*
  lp(i,10){
    lp(j,10){
      cout<<a[i][j];
    }
    cout<<endl;
    }*/
  lp(i,1001){
    lp(j,1001){
      ans=max(ans,a[i][j]);
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 10936
#include <stdio.h>
int main(void){
    int count[100]={0},temp,five,i,j;
    for(i=0;;i++){
    	five=5;
        scanf("%d",&temp);
        if(temp==0) break;
        while(1) {
            if (temp>=five) {
                count[i]+=temp / five;
            } else {
                break;
            }
            five*=5;
        }
    }
    for(j=0;j<i;j++) printf("%d\n",count[j]);
    return 0;
}

Measured memory_bytes: 600
#include<stdio.h>

int main(void){
	int L,M,N,k[12],i,kai;

	while(0==0){
		scanf("%d",&L);
		if(L==0) break;
		kai=0;
		for(i=1;i<13;i++){
			scanf("%d %d\n",&M,&N);
			k[i]=M-N;
		}
        for(i=1;i<13;i++){
			L-=k[i];
			  if(L<=0){
				  kai=i;
				  break;
			  }
		}
		if(kai==0) printf("NA\n");
	    else printf("%d\n",kai);
	}
  return 0;
}

Measured memory_bytes: 1044
// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;
 
#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

using T=ll;

class SST {
public:
    const T inf = 0;
    T m(T x, T y) { return max(x, y); }
    int d; T sum;
    SST* ch[2];
    SST(int D) : d(D) {
        sum = inf;
        ch[0] = nullptr;
        ch[1] = nullptr;
    }
    ~SST() {
        if (ch[0]) delete ch[0];
        if (ch[1]) delete ch[1];
    }
    void inc(const int& i, const T& v) {
        if (!d) { sum = m(sum, v); return; }
        bool cv = i & (1ll << (d - 1));
        if (!ch[cv]) ch[cv] = new SST(d - 1);
        ch[cv]->inc(i, v);
        sum = ch[cv]->sum; if(ch[1-cv]) sum = m(sum, ch[1-cv]->sum);
    }
    T prepsum(const int& i) {
        if (!d) return sum;
        T ans = inf;
        bool cv = i & (1ll << (d - 1));
        if (ch[cv]) ans = ch[cv]->prepsum(i);
        if (cv && ch[0]) ans = m(ans, ch[0]->sum);
        return ans;
    }
    T sufpsum(const int& i) {
        if (!d) return sum;
        T ans = inf;
        bool cv = i & (1ll << (d - 1));
        if (ch[cv]) ans = ch[cv]->sufpsum(i);
        if (!cv && ch[1]) ans = m(ans, ch[1]->sum);
        return ans;
    }
    T psum(const int& l, const int& r) {
        if (!d) return sum;
        bool cv1 = l & (1ll << (d - 1));
        bool cv2 = r & (1ll << (d - 1));
        if (cv1==cv2) {
            if(!ch[cv1]) return inf;
            return ch[cv1]->psum(l, r);
        }
        T ans = inf;
        if(ch[0]) ans = m(ans, ch[0]->sufpsum(l));
        if(ch[1]) ans = m(ans, ch[1]->prepsum(r));
        return ans;
    }
};

int h[200005];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    SST* s = new SST(20);
    int n; cin >> n;
    rep(i, n) cin >> h[i];
    rep(i, n) {
        int v; cin >> v;
        s->inc(h[i], s->psum(1, h[i]-1) + v);
    }
    cout << s->psum(1, n) << endl;
}



Measured memory_bytes: 19968
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n,m; cin>>n>>m;
    vector<int> s(m),c(m);
    vector<int> cnt(10);
    map<int,int, greater<int>> mp;
    rep(i,m) {
        cin>>s[i]>>c[i];
        if (mp.count(s[i])) {
            if (c[i] != mp[s[i]]) {
                cout << -1 << '\n';
                return 0;
            }
        }
        mp[s[i]] = c[i];
    }

    string ans(n,'0');
    for (auto &&e: mp) {
        ans[e.first-1] = e.second+'0';
    }

    if (mp.count(1)) {
        if (mp[1] == 0 && n>1) {
            cout << -1 << '\n';
            return 0;
        }
    }

    if (ans[0] == '0' && n > 1) ans[0] = '1';
    cout << ans << '\n';
    return 0;
}

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

using namespace std;


long long int a,b=1000000000000007,c[200010],d[200010],ans =0,ant=0,anu =0;

int main(){
  cin >> a ;
  
  for(int i=0;i<a;i++)
    cin >> c[i];
  
  for(int i=0;i<a;i++){
    
   ant += c[i];
  }
  
  for(int i=0;i<a-1;i++){
    anu += c[i];
  b = min(b,abs(ant -2*anu));
  }
  
  cout << b << endl;
}


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

int main(void){
  char str[100001];
  int l,N,point=0,i;
  scanf("%s%*c",str);
  l=strlen(str);

  for(i=0;i<l;i++){
    if(i%2)
      point+=str[i]=='g';
    else
      point-=str[i]=='p';
  }
  printf("%d\n",point);
  return 0;
}


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

int main() {
	ll x;
	cin >> x;
	ll ans;
	for (ll i = x; i < INF; i++) {
		int cnt = 0;
		for (ll j = 1; j * j <= i; j++) {
			if (i % j == 0) cnt++;
		}
		if (cnt == 1) {
			ans = i;
			break;
		}
	}
	cout << ans;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)(j);i <= (int)(k);i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int s,w;cin>>s>>w;
    cout<<(w>=s?"unsafe":"safe")<<endl;
}

Measured memory_bytes: 3568
#include<stdio.h>
int solve(int,int);

int n;
int A[2000];
int main(){


  int i;
  int q;
  int m[2000];
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i = 0;i < q;i++){
    scanf("%d",&m[i]);
    if(solve(0,m[i]) == 1){
      printf("yes\n");
    }else if(solve(0,m[i]) == 0){
      printf("no\n");
    }
  }
  return 0;
}

int solve(int i,int m){
  int res;
  if(m == 0) return 1;
  else if(i>=n){
    return 0;
  }
  res = solve(i + 1,m) || solve(i + 1,m - A[i]);
  return res;
}




Measured memory_bytes: 2108
S = input()[:: -1]
mod = 10 ** 9 + 7
dp = [[0 for _ in range(13)] for _ in range(len(S) + 1)]

if S[0] == "?":
    for k in range(10):
        dp[1][k % 13] += 1
else:
    dp[1][int(S[0]) % 13] += 1

tmp = 1
for i in range(2, len(S) + 1):
    tmp *= 10
    tmp %= 13
    for j in range(13):
        if dp[i - 1][j] > 0:
            if S[i - 1] == "?":
                for k in range(10):
                    dp[i][(tmp * k + j) % 13] += dp[i - 1][j] % mod
            else:
                dp[i][(tmp * int(S[i - 1]) + j) % 13] += dp[i - 1][j] % mod

print(dp[len(S)][5] % mod)

Measured memory_bytes: 65884
#include <iostream>
#define llint long long

using namespace std;

llint n;

int main(void)
{
	while(1){
		cin >> n;
		if(n == 0) break;
		
		llint ans = 0;
		for(int i = 1; i <= n; i++){
			for(int j = i+1; j <= n; j++){
				if((i+j)*(j-i+1)/2 == n) ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 2980
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1000000007
//S.size()

using namespace std;


typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;



int main(void){
  int N,M,X; cin>>N>>M>>X;
  int a[M];rep(i ,M)cin>>a[i];

  int right = 0,left = 0,jud;
  for(auto t : a)if(t < X)left++;

  right = M - left;
  
  if(right <= left)cout<<right;
  else cout<<left;

}


Measured memory_bytes: 256
def f2(p):
    return 2*p
def f4(p):
    if p<5:
        return 3*p
    else:
        return 4*p
def f14(p):
    if p==2:
        return 16
    elif p==3:
        return 30
    elif p==5:
        return 60
    elif p==7:
        return 91
    else:
        return 101
def f24(p):
    if p==2:
        return 28
    elif p==3:
        return 54
    elif p==5:
        return 100
    else:
        return 101
def f74(p):
    if p==2:
        return 78
    else:
        return 101
    
P = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

N = int(input())
c2=0
c4=0
c14=0
c24=0
c74=0

for p in P:
    if f2(p)<=N:
        c2 += 1
    if f4(p)<=N:
        c4 += 1
    if f14(p)<=N:
        c14 += 1
    if f24(p)<=N:
        c24 += 1
    if f74(p)<=N:
        c74 += 1


ans = 0
ans += (c4*(c4-1)//2)*(c2-2)
ans += c14 * (c4 - 1)
ans += c24 * (c2 - 1)
ans += c74

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    String result = "";
   	if(a<b) {
   		for(int i=0;i<b;i++) {
   		result = result + a;
   		}
   	}else if(a>b) {   		
   		for(int i=0;i<a;i++) {
   		result = result + b;
   		}  		
   	}else {
   		for(int i=0;i<b;i++) {
   	   		result = result + a;
   	   		}
   	}
    System.out.println(result);
  }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
int main(){
  ll n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  sort(all(a));
  if(n==2) cout<<a[1]<<" "<<a[0]<<endl;
else{
  cout<<a[n-1]<<" ";
   ll r;
   ll t=0;
  rep(i,n){
    ll com=a[n-1]-a[i];
    if(min(a[i],com)>t){
      t=min(a[i],com);
      r=a[i];
    }
  }
  cout<<r<<endl;
}
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RREP(i,n) for(long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define llINF (long long) 9223372036854775807
#define loINF (long) 2147483647
#define shINF (short) 32767
#define SORT(c) sort((c).begin(),(c).end())

using namespace std;
typedef vector<short> VI;
typedef vector<VI> VVI;

int main(void){
	short N;
	long sumval,half;
	cin >> N;
	VI A(N,0);
	REP(i,N) {
		cin >> A[i];
		sumval += A[i];
	}
	half = ((sumval+1) / 2);

	bitset<2000*2000> dp(0);
	dp.set(0);
	REP(i,N){
		bitset<2000*2000> tmp(0);
		tmp |= dp;
		dp <<= A[i];
		dp |= tmp;
	}

	FOR(i,half,sumval+1){
		if (dp[i]) {
			cout << i << endl;
			exit(0);
		}
	}

	return 0;
}

Measured memory_bytes: 1280
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String line = scanner.nextLine();
		String[] lines = line.split(" ");

		int M = Integer.parseInt(lines[0]);
		int D = Integer.parseInt(lines[1]);

		int ans = 0;

		for (int i = 22; i <= D; i++) {
			String[] strD = String.valueOf(i).split("");
			if (Integer.parseInt(strD[0]) < 2 || Integer.parseInt(strD[1]) < 2)
				continue;
			int compare = Integer.parseInt(strD[0]) * Integer.parseInt(strD[1]);

			for (int j = 1; j <= M; j++) {
				if (j == compare) {
					ans++;
				}
			}
		}

		System.out.println(ans);

	}

}


Measured memory_bytes: 20688
# Author: cr4zjh0bp
# Created: Sat Mar  7 12:47:52 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

from collections import deque

s = deque(ns())
q = ni()
p = 0
for i in range(q):
    que = nas()
    if int(que[0]) == 1:
        p += 1
    elif int(que[0]) == 2:
        f, c = int(que[1]), que[2]
        if p % 2 == 0:
            if f == 1:
                s.appendleft(c)
            else:
                s.append(c)
        else:
            if f == 1:
                s.append(c)
            else:
                s.appendleft(c)

for i in range(len(s)):
    if p % 2 == 1:
        print(s.pop(), end="")
    else:
        print(s.popleft(), end="")
print()

Measured memory_bytes: 90664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    ll N,M;
    string S;
    cin >> N >> M >> S;
    reverse(S.begin(),S.end());
    vector<ll> ans;
    int now=0;
    while(now<N){
        for (int i=M;i>=1;--i){
            if (S[now+i]=='0'){
                ans.push_back(i);
                now+=i;
                break;
            }
            if (i==1){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    reverse(ans.begin(),ans.end());
    int s=ans.size();
    rep(i,s){
        cout << ans[i];
        if (i!=s-1) cout << ' ';
        else cout << endl;
    }
}

Measured memory_bytes: 1528
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 51;
ll a[MAXN], b[MAXN];
int n;
bool check(ll x)
{
    ll sum = 0, t;
    for (int i = 1; i <= n; i++) a[i] = b[i] + x;
    for (int i = 1; i <= n; i++) if (a[i] >= n)
    {
        t = max(0ll, (a[i] - n + 1) / (n + 1));
        a[i] -= (n + 1) * t;
        while (a[i] >= n) sum++, a[i] -= n;
        sum += t;
    }
    return sum <= x;
}
bool cmp(ll &x, ll &y) {return x > y;}
int main() 
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%lld", &b[i]);
    sort(b + 1, b + 1 + n, cmp);
    // for (int i = 0; i <= 100; i++) printf("%d ", check(i));
    ll l = 0, r = 1e18;
    while (l < r)
    {
        ll mid = (l + r) >> 1;
        if (check(mid)) r = mid;
        else l = mid + 1;
    }
    ll ans;
    for (ll x = max(0ll, l - n * n - 1); x <= l; x++) 
        if (check(x)) {ans = x; break;}
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
I = [[i, 1] for i in range(N)]
B = [0] * M
for i in range(M):
  B[M - 1 - i] = [int(x) - 1 for x in input().split()]

def root(a):
	if I[a][0] == a:
		return a
	else:
		I[a][0] = root(I[a][0])
		return I[a][0]

def uni(a,b):
	ra = root(a)
	rb = root(b)
	na = I[ra][1]
	nb = I[rb][1]
	if ra == rb:
		return 0
	if ra < rb:
		I[rb][0] = ra
		I[ra][1] += I[rb][1]
	else:
		I[ra][0] = rb
		I[rb][1] += I[ra][1]
	return na*nb

NC = [0]*M
NC[-1] = N*(N-1)//2
for i in range(M-1):
	a,b = B[i]
	NC[M-2-i] = NC[M-1-i]-uni(a,b)

for nc in NC:
	print(nc)

Measured memory_bytes: 36608
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  int h,w;
  cin >> h >> w;
  int n;
  cin >> n;
  vector<int> v;
  for(int i = 0;i < n;i++)
  {
    int a;
    cin >> a;
    for(int j = 0;j < a;j++)
    {
      v.push_back(i + 1);
    }
  }
  for(int i = 0;i < h;i++)
  {
    if(i % 2 == 0)
    {
      for(int j = 0;j < w;j++)
      {
        cout << v.at(i * w + j) << " ";
      }
    }
    else
    {
      for(int j = w - 1;j >= 0;j--)
      {
        cout << v.at(i * w + j) << " ";
      }
    }
    cout << "\n";
  }

  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <ctype.h>
 
void FuncOpenLock(char str[96], int key);
 
int main(void)
{
  char buf[81];
  int key;
  int i;
 
  while (fgets(buf, 81, stdin) != NULL) {
    char temp[81];
     
    key = 27;
    for (i = 0; i < 26; i++) {
      strcpy(temp, buf);
      FuncOpenLock(temp, i);
 
      if (strstr(temp, "the")  != NULL ||
      strstr(temp, "this") != NULL ||
      strstr(temp, "that") != NULL) {
    key = i;
      }
       
      if (key != 27) {
    printf("%s", temp);
    break;
      }
    }
  }
 
  return 0;
}
 
void FuncOpenLock(char *str, const int key){
  int i;
   
  for ( i = 0; str[i] != '\n'; i++ ) {
    if ( isalpha(str[i]) ) {
      str[i] = ((str[i] - 'a' + key) % 26) + 'a';
    }
 }
}

Measured memory_bytes: 540
import java.util.Scanner;
class Main{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        
        int h=0,m=0,s=0;
        
        while(n >=3600){
            n -= 3600;
            h++;
        }
        
        while(n >= 60){
            n -= 60;
            m++;
        }
        s = n;
        System.out.println(h+":"+m+":"+s);
        scan.close();
    }
}


Measured memory_bytes: 26252
import java.nio.file.FileSystemLoopException;
import java.text.DecimalFormat;
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.next());
        int M = Integer.parseInt(scanner.next());
        int[][] PY = new int[M][2];
        int[][] PY2 = new int[M][2];
        for (int i = 0; i < M; i++) {
            PY[i][0] = Integer.parseInt(scanner.next());
            PY[i][1] = Integer.parseInt(scanner.next());
            PY2[i][0] = PY[i][0];
            PY2[i][1] = PY[i][1];
        }
        Arrays.sort(PY, Comparator.comparing(x -> x[1]));

        Map<Integer, Integer> m = new HashMap<>();
        Map<Long, Long> ans = new HashMap<>();
        for (int i = 0; i < M; i++) {
            int P = PY[i][0];
            int Y = PY[i][1];
            m.put(P, m.getOrDefault(P, 0) + 1);
            long k = (((long) P) << 32) + Y;
            long v = (((long) P) << 32) + m.get(P);
            ans.put(k, v);
        }

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < M; i++) {
            long k = (((long) PY2[i][0]) << 32) + PY2[i][1];
            long v = ans.get(k);
            sb.append(String.format("%06d%06d", v >> 32, (int) v));
            sb.append('\n');
        }

        System.out.println(sb);
    }

}


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

class UnionFind {
private:
	std::vector<int> pre;
	std::vector<int> siz;
	std::vector<int> rank;
	int cnt;
	int root(int x);
public:
	UnionFind(int n);
	void unite(int x, int y);
	int size(int x);
	bool same(int x, int y);
	int get_cnt();
};

UnionFind::UnionFind(int n) : pre(n), siz(n), rank(n) {
	for (int i = 0; i < pre.size(); ++i) {
		pre.at(i) = i;
		siz.at(i) = 1;
		rank.at(i) = 0;
	}
	cnt = n;
}

int  UnionFind::root(int x) {
	if (pre.at(x) == x) return x;
	else return pre.at(x) = root(pre.at(x));
}

void UnionFind::unite(int x, int y) {
	int root_x = root(x);
	int root_y = root(y);
	if (root_x == root_y) return;
	if (rank.at(root_x) < rank.at(root_y)) {
		siz.at(root_y) += siz.at(root_x);
		pre.at(root_x) = root_y; 
	} 
	else{
		siz.at(root_x) += siz.at(root_y);
		pre.at(root_y) = root_x;
		if (rank.at(root_x) == rank.at(root_y))
			rank.at(x)++;
	}
	cnt--;
}

int UnionFind::size(int x) {
	return siz.at(root(x));
}

bool UnionFind::same(int x, int y) {
	return root(x) == root(y);
}

int UnionFind::get_cnt() {
	return cnt;
}

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

	vector<pair<int, int>> ab(m);
	for (int i = 0; i < m; ++i) {
		cin >> ab.at(i).first >> ab.at(i).second;
		ab.at(i).first--;
		ab.at(i).second--;
	}

	int ans = 0;
	for (int i = 0; i < m; ++i) {
		UnionFind uni(n);
		for (int j = 0; j < m; ++j)
			if (i != j)
				uni.unite(ab.at(j).first, ab.at(j).second);
		if (uni.get_cnt() == 2)
			ans++;
	}

	cout << ans;
}

Measured memory_bytes: 256
import heapq

H,W=map(int,input().split())

mat=[]
for i in range(H):
  array=[x=='.' for x in input()]
  mat.append(array)
#print(mat)

dist=[]
for i in range(H):
  dist.append([-1]*W)

if mat[0][0]:
  dist[0][0]=0
else:
  dist[0][0]=1
  
for i in range(1,H):
  if mat[i-1][0] and not mat[i][0]:
    dist[i][0]=dist[i-1][0]+1
  else:
    dist[i][0]=dist[i-1][0]
    
for j in range(1,W):
  if mat[0][j-1] and not mat[0][j]:
    dist[0][j]=dist[0][j-1]+1
  else:
    dist[0][j]=dist[0][j-1]
    
for i in range(1,H):
  for j in range(1,W):
    if mat[i-1][j] and not mat[i][j]:
      dist1=dist[i-1][j]+1
    else:
      dist1=dist[i-1][j]
    
    if mat[i][j-1] and not mat[i][j]:
      dist2=dist[i][j-1]+1
    else:
      dist2=dist[i][j-1]
      
    dist[i][j]=min(dist1,dist2)
    
#print(dist)
print(dist[H-1][W-1])

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

int main()
{
    int n, k;
    cin >> n >> k;
    double ans;
    for (int i = 1; i <= n; i++)
    {
        int score = i;
        double b = 1.0 / n;
        while (score < k)
        {
            b /= 2;
            score *= 2;
        }
        ans += b;
    }
    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String[] res = new String[N];
        int ac = 0, wa = 0, tle = 0, re = 0;
        for(int i=0; i<N; i++){
            res[i] = sc.next();
            if(res[i].equals("AC")){
                ac++;
            }else if (res[i].equals("WA")){
                wa++;
            }else if(res[i].equals("TLE")){
                tle++;
            }else{
                re++;
            }
        }
        System.out.println("AC x "+ac+"\nWA x "+wa+"\nTLE x "+tle+"\nRE x "+re);
    }
}

Measured memory_bytes: 65708
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

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


int main(){fastio
    
    ll n;cin>>n;
    string s;cin>>s;
    ll ans=1;
    rep(i,1,n)ans=mod(ans*i);
    ll cnt=0;
    rep(i,0,2*n-1){
        if((s[i]=='B')^(cnt%2==0)){
            ans=mod(ans*cnt);
            cnt--;
            if(cnt<0){
                cout<<0<<endl;return 0;
            }
        }else{
            cnt++;
        }
        //cout<<cnt<<" ";
    }
    if(cnt!=0)ans=0;
    cout<<mod(ans)<<endl;
    
    return 0;
}


Measured memory_bytes: 848
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>

using namespace std;
typedef long long ll;

int main()
{
	int N, M;
	cin >> N >> M;
	int ans = 0;
	int X = 1 << M;
	for (int i=0; i<X; i++) {
		ans += (M * 1900) + (N - M) * 100;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
  _map, _range, _int = map, range, int
  n, q = _map(_int, input().split())
  values = [0] * (n + 1)
  parents = [0] * (n + 1)
  for i in _range(n - 1):
    a, b = _map(_int, input().split())
    parents[b] = a
  for _ in _range(q):
    p, x = _map(_int, input().split())
    values[p] += x
  for i in _range(1, n + 1):
    values[i] += values[parents[i]]
  print(*values[1:])
main()


Measured memory_bytes: 25852
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <complex>
//C++11

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-12;
const int MOD = 1000000007;
typedef complex<double> P;
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
  bool operator < (const L& a, const L& b) {
    return a[0] < b[0];
  }
}
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}
bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}
P projection(const L &l, const P &p) {
  double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
  return l[0] + t*(l[0]-l[1]);
}
double distanceSP(const L &s, const P &p) {
  const P r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}
double distanceSS(const L &s, const L &t) {
  if (intersectSS(s, t)) return 0;
  return min(min(distanceSP(s, t[0]), distanceSP(s, t[1])),
             min(distanceSP(t, s[0]), distanceSP(t, s[1])));
}
int main(){
  int N;
  while(cin>>N && N){
    double ans = INF;
    vector<L> ls;
    set<pair<int, int>> check;
    REP(i, N){
      int x1,y1,x2,y2;
      scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
      if(ans == 0) continue;
      if(x1 > x2) {
        swap(x1, x2);
        swap(y1, y2);
      }
      ls.push_back(L(P(x1, y1), P(x2, y2)));
      if((check.count(make_pair(x1,y1)) || check.count(make_pair(x2,y2)))){
        ans = 0;
      }
      check.insert(make_pair(x1, y1));
      check.insert(make_pair(x2, y2));
    }
    sort(ls.begin(), ls.end());
    REP(i, ls.size())FOR(j, i+1, ls.size())if(i != j){
      if(ans == 0) goto OUTPUT;
      if(ans < real(ls[j][0]) - real(ls[i][1])) break;
      ans = min(ans, distanceSS(ls[i], ls[j]));
    }
OUTPUT:
    printf("%.8lf\n", ans);
  }
  return 0;
}

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

std::vector<bool> IsPrime;

void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}

ll q,l,r;
ll s[100010];
bool f[100010];


int main(){
  cin >> q;
  sieve(100010);
  for (int i=0;i<100010;i++){
    if(IsPrime[i]){
      if (IsPrime[(i+1)/2]){
        s[i]=s[i-1]+1;
      }
      else{
        s[i]=s[i-1];
      }
    }
    else{
      s[i]=s[i-1];
    }
  }
  for(int i=0;i<q;i++){
    cin >> l >> r;
    cout << s[r]-s[l-1] << endl;
  }
}

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

int main() {
  int A,B,C,X;
  int count = 0;
  int total = 0;
  
  cin >> A >> B >> C >> X ;
  
  for ( int a = 0; a <= A; a++){
    for ( int b = 0; b <= B; b++){
      for ( int c = 0; c <= C; c++){
        total = 500 * a + 100 * b + 50 * c;
        if ( total == X ){
          count ++;
        }
      }
    }
  }
  
  cout << count << endl;
  
}

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

int main(){
  ll a,b,x;
  cin >> a >> b >> x;
  if(a>0){
    a--;
    ll fa=a/x+1;
    ll fb=b/x+1;
    ll ans=fb-fa;
    cout << ans << endl;
  }else{
    ll ans=b/x+1;
    cout << ans << endl;
  }
  return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int height[] = new int[n];

        for (int i = 0; i < n; i++)
            height[i]=scanner.nextInt();

        int max=0;
        int heightGreaterCount[] = new int[n];
        heightGreaterCount[n-1] = 0;
        for (int i = n-2; i >= 0; i--) {
            if(height[i]>=height[i+1]) {
                heightGreaterCount[i] = heightGreaterCount[i + 1] + 1;
                max = Math.max(heightGreaterCount[i],max);
            }
        }


        System.out.println(max);
    }
}

Measured memory_bytes: 50288
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int memo[90005];
int main()
{
    int h, w, d;
    cin >> h >> w >> d;
    map<int, pair<int, int>> mp;
    rep(i,h){
        rep(j,w){
            int a;
            cin >> a;
            a--;
            mp[a] = make_pair(i, j);
        }
    }
    int q;
    cin >> q;
    vector<int> L(q), R(q);
    rep(i,q){
        cin >> L[i] >> R[i];
        L[i]--;
        R[i]--;
    }
    ll ans = 0;
    rep(i,h*w-d){
        memo[i + d] = memo[i] + abs(mp[i].first - mp[i + d].first) + abs(mp[i].second - mp[i + d].second);
    }
    rep(i,q){
        cout << memo[R[i]] - memo[L[i]] << endl;
    }

}
        


Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double db;
typedef vector<ll> VI;
typedef vector<pair<ll,ll> > VII;
typedef map<ll,ll> mll;
typedef pair<ll,ll> pll;
//
#define M 1000000007
#define INF (ll)0x3f3f3f3f3f3f3f3f
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define itr iterator
#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
void fileioe(){
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout); 
	freopen("error.txt","w",stderr);
}

void error_out() { cerr << endl; }
template <typename Head, typename... Tail>
void error_out(Head H, Tail... T) {
  cerr << " " << H;
  error_out(T...);
}
void time_elapsed(){
  cerr<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
}
#ifndef ONLINE_JUDGE
#define error(...) cerr << "[" << #__VA_ARGS__ << "]:", error_out(__VA_ARGS__)
#define fioe() fileioe()
#define time() time_elapsed()
#else
#define error(...) 1
#define fioe() 1
#define time() 1
#endif
const int maxr=6;
ll arr[maxr],num[maxr];
map<pair<ll,ll>,ll> m,m1;
ll n;
void generate1(ll size,ll ind,ll less){
	if(size==ind){
		ll ind1=0;
		while(arr[ind1]==0 && ind1<size){
			ind1++;
		}
		if(ind1==size||arr[size-1]==0){
			return ;
		}
		m[{arr[ind1],arr[size-1]}]++;
		return ;
	}
	for(ll i=0;i<=9;i++){
		if(less){
			arr[ind]=i;
			generate1(size,ind+1,less);
		}
		else if(i<=num[ind]){
			arr[ind]=i;
			generate1(size,ind+1,less|(arr[ind]<num[ind]));
		}
	}
}
//
int main()
{
	GO
	//fioe();
	cin>>n;
	ll count=0,ref=n,i=0;
	memset(arr,0,sizeof(arr));
	memset(num,0,sizeof(num));
	while(ref>0){
		num[i++]=ref%10;
		ref=ref/10;
		count++;
	}reverse(num,num+count);
	generate1(count,0,0);
	ll finalans=0;
	for(ll i=0;i<=9;i++){
		for(ll j=0;j<=9;j++){
			if(!m1[{i,j}]){
				if(i!=j)
					finalans+=2*m[{i,j}]*m[{j,i}];
				else
					finalans+=m[{i,j}]*m[{j,i}];
				m1[{i,j}]=1;m1[{j,i}]=1;
			}
		}
	}
	cout<<finalans<<endl;
	time();
	return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

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

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

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    V<int> A(N);
    rep(i, N) cin >> A[i];
    for (int i = K; i < N; ++i) {
        if (A[i] > A[i - K]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;


int main(){
    int A,B;
    cin >> A >> B;
    bool j = true;
    
    for(int i = 1;i <= 1000;i++){
        if(A == (int)(i*(0.08)) && B == (int)(i*(0.1))){
            cout << i << endl;
            j = false;
            break;
        }
    }
    if(j){
        cout << -1 << endl;
    }
}


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

int main(){
  int N,Y;
  int list[] = {1000,5000,10000};

  cin >>N>>Y;

  for(int i = 0;i<=N;i++){
      for(int j = 0;j<=N-i;j++){
          if(list[0]*i+list[1]*j+list[2]*(N-i-j) == Y){
              cout <<N-i-j<<" "<<j<<" "<<i<<endl;
              return 0;
          }
      }
  }

  cout <<-1<<" "<<-1<<" "<<-1<<endl;
  return 0;
  }

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

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

  std::string s, t;

  std::cin >> s >> t;

  std::sort(ALL(s));
  std::sort(ALL(t));
  std::reverse(ALL(t));

  std::cout << (s < t ? "Yes" : "No") << std::endl;

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main()
{
    int n;
    cin >>n;
    vector<int> p(n);
    rep(i,n) cin >>p[i];

    int ans = 19191919;
    rep(i,p[0]+1)
    {
        vector<int> v(p);
        v[0] -= i;
        int t = i;

        for(int j=1; j<n; ++j)
        {
            if(v[j-1]>0)
            {
                t += 2*v[j-1];
                v[j] -= v[j-1];
                v[j-1] = 0;
            }
        }
        if(v[n-1]>0) t += v[n-1];

        ans = min(ans,t);
    }

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

Measured memory_bytes: 3192
#!/usr/bin/env ruby

inputs = Array.new
while input = STDIN.gets
	inputs.push input
end

outputs = ["EQUAL","GREATER","LESS"]

if inputs[0].length < inputs[1].length
	result = -1
elsif inputs[0].length > inputs[1].length
	result = 1
elsif inputs[0].length == inputs[1].length
	result = inputs[0] <=> inputs[1]
end

puts outputs[result]


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

int main(){
	int n, k, x = 1;
	cin >> n >> k;
	for(int i=0; i < n; i++) {
		if(x*2 <= x+k)
			x *= 2;
		else
			x += k;
	}
	cout << x << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
double dp[102][102];
//i???????????????j????????????????????¨????????´????????§???????¢????
int N, T, L, B;
bool lose[101], back[101];
double dfs(int turn, int masu){
    if(dp[turn][masu] != -1.0) return dp[turn][masu];
    if(masu == N) return dp[turn][masu] = 1.0;
    if(turn >= T) return dp[turn][masu] = 0.0;
    if(back[masu]) return dp[turn][masu] = dfs(turn, 0);
    int nxturn = turn + 1;
    if(lose[masu]) nxturn++;
    dp[turn][masu] = 0.0;
    REP(i, 1, 7){
        int nxmasu = masu + i;
        if(nxmasu > N) nxmasu = 2 * N - nxmasu;
        dp[turn][masu] += dfs(nxturn, nxmasu) / 6.0;
    }
    return dp[turn][masu];
}
int main(){
    while(cin >> N >> T >> L >> B && N){
        rep(i, T + 1) rep(j, N + 1) dp[i][j] = -1.0;
        memset(lose, 0, sizeof(lose));
        memset(back, 0, sizeof(back));
        rep(i, L){
            int a; scanf("%d", &a);
            lose[a] = true;
        }
        rep(i, B){
            int a; scanf("%d", &a);
            back[a] = true;
        }
        printf("%.6f\n", dfs(0, 0));
    }
    return 0;
}

Measured memory_bytes: 1352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
#define repr(i,a,n) for (int i=a;i<n;i++)
#define rrep(i,a,n) for (int i=n-1;i>=a;i--)
#define all(cont) cont.begin(), cont.end()
#define unique(a)  sort(all(a)) , (a).erase(unique((a).begin(), (a).end()),(a).end())
#define rall(cont) cont.rbegin(), cont.rend()
#define sz(x) (int)(x).size()
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define fi first
#define se second
#define mod 1000000007
const int N = 2e5 + 5;
#define PI acos(-1.0)
typedef long long ll;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
#define pqll_max priority_queue<ll> // max heap. push(),pop(),top(),size(),empty()
#define pqll_min priority_queue<ll,vector<ll>,greater<ll> >
#define lb(v,val)   lower_bound(v.begin(),v.end(),val) //first equal to or lower than [------------
#define ub(v,val)   upper_bound(v.begin(),v.end(),val) //first greater than ------------)
#define bs(v,x) binary_search(v.begin(),v.end(),x)
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x; }
inline ll sub(ll a, ll b) { if (a < b)swap(a, b); return (((a%mod) - (b%mod) + mod) % mod); }
inline ll mul(ll x, ll y) { return (x%mod * 1ll * y%mod) % mod; }
inline ll pwr(ll a, ll b) { ll x = 1 % mod; while (b) { if (b & 1) x = mul(x, a); a = mul(a, a); b >>= 1; }return x % mod; }
inline ll inv(ll a) { return pwr(a, mod - 2) % mod; }
ll gcd(ll a, ll b) { if (!a)return b % mod; return gcd(b%a, a) % mod; }
#define debug(x) cout << #x << " = " << x << endl;
#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...);
}
#define in(container) for (auto &it : container) cin>>it;
#define out(container) for (auto it : container) cout << it << " "; cout << endl;

void solve() {
	int lim;
	cin >> lim;
	int ans = 0;
	for (int i = 1; i <= lim; i++) {
	if (i == 1) {
			ans += pow(lim,2);
			continue;
		}
		for (int j = 1; j <= lim; j++) {
		/*	if (j == 1) {
				ans += 1;
				continue;
			}*/
			if (gcd(i, j) == 1) {
				ans += lim;
				continue;
			}
			for (int k = 1; k <= lim; k++) {
				/*if (k == 1) {
					ans += 1;
					continue;
				}*/
				ans += gcd(i, gcd(j, k));
			}
		}
	}
	cout << ans << endl;
}

signed main()
{
	int tc;
	tc = 1;
	//	cin >> tc;
	while (tc--) {
		solve();
	}


}

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

int main() {
    int n, k;
    cin >> n >> k;
    
    vector<int> data(n);
    for(int i = 0 ; i < n ; i++){
        cin >> data.at(i);
    }
    sort(data.begin(), data.end());

    int sum = 0;
    for(int i = 0 ; i < k ; i++){
        sum += data.at(i);
    }
    cout << sum << endl;
}


Measured memory_bytes: 3596
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try(Scanner scn = new Scanner(System.in)) {
            int w;
            int h;
            while((w = scn.nextInt()) > 0 | (h = scn.nextInt()) > 0) {
                int[][] fld = new int[h][w];
                for(int y = 0; y < h; y++) {
                    for(int x = 0; x < w; x++) {
                        fld[y][x] = scn.nextInt();
                    }
                }
                System.out.println(new Area(fld).count());
            }
        }
    }
}

class Area {
    private int[][] fld;

    Area(int[][] fld) {
        this.fld = fld;
    }

    int count() {
        int rslt = 0;
        for(int y = 0; y < fld.length; y++) {
            for(int x = 0; x < fld[y].length; x++) {
                if(fld[y][x] > 0) {
                    rslt++;
                    sink(y, x);
                }
            }
        }
        return rslt;
    }

    private void sink(int y, int x) {
        try {
            if(fld[y][x] > 0) {
                fld[y][x] = 0;
                int[][] vector = {
                    {-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}
                };
                for(int i = 0; i < 8; i++) {
                    sink(y + vector[0][i], x + vector[1][i]);
                }
            }
        } catch(ArrayIndexOutOfBoundsException ignore) {}
    }
}

Measured memory_bytes: 46532