akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main()
{
    int n;
    int a[5000];
    while (cin >> n && n)
    {
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
        }
        int max = a[0];
        int S[5000];
        S[0] = a[0];
        for (int i = 1; i < n; i++)
        {
            S[i] = S[i - 1] + a[i];
        }
        for (int l = 0; l < n; l++)
        {
            for (int r = l; r < n; r++)
            {
                int sum = 0;
                if (l != 0)
                {
                    sum = S[r] - S[l - 1];
                }
                else
                {
                    sum = S[r];
                }

                if (sum > max)
                {
                    max = sum;
                }
            }
        }
        cout << max << endl;
    }
}



Measured memory_bytes: 3116
#include<iostream>
#include<string>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)
const int INF=1e9;
using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int n;
  cin>>n;
  int a[n];
  rep(i,0,n) cin>>a[i];
  int ans=a[0];
  rep(i,1,n) ans=__gcd(ans,a[i]);
  cout<<ans<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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(){
    int a[3][3];
    REP(i,3){
        REP(j,3){
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    int b[n];
    REP(i,n){
        cin >> b[i];
    }
    REP(k,n){
        REP(i,3){
            REP(j,3){
                if(b[k]==a[i][j]){
                    a[i][j]=0;
                }
            }
        }
    }
    string ans="No";
    if(a[0][0] +a[0][1] +a[0][2] == 0){ans = "Yes";}
    else if(a[1][0] +a[1][1] +a[1][2] == 0){ans = "Yes";}
    else if(a[2][0] +a[2][1] +a[2][2] == 0){ans = "Yes";}
    else if(a[0][0] +a[1][0] +a[2][0] == 0){ans = "Yes";}
    else if(a[0][1] +a[1][1] +a[2][1] == 0){ans = "Yes";}
    else if(a[0][2] +a[1][2] +a[2][2] == 0){ans = "Yes";}
    else if(a[0][0] +a[1][1] +a[2][2] == 0){ans = "Yes";}
    else if(a[0][2] +a[1][1] +a[2][0] == 0){ans = "Yes";}

    cout << ans << endl;



}

Measured memory_bytes: 256
read_flag = True
while  read_flag:
    x, y = list(map(int, input().split()))
    if x == 0 and y  == 0:
        read_flag = False
        break
    ans = 0
    for i in range(1, y//3 + 1):
        for j in range(i+1, y):
            if j >= y - i -j:
                break
            if y - i - j > x:
                continue
            ans += 1
    print(ans)
        



Measured memory_bytes: 5592
n = int(input())
s = input().split(" ")
nums = list(map(int,s))
flag = 1
koukan = 0
while flag:
    flag = 0
    for i in range(n-1, 0, -1):
        if nums[i] < nums[i-1]:
            w = nums[i]
            nums[i] = nums[i-1]
            nums[i-1] = w
            koukan += 1
            flag = 1
for i in range(n):
    if i == n-1:
        print(nums[i])
    else:
        print(nums[i],end=" ")
print(koukan)

Measured memory_bytes: 7692
/**
*    created: 28.07.2020 20:30:00
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dx2[8] = {0, 1, 0, -1, 1, 1,-1, -1};
const int dy2[8] = {1, 0,-1, 0, 1, -1, 1, -1};
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n; cin >> n;
    vector<int> a(n);
    int sum = 0;
    int e = 0;
    rep(i,n) {
        cin >> a[i];
        sum += a[i];
        if (i % 2 == 1) e += a[i];
    }
    vector<int> b(n);
    rep(i,n) {
        if (i == 0) b[i] = sum - 2 * e;
        else b[i] = 2 * a[i-1] - b[i-1];
    }
    rep(i,n) {
        if (i == 0) cout << b[i];
        else cout << " " << b[i];
    }
    cout << endl;
    return 0;
}

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

int main(){
  int N ; 
  cin >> N ; 
  vector<int> P(N) , Q(N) ,A(N); 
  int a = 0  , b = 0  ; 
  int cnt = 1 ; 
  
  
  for(int i = 0 ; i < N ; i++){
    cin >> P.at(i) ; 
    A.at(i) = i+1 ; 
  }
  
  for(int i = 0 ; i < N ; i++){
    cin >> Q.at(i) ; 
  }

  
  do{
      int  cnt1 = 0 , cnt2 = 0  ;
      for(int j = 0 ; j < N ; j++){
        if(A.at(j) == P.at(j)){
         cnt1++ ; 
        }
      }
      if(cnt1 == N){
        a = cnt ; 

      }
      
      for(int j = 0 ; j < N ; j++){
        if(A.at(j) == Q.at(j)){
          cnt2++ ; 
        }
      }  
      if(cnt2 == N){
         b = cnt ;  
      }      
    
    cnt++ ; 

  }while (next_permutation( A.begin() , A.end() ) );

    cout << abs(a - b ) << endl ; 
}

Measured memory_bytes: 3608
#include <iostream>
#include <map>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;

int main(){
  string S, T;
  cin >> S >> T;
  //ここまで入力

  //換字表と，各アルファベットを割り当てたか
  char table[26];
  bool allc[26];
  rep(i, 26){
    table[i] = -1;
    allc[i] = false;
  }

  //換字表の作成
  rep(i, S.size() )
    //T[i]がまだ割り当てられていなければ
    if(allc[T[i]-'a']  == false ){
      //S[i]にT[i]を割り当て
      table[S[i]-'a' ] = T[i];
      //T[i]の割り当てフラッグ更新
      allc[T[i]-'a' ] = true;
    }
  
  //換字表に従って文字列Sの書き換え
  rep(i, S.size() )
    S[i] = table[S[i]-'a' ];

  //文字列Sと文字列Tの比較
  rep(i, S.size() )
    if(S[i] != T[i]){
      cout << "No" << endl;
      return 0;
    }
  
  //上のループを抜ければS=Tになっている
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 776
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
int n,m,tag[101000],dep[101000],s[2],sum[101000];
ll ans;
vector<int> e[101000];
void dfs(int x,int deep,int p){
	dep[x]=deep;
	sum[p]++;
	for(int&v:e[x])
		if(!dep[v]) dfs(v,deep+1,p);
		else if(dep[v]%2==dep[x]%2) tag[p]=1;
}
int main(){
	read(n);read(m);
	for(int i=1;i<=m;i++){
		int x,y;
		read(x);read(y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	int res=0;
	for(int i=1;i<=n;i++)
		if(!dep[i]){
			dfs(i,1,i);
			if(sum[i]==1) res++;
			else s[tag[i]]++;
		}
	ans+=1ll*s[1]*s[1]+2ll*s[1]*s[0]+2ll*s[0]*s[0]+1ll*res*res+2ll*res*(n-res);
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 11264
#include<iostream>

using namespace std;

const int INF = (1 << 25);
const int MAX = 50;
int data[MAX][MAX];
int w,h;

void solve(){
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(i-1 >= 0 && j-1 >= 0)
	data[i][j] = min(data[i-1][j]+data[i][j],data[i][j-1]+data[i][j]);
      else if(i-1 >= 0)
	data[i][j] += data[i-1][j];
      else if(j-1 >= 0)
	data[i][j] += data[i][j-1];
    }
  }
}
int main(){

  cin >> h >> w;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      char c;
      cin >> c;
      data[i][j] = c-'0';
    }
  }
  solve();
  cout << data[h-1][w-1] << endl;
  return 0;
}

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

using namespace std;

int main(){
	int n;
	cin>>n;
	string s,s2;
	cin>>s>>s2;
	string s3="";
	for(int i=0;i<n;i++){
		s3=s3+s[i];
		s3=s3+s2[i];
	}
	cout<<s3;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int Sum(const string&s){
  int n = (int)s.size();
  int sum = 0;
  for(int i = 0; i < n; ++i)sum += s[i] - '0';
  return sum;
}

int main(){
  vector<int> v(3); cin >> v;
  sort(v.begin(), v.end());
  cout << (v[0]+v[1] == v[2] ? "Yes" : "No") << endl;
}


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

int main() {
  string S;cin>>S;
  int high=S[0]*10+S[1] -'0'*10-'0';
  int low=S[2]*10+S[3] -'0'*10-'0';
  bool high_month = false;
  bool low_month = false;
  if (1 <= high && high <= 12) {
    high_month = true;
  }
  if (1 <= low && low <= 12) {
    low_month = true;
  }

  cerr<<high<<" "<<low<<endl;

  if (low_month && high_month) {
    cout<<"AMBIGUOUS"<<endl;
    return 0;
  }
  if (low_month) {
    cout<<"YYMM"<<endl;
    return 0;
  }
  if (high_month) {
    cout<<"MMYY"<<endl;
    return 0;
  }
  cout<<"NA"<<endl;
  return 0;
}



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

using namespace std;

int main()
{
	int A1, B1, C1, D1, A2, B2, C2, D2;

	cin >> A1 >> B1 >> C1 >> D1 >> A2 >> B2 >> C2 >> D2;

	cout << max(A1 + B1 + C1 + D1, A2 + B2 + C2 + D2) << endl;

	return 0;
}

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

using namespace std;

int main()
{
    //freopen("test.inp","r",stdin);
    int i, n, t = 0, tmp, j, k;
    int a[100001], b[100001], s[100001] = {0};
    cin >> n >> k;
    for (i = 1; i <= n; i++) cin >> a[i];
    for (i = 2; i <= n; i++)
    {
        tmp = s[i-1]+abs(a[i-1]-a[i]);
        for (j = i-2; j >= max(1, i-k); j--)
            tmp = min(s[j] + abs(a[j] - a[i]), tmp);
        s[i] = tmp;
    }
    cout << s[n] << endl;
    //for (i = t; i >= 1; i--) cout << b[i] << " ";
    return 0;
}

Measured memory_bytes: 1024
def gcd(a0, b0):
    a, b = max(a0, b0), min(a0, b0)
    while b != 0:
        a = a % b
        a, b = b, a

    return a


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    if n == 1:
        if k in a:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")
    
    else:
        g = gcd(a[0], a[1])
        for i in range(2, len(a)):
            g = gcd(a[i], g)

        if k % g == 0 and k <= max(a):
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")


if __name__ == '__main__':
    main()


Measured memory_bytes: 14252
#!/usr/bin/env python3
import sys

def solve(S: str):
    stack = [-1]
    for c in map(int, S):
        if stack[-1] + c == 1:
            stack.pop()
            continue
        stack.append(c)
    return len(S)-len(stack)+1

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    print(solve(S))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 9856
#include<stdio.h>

int main(void){


int a,b,c;


int count=0;


int i;


scanf("%d %d %d",&a,&b,&c);


for(i=a;i<=b;i++)


{


if(c%i==0) count++;


}


printf("%d\n",count);


return 0;


}

Measured memory_bytes: 596
#include <stdio.h>
int main(void){
  char s[3], t[3];
  int i = 0, sum = 0;
  scanf("%s", &s);
  scanf("%s", &t);
  for(i = 0; i < 3; i++){
    if (s[i] == t[i]) {
      sum++;
    }
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define L_T_S_k ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
using namespace std;
const int mod = 1e9 + 7;
const int N = 1e5 + 7;
int dp[(1 << 25)];

int add(int a , int b){
  return (a % mod + b % mod) % mod;
}
int32_t main(){
  int n;
  cin >> n;
  int mat[n][n];
  for(int i = 0 ; i < n ; i ++){
    for(int j = 0 ; j < n ; j++){
      cin >> mat[i][j];
    }
  }
  dp[0] = 1;
  for(int mask = 0 ; mask < (1 << n) ; ++mask){
    int a = __builtin_popcount(mask);
    for(int i = 0 ; i < n ; i++){
      if(mat[a][i] and !(mask & (1 << i))){
        int newMask = mask ^ (1 << i);
        dp[newMask] = add(dp[newMask] , dp[mask]);
      }
    }
  }
  cout << dp[(1 << n) - 1] << "\n";
  return 0;
}

Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define l 1000000007
#define INF 1000000;
char S[50][50];
int H,W;
int roads = 0;
int d[50][50];
int dx[4] = {1,0,-1,0},dy[4]={0,1,0,-1};
int calu(){
    queue<pair<int,int>> que;
    for(int a = 0;a < H;a++){
        for(int b = 0;b < W;b++){
            d[a][b] = INF;
        }
    }
    que.push(make_pair(0,0));
    d[0][0]=0;
    while (que.size()) {
       pair<int,int> p = que.front();que.pop();
       if(p.first==H&&p.second==W)break;
       for(int a = 0;a < 4;a++){
           int nx = p.first+dx[a],ny = p.second+dy[a];
           if(0<=nx&&nx<W&&0<=ny&&ny<H){
               if(S[ny][nx]!='#'&&d[ny][nx]==1000000){
                   que.push(make_pair(nx,ny));
                   d[ny][nx]=d[p.second][p.first]+1;
               }
           }
       }
    }
    return d[H-1][W-1];
}
int main()
{
    cin >> H >> W;
    for(int a = 0;a < H;a++){
        for(int b = 0;b < W;b++){
            cin >> S[a][b];
        }
    }
    int e = 0;
    for(int a = 0;a < H;a++){
        for(int b = 0;b < W;b++){
            if(S[a][b]=='.')e++;
        }
    }
    int w = calu();
    if(w!=1000000){
    cout<<e-w-1<<endl;
    }else{
        cout<<-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
const int inf = 1012345678;
int n, a[309][309], sa[309][309], s[309], t[309], st[309], r[309];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
			sa[i][j + 1] = sa[i][j] + a[i][j];
		}
	}
	int ret = -inf;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j <= n; j++) {
			for (int k = 0; k < n; k++) {
				s[k] = sa[k][j] - sa[k][i];
				t[k] = (j - i >= 2 ? a[k][i] + a[k][j - 1] : a[k][i]);
				st[k + 1] = st[k] + t[k];
				r[k] = st[k] + s[k];
			}
			int p = -inf;
			for (int k = 0; k < n; k++) {
				ret = max(ret, r[k] + p);
				ret = max(ret, s[k]);
				p = max(p, s[k] - st[k + 1]);
			}
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3836
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long LL;
const int mod=1000000007;

int mul(int x,int k){
	LL ans=1,mid=x;
	while(k)
	{
		if(k&1) ans=ans*mid%mod;
		mid=mid*mid%mod;
		k>>=1;
	}
	return ans;
}

int main()
{
	int N,M,K;
    LL ans1=1,ans2=1;
    scanf("%d%d%d",&N,&M,&K);
	int u=N*M;
    N+=M,M=u;
	
    for(int i=0;i<K-2;++i)
	{
		ans1=ans1*(i+1)%mod;
		ans2=ans2*(M-2-i)%mod;
	}
	ans2=ans2*mul(ans1,mod-2)%mod;
	ans2=ans2*mul(6,mod-2)%mod*M%mod*N%mod*(M-1)%mod;
	printf("%lld\n",ans2);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int n,m;// 頂点、辺
ll dist[333][333];
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  m = n * n;
  FOR(i, 1, n + 1){
    FOR(j, 1, n + 1) {
      cin >> dist[i][j];
    }
  }
  ll ans = 0;
  FOR(i, 1, n + 1){
    FOR(j, i + 1, n + 1) {
      bool use = true;
      FOR(k, 1, n + 1) {
        if(i == j || k == i || k == j) continue;
        if(dist[i][j] > dist[i][k] + dist[k][j]) {
          cout << -1 << endl;
          return 0;
        }
        if(dist[i][j] == dist[i][k] + dist[k][j]){
          use = false;
        }
      }
      if(use) ans += dist[i][j];
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
	char a[11], b[11], c[11];
	int d, e;
	scanf("%s %s\n", &a, &b);
	scanf("%d %d\n", &d, &e);
	scanf("%s", &c);
	
	if(strcmp(a, c) == 0) {
		printf("%d %d", d-1, e);
	}
	else if(strcmp(b, c) == 0){
		printf("%d %d", d, e-1);
	}
return 0;
}

Measured memory_bytes: 3128
/*
一个有向图, 对每一条边查询反向后强连通块的数目是否改变
*/
#include<bits/stdc++.h>
using namespace std;

const int N=3003;
const int M=2e5+5;

int n,m,v[M],u[M],F[N][N][3];

bool vis[N];

struct node{
	int id,v;
};

vector<node>Link[N];

void dfs(int x,int fa,int Id,int sta){
	vis[x]=1;F[fa][x][sta]=Id;
	int Len=Link[x].size();
	for(int i=0;i<Len;i++)
		if(!vis[Link[x][i].v])
			dfs(Link[x][i].v,fa,Id,sta);
}

void sol(int x){
	int Len=Link[x].size();
	memset(vis,0,sizeof(vis));
	vis[x]=1;
	for(int i=0;i<Len;i++)
		if(!vis[Link[x][i].v])
			dfs(Link[x][i].v,x,Link[x][i].id,0);
	reverse(Link[x].begin(),Link[x].end());
	memset(vis,0,sizeof(vis));
	vis[x]=1;
	for(int i=0;i<Len;i++)
		if(!vis[Link[x][i].v])
			dfs(Link[x][i].v,x,Link[x][i].id,1);
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&u[i],&v[i]);
		Link[u[i]].push_back((node){i,v[i]});
	}
	for(int i=1;i<=n;i++) sol(i);
	for(int i=1;i<=m;i++){
		if((F[v[i]][u[i]][0]>0)^(F[u[i]][v[i]][0]!=i||F[u[i]][v[i]][1]!=i))
			printf("diff\n");
		else 
			printf("same\n");
	}
	return 0;
}

Measured memory_bytes: 42880
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int main() {
	int N;
	scanf("%d", &N);

	if (N == 3) {
		printf("2 5 63 ");
		return 0;
	}
	else if (N == 4) {
		printf("2 4 3 9 ");
		return 0;
	}

	vector<int> Two, Three, Six, Ans;
	rep(i, 15000) {
		if ((i + 1) % 3) Two.push_back((i + 1) * 2);
		else Six.push_back((i + 1) * 2);
	}
	rep(i, 5000) Three.push_back((i * 2 + 1) * 3);

	if (N <= 4 + 9998 + 1) {
		//2, (6)
		Ans.push_back(2);
		Ans.push_back(4);
		Ans.push_back(3);
		Ans.push_back(9);
		for (int i = 0; i < (N - 4) / 2; i++) {
			Ans.push_back(Two[(i + 1) * 2]);
			Ans.push_back(Two[(i + 1) * 2 + 1]);
		}
		if (N % 2) Ans.push_back(6);
		rep(i, Ans.size()) printf("%d ", Ans[i]);
		return 0;
	}
	else if (N <= 4 + 9998 + 4998 + 1) {
		//All 2, 3, (6)
		Ans = Two;
		Ans.push_back(3);
		Ans.push_back(9);
		for (int i = 0; i < (N - (4 + 9998)) / 2; i++) {
			Ans.push_back(Three[(i + 1) * 2]);
			Ans.push_back(Three[(i + 1) * 2 + 1]);
		}
		if (N % 2) Ans.push_back(6);
		rep(i, Ans.size()) printf("%d ", Ans[i]);
		return 0;
	}
	else {
		//All 2, All 3, 6
		Ans = Two;
		Ans.insert(Ans.end(), Three.begin(), Three.end());
		rep(i, N - 15000) Ans.push_back(Six[i]);

		rep(i, Ans.size()) printf("%d ", Ans[i]);
		return 0;
	}
}


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

int main(){
  int N;
  cin >> N;
  vector<int> V(N);
  for (int i = 0; i < N; i++) cin >> V[i];
  int maior = 0, C = 0;
  for (int i = 0; i < N; i++){
    if (V[i] >= maior){
      maior = max(maior, V[i]);
      C++;
    }
  }
  cout << C << '\n';
}

Measured memory_bytes: 256
def gcd(x,y):
    if y==0:
        return x
    return gcd(y,x%y)

MOD = 10**9+7
N = int(input())
A = list(map(int,input().split()))
lcm = 1
for i in A:
    lcm = (lcm*i)//gcd(lcm,i)
lcm %= MOD
ans = 0
for i in A:
    ans += lcm*pow(i,MOD-2,MOD)
    ans %= MOD
print(ans)


Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for (int i = 0; i < r; i++)
#define repeq(i,r) for (int i = 0; i <= r; i++)
#define isc(n) scanf("%d", &n)

int main() {
  int N; isc(N);
  string res = "No";
  if (N / 100 == 7) res = "Yes";
  if (N % 100 / 10 == 7) res = "Yes";
  if (N % 10 == 7) res = "Yes";
  cout << res << endl;
  return 0;
}


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

int main(){
  int n, k, c;
  cin >> n >> c >> k;

  vector<int> t(n);
  rep(i, n) cin >> t[i];
  sort(t.begin(), t.end());
  t.push_back(1e9+1);

  int start;
  int ans = 0;
  int count = 0;
  start = t[0];
  rep(i, n){
    ++count;
    if (((start + k) < t[i+1]) || (count >= c)){
      start = t[i+1];
      count = 0;
      ++ans;
    }
  }
  if (count != 0) ++ans;
  cout << ans << endl;
  return 0;
}

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

int main()
{
    int a[20],i,j;

    for(i=0; i<10; i++)
    {
        cin >> a[i];
    }

    for(i=0; i<10; i++)
    {
        j = i;
        while(a[j]>a[j-1] && j)
        {
            int tmp = a[j-1];
            a[j-1] = a[j];
            a[j--] = tmp;
        }
    }
    cout << a[0] << endl << a[1] << endl << a[2] << endl;

    return 0;
}

Measured memory_bytes: 1160
#include"iostream"
using namespace std;

int main()
{
	int n;
	cin >> n;
	int sum = 0;
	for (int i = 0; i < 8; i++)
	{
		sum += n - (n / 10) * 10;
		n = n / 10;
	}
	cout << (sum == 1 ? 10 : sum) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
int cmpfunc(const void*a,const void*b){
    return(*(int*)a-*(int*)b);
}
int main()
{
    int n,m,sum=0,temp,count=0;
    scanf("%d %d",&n,&m);
    int a[n];
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
        a[i]*=(4*m);
    }
    qsort(a,n,sizeof(int),cmpfunc);
    for(int i=n-1;i>=0;i--)
    {
        if(a[i]>=sum)
        count++;
        else
        break;
    }
    if(count>=m)
    printf("Yes\n");
    else
    printf("No\n");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;int p[1024][1<<17],v[1<<19],w[1<<19],q,a,l,i;int f(int a,int l){if(l<0)return -1e9;if(!a)return 0;if(a>1023)return max(f(a/2,l),f(a/2,l-w[a])+v[a]);if(~p[a][l])return p[a][l];return p[a][l]=max({f(a/2,l),f(a,l-1),f(a/2,l-w[a])+v[a]});};int main(){memset(p,-1,1<<29);cin>>l;for(;i++<l;)cin>>v[i]>>w[i];cin>>q;while(q--){cin>>a>>l;cout<<f(a,l)<<" ";}}

Measured memory_bytes: 537688
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iterator>
#include <typeinfo>
using namespace std;


// define list


namespace  math{
    const double PI = 3.14;
    const int INF = 1000000007;
    int GCM(int a,int b); //最大公約数
    int LCM(int a,int b); //最小公倍数
    int Pemu(int n,int r); //順列
    int Comb(int n,int m); //組み合わせ
    
    int GCM(int a,int b){
        if(a<b){
            swap(a,b);
        }
        int r = a%b;
        while (r!=0)
        {
            a=b;
            b=r;
            r=a%b;
        }
        return b;
    }

    int LCM(int a,int b){
        return a*(b/GCM(a,b));
    }

    int Pemu(int n,int r){
        int ans = n;
        for(int i=1;i<r;i++){
            ans*=(ans-i);
        }
        return ans;
    }

    int Comb(int n,int m){
        int a=n,b=m;
        for(int i=1;i<m;i++){
            a *= (a-i);
        }
        for(int i=1;i<m;i++){
            b *= (b-i);
        }
        
        return a/b;
    }
}

namespace SubLib{
    #define int long long
    #define double long double
    #define incin(n) int (n); cin >> (n);
    #define incin2(a,b) int a,b; cin >> a >> b; 
    #define rap(n,i) for(int (i) = 0;i<(n);(i)++)
    #define input(n,v) (v) = SubLib::Input((n),(v))
    #define all(v) (v).begin(),(v).end()
    using intv = vector<int>;
    using strv = vector<string>;
    using charv = vector<char>;
    template <class T1>
    using pvec = vector<pair<T1,T1>>;
    template <typename T> vector<T> Input(int n,vector<T> v){
        for(int i=0;i<n;i++){
            cin >> v.at(i);
        }
        return v;
    }
}

using namespace math;
using namespace SubLib;

signed main(){
    string o,e,pass;
    cin >> o >> e ;
    int i  = 0;
    while (true)
    {
        pass.push_back(o[i]);
        if(pass.size()==o.size()+e.size()){
            break;
        }
        pass.push_back(e[i]);
         if(pass.size()==o.size()+e.size()){
            break;
        }
        i++;
    }
    cout<<pass<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int w = sc.nextInt();
            int n = sc.nextInt();
            int[] values = new int[w];
            for (int i = 0; i < values.length; i++) {
                values[i] = i + 1;
            }
            for (int i = 0; i < n; i++) {
                String str = sc.next();
                String[] ab = str.split(",");
                int a = Integer.parseInt(ab[0]) - 1;
                int b = Integer.parseInt(ab[1]) - 1;
                int temp;
                temp = values[a];
                values[a] = values[b];
                values[b] = temp;
            }
            for (int i = 0; i < w; i++) {
                System.out.println(values[i]);
            }
        }
    }
}




Measured memory_bytes: 26036
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

const ll INF = 5e18;
ll a, b, c, d;
map<ll, ll> memo;
ll f(ll x) {
    if (x == 0) return 0;
    if (x == 1) return d;
    if (memo.count(x)) return memo[x];
    ll res = INF;
    if (x < res / d) chmin(res, x * d);
    rep(i, 3) {
        int mul = vi{2, 3, 5}[i];
        ll cost = vll{a, b, c}[i];
        if (x % mul == 0) {
            chmin(res, f(x / mul) + cost);
        } else {
            ll down = x / mul;
            chmin(res, f(down) + cost + d * (x - mul * down));
            ll up = down + 1;
            chmin(res, f(up) + cost + d * (up * mul - x));
        }
    }
    return memo[x] = res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int t;
    cin >> t;
    while (t--) {
        ll n;
        cin >> n;
        cin >> a >> b >> c >> d;
        cout << f(n) << endl;
        memo.clear();
    }
}

Measured memory_bytes: 4444
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<vector>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define FOR(i,s,e) for (int i=s;i<e;i++)
#define FOE(i,s,e) for (int i=s;i<=e;i++)
#define FOD(i,s,e) for (int i=s;i>=e;i--)
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define LD long double
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>
#define PLI pair<LL,int>
#define PIL pair<int,LL>
#define PLL pair<LL,LL>
#define eps 1e-9
 
int ans,x;
long long n,a,b,c,p[12];

int main () {
 	ans=12;
	scanf("%lld",&n);
	p[0]=1;
	FOE(i,1,12){
	  p[i]=p[i-1]*10;	
	}
	FOE(i,1,floor(sqrt(n))){
		if (n%i==0) {
			++x;
			a=i;
			b=n/i;
			if (a>b) c=a;
			else c=b;
			FOE(j,0,11){
				if ((c>=p[j]) and (c<p[j+1])) {
					if (j+1<ans) {
						ans=j+1;	
					}
				}
			}
		}
	}
	printf("%d\n",ans);
	return 0;	
}

Measured memory_bytes: 128
from scipy.sparse.csgraph import dijkstra, csgraph_from_dense
xs,ys,xg,yg = map(int, input().split())
N = int(input())
xyr = [(xs,ys,0)]
xyr.extend([list(map(int, input().split())) for i in range(N)])
xyr.append((xg,yg,0))
graph = [[0] * (N+2) for _ in range(N+2)]

max_val = 10**9

for i in range(N+2):
    graph[i][i] = max_val

for i in range(N+2):
    for j in range(i+1,N+2):
        x1,y1,r1 = xyr[i]
        x2,y2,r2 = xyr[j]
        d = max(0, ((x1-x2)**2 + (y1-y2)**2) ** 0.5 - r1 - r2)
        graph[i][j] = graph[j][i] = d

g = csgraph_from_dense(graph,null_value=max_val)
print(dijkstra(g,indices=0)[-1])

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

char s[3000] ;

int main()
{
    #ifdef insomnia
    //freopen("in.txt","r",stdin) ;
    //freopen("out.txt","w",stdout) ;
    #endif // insomnia
    while(~scanf("%s",s)){
        int l = strlen(s) ;
        printf("%c%d%c\n",s[0],l-2,s[l-1]) ;
    }
    return 0 ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll                 long long
#define LL                 long long
#define pii                pair<int, int>
#define pll                pair<ll, ll>
#define pil                pair<int, ll>
#define pli                pair<ll, int>
#define vi                 vector<int>
#define vl                 vector<ll>
#define vii                vector<pii>
#define vll                vector<pll>
#define vil                vector<pil>
#define vli                vector<pli>
#define pb                 push_back
#define mp                 make_pair
#define ff                 first
#define ss                 second
#define sz(x)              (int)x.size()
#define TN                 typename
#define all(v)             v.begin(), v.end()
#define fill(a, b)         memset(a, b, sizeof(a))
#define endl               '\n'
#define Int                in()
#define Long               Lin()
#define policy_set         tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define policy_multiset    tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>

template <TN T> T gcd(T a, T b) {return !b ? a : gcd(b, a % b);}
template <TN T> T lcm(T a, T b) {return a * (b / gcd(a, b));}
template <TN T> inline void smin(T &a, T b) {a = a < b ? a : b;}
template <TN T> inline void smax(T &a, T b) {a = a > b ? a : b;}

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", " ;
    err(++it, args...);
}

inline int in() {int n; scanf("%d", &n); return n;}
inline ll Lin() {ll n; scanf("%lld", &n); return n;}
inline double Din() {double n; scanf("%lf", &n); return n;}

const int mod        = (int)1e9 + 7;
const ll  Mod        = (ll)1e9 + 7;

inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (ll)a * b % mod;}

const int inf        = (int)2e9 + 5;
const ll  Inf        = (ll)1e18 + 5;
const int N          = 2e5 + 5;



int solve() {
    ll n;
    cin>>n;
    ll ans=0;
    for (int i = 1; i < n; i++) {
    	ans+=(n-1)/i;
    }
    cout<<ans<<endl;
    return 0;
}

int main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL);
    int test = 1, tc = 0;
    //scanf("%d", &test);
    //cin >> test;
    while (test--) {
        //printf("Case %d: ", ++tc);
        solve();
    }
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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; }

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

struct mint {
    long long x;
    mint(long long x=0):x(x % MOD + (0 <= x ? 0 : MOD)) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint& a) { if ((x += a.x) >= MOD) x -= MOD; return *this; }
    mint& operator-=(const mint& a) { if ((x -= a.x) < 0) x += MOD; return *this; }
    mint& operator*=(const mint& a) { (x *= a.x) %= MOD; return *this; }
    mint operator+(const mint& a) const { return mint(x) += a; }
    mint operator-(const mint& a) const { return mint(x) -= a; }
    mint operator*(const mint& a) const { return mint(x) *= a; }

    // for prime mod
    mint inv() const {
        long long a = x, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        return mint(u);
    }
    mint& operator/=(const mint& a) { return *this *= a.inv(); }
    mint operator/(const mint& a) const { return mint(x) /= a; }
};
istream& operator>>(istream& is, const mint& a){ return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a){ return os << a.x; }

struct Combination{
    vector<long long> fac, finv, inv;
    Combination(int n=1001001):fac(n+1), finv(n+1), inv(n+1) {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i <= n; i++){
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
    long long operator()(int n, int k) const {
        if (n < k || n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
};

long long mod_pow(long long x, long long n, int M=1000000007) {
    long long ret = 1;
    while(n) {
        if(n & 1) (ret *= x) %= M;
        (x *= x) %= M;
        n >>= 1;
    }
    return ret;
}

int main(){
    int K;
    string S;
    cin >> K >> S;

    int N = S.size();

    mint ans = 0;
    Combination c(2001001);

    for (int i = N; i <= K + N; ++i) {
        int left = i - N;
        int n = left + 1, r = N - 1;
        mint tmp = (mint)mod_pow(25, left) * c(n + r - 1, r);

        int right = K + N - i;
        ans += tmp * mod_pow(26, right);
    }

    cout << ans << endl;
}

Measured memory_bytes: 51228
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int N = 0;
		int Q = 0;
		String s;
		Scanner sc = new Scanner(System.in);
		N = Integer.parseInt(sc.next());
		Q = Integer.parseInt(sc.next());
		s = sc.next();
		int n;
		String Golem[] = new String[N];
		for (n = 0; n < N; n++) {
			Golem[n] = s.substring(n, n + 1);
		}
		int l = 0;
		int L = 0;
		int r = N-1;
		int R = 0;
		int m = 0;
		String t[] = new String[Q];
		String d[] = new String[Q];
		for (n = 0; n < Q; n++) {
			t[n] = sc.next();
			d[n] = sc.next();
		}
		while (r >=l) {
			// 左側
			m = (l + r) / 2;
			if (simulate(Golem, t, d, Q, m, N) == -1)
				l = m + 1;
			else
				r = m - 1;
		}
		L = r;
		l = 0;
		r = N-1;
		while (r >=l) {
			// 右側
			m = (l + r) / 2;
			if (simulate(Golem, t, d, Q, m, N) == 1)
				r = m - 1;
			else
				l = m + 1;
		}
		R = r;
		sc.close();
		System.out.println(R - L);
	}

	static int simulate(String Golem[], String t[], String d[], int Q, int m, int N) {
		int temp = 0;
		temp = m;

		for (int i = 0; i < Q; i++) {
			if (Golem[temp].equals(t[i])) {
				if (d[i].equals("R"))
					temp++;
				else
					temp--;
				if (temp < 0)
					return -1;// 左に落下
				if (temp >= N)
					return 1;// 右に落下
			}
		}
		return 0;
	}
}

Measured memory_bytes: 99096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    string s; 
    ll K; 
    cin >> s >> K;

    string abc = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";


    rep(i,s.size()) {
        if( i == s.size() - 1 ) {
            K %= 26;
            s[i] = abc[ ( s[i] - 'a' ) + K];
            continue;
        }
        if(s[i] == 'a') continue;
        if( K >= 26 - (s[i] - 'a') ) { K -= 26 - (s[i] - 'a'); s[i] = 'a'; }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 592
import math
A, B, C, D = map(int, input().split())
t_mon = [A, B]
a_mon = [C, D]
t_turn = math.ceil(t_mon[0] / a_mon[1])
a_turn = math.ceil(a_mon[0] / t_mon[1])

if t_turn >= a_turn:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9068
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    string s;cin>>s;
    string str="ABC";
    str+=s;
    cout<<str<<endl;
}


Measured memory_bytes: 3604
N = int(input())
t = 0
xy = [0,0]
ans = 'Yes'
for i in range(N):
    ti,xi,yi = map(int,input().split())
    dt = ti - t
    dx = abs(xi - xy[0])
    dy = abs(yi - xy[1])
    if dt < dx+dy:
        ans = 'No'
    elif dt%2 != (dx+dy)%2:
        ans = 'No'
    t = ti
    xy = [xi,yi]
print(ans)

Measured memory_bytes: 9212
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
using namespace std;
long long inf=100000000000007;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
typedef pair<int,int>  P;
string alph("abcdefghijklmnopqrstuvwxyz");
struct edge{int to,cost;};
vector<edge> G[22];
vector<int> O[10];
char fi[1005][1005];
P sg[10];
int d[1005][1005];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
pair<int,double> s[1005];
int c=0;
int n,k;

signed main(){
    int n;cin>>n;
    int a=n/1000,b=(n%1000)/100,c=(n%100)/10,d=n%10;
    int to=(a+b+c+d-7)/2;
    for(int i=0; i<=7;i++){
        int h=0;
        if(i>=4)h+=b;
        if(i%4>=2)h+=c;
        if(i%2>=1)h+=d;
        if(h==to){
            cout<<a;
            if(i>=4)cout<<"-";else cout<<"+";
            cout<<b;
            if(i%4>=2)cout<<"-";else cout<<"+";
            cout<<c;
            if(i%2>=1)cout<<"-";else cout<<"+";
            cout<<d;
            cout<<"=7"<<endl;
            break;
        }
    }
    return 0;
}

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

int limit,n,m,x;

int a[111],b[111],c[111],d[111];
string damy;
int dp[1111][111];
bool used[1111][111];
int MAX[1111];

void Input(){
  rep(i,m){
    cin>>damy>>c[i]>>d[i];
  }
  rep(i,n){
    cin>>damy>>a[i]>>b[i];
  }
}

void init(){
  memset(MAX,0,sizeof(MAX));
  memset(dp,0,sizeof(dp));
  memset(used,0,sizeof(used));
}

void DP(){
  used[0][0]=1;
  for(int k=0;k<n;k++){
    for(int i=limit;i>=0;i--){
      for(int j=n;j>=0;j--){
	if(used[i][j]){
	  if(i+a[k]<=limit){
	    used[i+a[k]][j+1]=1;
	    dp[i+a[k]][j+1]=max(dp[i+a[k]][j+1],dp[i][j]+b[k]);
	  }
	}
      }
    }
  }

  for(int i=0;i<=limit;i++){
    for(int j=x;j<=n;j++){
      MAX[i]=max(MAX[i],dp[i][j]);
    }
  }

  int ans=0;

  for(int i=0;i<m;i++){
    for(int j=i+1;j<m;j++){
      for(int k=0;k<limit;k++){
	if(k+c[i]+c[j]>limit)break;
	ans=max(ans,MAX[k]+d[i]+d[j]);
      }
    }
  }

  for(int i=0;i<m;i++){
    for(int k=0;k<limit;k++){
      if(k+c[i]>limit)break;
      ans=max(ans,MAX[k]+d[i]);
    }
  }

  cout << ans << endl;
  
}


int main(){
  while( cin>>limit>>m>>n>>x,limit){
    Input();
    init();
    DP();
  }
}



Measured memory_bytes: 3756
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
using namespace std;


typedef long long       ll;
struct edge { ll to; ll cost; };
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef vector<edge>    ve;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<ve>      vve;
typedef vector<vc>		vvc;

// マクロ
#define repr(itr, bgn, end) for (ll itr = (ll)bgn; itr < (ll)end; ++itr)
#define rep(itr, end) repr(itr, 0, end)
#define reprrev(itr, bgn, end) for (ll itr = (ll)end - 1; itr >= (ll)bgn; --i)
#define reprev(itr, end) reprrev(itr, 0, end)
#define all(container) container.begin(), container.end()
#define sortall(container) sort(all(container))
#define yn(cond) cond ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(cond) cond ? (cout << "YES" << endl) : (cout << "NO" << endl)

// 定数
#define LLONG_MAX 9223372036854775807
constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 15;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;

// よく使うもの
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (T& x : vec) os << x << " ";
	return os;
}

// ***<ここから>****************************************************************



int main(void) {

	string S;
	cin >> S;

	if (S[0] != 'A') {
		cout << "WA" << endl;
		return 0;
	}

	int cnt = 0;
	repr(i, 2, S.length() - 1) {
		if (S[i] == 'C') cnt++;
	}

	if (cnt != 1) {
		cout << "WA" << endl;
		return 0;
	}

	rep(i, S.length()) {
		if (i == 0 || (i >= 2 && i <= S.length() - 2)) continue;
		if (S[i] < 'a' || S[i] > 'z') {
			cout << "WA" << endl;
			return 0;
		}
	}

	cout << "AC" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define mod 1000000007
typedef long long int LL;
const int MAX = 105;
const int INF = 1e5;


int main() {
	int n;
	cin >> n;
	if (n & 1) {
		int x = n / 2 + 1;
		double ans = (double)x / n;
		printf ("%f\n", ans);
	}
	else printf ("%f\n", 0.5);
	return 0;
}

Measured memory_bytes: 256
#include<iostream> 
#include<stdio.h>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;
string a;
char p[300];
int b=1,q;
void init()
{
    p['b'] = 'd';
    p['d'] = 'b';
    p['q'] = 'p';
    p['p'] = 'q';
}
int main()
{
    getline(cin,a);
    init();
    for(int i=0;i<=a.size()-1;i++)
    {
        if(p[a[i]]!=a[a.size()-1-i])
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

// ll m_lcm(vector<int> &a, int lv, int n){
// 	if(lv == 2){
// 		ll g = __gcd(a.at(lv-2), a.at(lv-1));
// 		ll l = a.at(lv-2) * a.at(lv-1);
// 		l /= g;
// 		return l;
// 	}else{
// 		ll lm = m_lcm(a, lv-1, n);
// 		ll g = __gcd(lm, (ll)a.at(lv-1));
// 		ll l = lm * a.at(lv-1);
// 		l /= g;
// 		return l;
// 	}
// }

int main(){
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	rep(snip_i, n) cin >> a.at(snip_i);
	int c;
	rep(i, n){
		if(i == 0){
			c = 0;
			int temp = a.at(0);
			while(1){
				if(temp % 2 == 0){
					temp /= 2;
					c++;
				}else{
					break;
				}
			}
		}else{
			int ct = 0;
			int temp = a.at(i);
			while(1){
				if(temp % 2 == 0){
					temp /= 2;
					ct++;
				}else{
					break;
				}
			}
			if(ct != c){
				cout << 0 << endl;
				return 0;
			}
		}
	}
	rep(i, n) a.at(i) /= 2;
	ll l = a.at(0);
	rep2(i, 1, n){
		ll g = __gcd(l, (ll)a.at(i));
		l /= g;
		l *= a.at(i);
	}
	// cerr << l << endl;
	int ans = m / l - m / (2*l);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        char[] c = scanner.next().toCharArray();

        int cnt = 0;
        int j = N - 1;

        for (int i = 0; i < N; i++) {
            if (c[i] == 'W') {
                for (; j > i; j--) {
                    if (c[j] == 'R') {
                        swap(c, i, j);
                        cnt++;
                        break;
                    }
                }
            }
        }

        System.out.println(cnt);
    }

    public static void swap(char[] c, int idxA, int idxB) {
        char tmp = c[idxA];

        c[idxA] = c[idxB];
        c[idxB] = tmp;
    }
}


Measured memory_bytes: 40776
#include<stdio.h>
 int main(void)
  {
     int a,b;

     scanf("%d",&a);
     scanf("%d",&b);

     if(a>b)
     puts("a > b");
     else if(a<b)
     puts("a < b");
     else
     puts("a == b");

 return 0;
 }

Measured memory_bytes: 580