akhauriyash/Code-Regression huggingface dataset:
import sys
import math
from collections import defaultdict, deque
from copy import deepcopy
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    H, W = MI()
    sx, sy = MI()
    gx, gy = MI()
    sx-=1
    sy-=1
    gx-=1
    gy-=1
    mylist = []
    for i in range(H):
        temp = input().rstrip()
        temp = tuple([True if temp[i]=="." else False for i in range(W)])
        mylist.append(temp)
    mylist = tuple(mylist)

    
    dist = Init(H, W, float('inf'))
    #dist2 = Init(H, W, float('inf'))
    dq = deque()
    dq2 = deque()
    dq.append((sx, sy))
    move1 = [[1,0],[0,1],[-1,0],[0,-1]]
    move2 = [[i,j] for i in range(-2,3) for j in range(-2,3) if not [i, j ] in move1 and [i, j] != [0, 0]]
    dist[sx][sy] = 0
    
    while dq:
        while dq:
            x, y = dq.popleft()
            if x == gx and y == gy:
                print(dist[gx][gy])
                sys.exit()


            #コスト1の移動
            for x2, y2 in move2:
                x2 += x
                y2 += y
                if x2 >= 0 and x2 < H and y2 >= 0 and y2 < W and mylist[x2][y2] and dist[x2][y2] > dist[x][y]+1:
                    dist[x2][y2] = dist[x][y]+1
                    dq2.append((x2,y2))

            #コスト0の移動
            for x2, y2 in move1:
                x2 += x
                y2 += y
                if x2 >= 0 and x2 < H and y2 >= 0 and y2 < W and mylist[x2][y2] and dist[x2][y2] > dist[x][y]:
                    dist[x2][y2] = dist[x][y]
                    dq.append((x2,y2))


        dq = deque(set(dq2))
        dq2 = deque()
        
    
    if dist[gx][gy] == float('inf'):
        print(-1)
    else:
        print(dist[gx][gy])
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 115636
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, const vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n, m; cin >> n >> m;
	vs a(n), b(m);
	for (auto &i : a) cin >> i;
	for (auto &i : b) cin >> i;
	REP(i, n - m + 1)REP(j, n - m + 1)
	{
		bool f = true;
		REP(k, m)REP(l, m)
		{
			int x = i + k, y = j + l;
			if (a[x][y] != b[k][l]) f = false;
		}
		if (f)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int W,H,N,ans=0;
  cin>>W>>H>>N;
  int A[H+1][W+1];
  REP(i,H+1){
    REP(j,W+1){
      A[i][j]=0;
    }
  }
  
    for(int j=1; j<=N; ++j){
      int X,Y,a;
      cin>>X>>Y>>a;
      if(a==1){
        for(int k=1; k<=H; ++k){
          for(int l=1; l<=X; ++l){
            A[k][l]=1;
          }
        }
      }
      if(a==2){
        for(int k=1; k<=H; ++k){
          for(int l=X+1; l<=W; ++l){
            A[k][l]=1;
          }
        }
      }
      if(a==3){
        for(int l=1; l<=W; ++l){
          for(int k=1; k<=Y; ++k){
            A[k][l]=1;
          }
        }
      }
      if(a==4){
        for(int l=1; l<=W; ++l){
          for(int k=Y+1; k<=H; ++k){
            A[k][l]=1;
          }
        }
      }
    }
  
  for(int i=1; i<=H; ++i){
    for(int j=1; j<=W; ++j){
      if(A[i][j]==0) ans++;
    }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000
#define ll long long int
using namespace std;




int main(){
  ll A,B; cin>>A>>B;
  A = A-1>0 ? A-1 : 0;
   ll diviser = 2;
   ll ans = 0;
   // 1 -- A と 1-- B に 分けて　偶奇を管理する
   bool evenA;
   bool evenB;
  
  while(diviser < 8 * B){

    evenA = ((A)%diviser < diviser/2) or ((A+1)%2 == 0);
    evenB = ((B)%diviser < diviser/2) or ((B+1)%2 == 0);
    if(diviser ==2){
      evenA = A%4==0 or A%4==3;
      evenB = B%4==0 or B%4==3;
    }

    if((evenA ==true and evenB == true) or(evenA ==false and evenB == false)){
      //ans += diviser / 2;

    } else {
      ans += diviser / 2;
    }
    //cout<<evenA <<"   " << evenB <<endl;

    diviser = diviser*2;
  }

  cout<<ans<<endl;



return 0;


}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define INF 10000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> p;

ll modpow(ll x, ll n) {
    ll res=1;
    while(n>0) {
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}

int main(void) {
    string s;
    cin >> s;
    ll la=0, lp=0, rc=0, rp=0;
    ll i, ans=0;
    ll size=(ll)s.size();
    ll l, r;
    for(i=0; i<size; i++) {
        if(s[i]=='C') rc++;
        else if(s[i]=='?') rp++;
    }
    
    for(i=0; i<size; i++) {
        if(s[i]=='C') rc--;
        else if(s[i]=='?') rp--;
        
        if(s[i]=='B' || s[i]=='?') {
            l=la*modpow(3, lp)%MOD + lp*modpow(3, lp-1)%MOD;
            r=rc*modpow(3, rp)%MOD + rp*modpow(3, rp-1)%MOD;
            ans+=l*r%MOD;
            ans%=MOD;
        }
        
        if(s[i]=='A') la++;
        else if(s[i]=='?') lp++;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 512
import java.util.*;
import java.io.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int l = Integer.parseInt(sc.next());

        int[][] A = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                A[i][j] = Integer.parseInt(sc.next());
            }
        }

        int[][] B = new int[m][l];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < l; j++) {
                B[i][j] = Integer.parseInt(sc.next());
            }
        }

        long[][] C = new long[n][l];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < l; j++) {
                for (int k = 0; k < m; k++) {
                    C[i][j] += A[i][k] * B[k][j];
                }
                if (j != 0) {
                    out.print(" ");
                }
                out.print(C[i][j]);
            }
            out.printf("\n");
        }

        out.flush();
    }
}


Measured memory_bytes: 46096
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    vector<int> v(3); cin >> v[0] >> v[1] >> v[2];
    sort(v.rbegin(), v.rend());

    int K; cin >> K;
    rep(i,0,K) v[0] *= 2;
    cout << v[0] + v[1] + v[2] << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,pair<int,int>> iii;
typedef vector<pair<int,int>> vii;
typedef vector<vector<int>> vvi;

#define pb push_back
#define mp make_pair
#define fi first
#define se second

const int MAXN = 2e5+100;
int n;
int A[MAXN], B[MAXN], ans[MAXN];

int main (void) {
    ios_base::sync_with_stdio(false);

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
        B[i] = A[i];
    }

    if (n == 2) {
        cout << A[1] << "\n" << A[0] << endl;
        return 0;
    }

    int med[3];
    for (int i = 0; i < 3; i++) {
        sort(B, B+n-1);
        med[i] = B[(n-1)/2];
        swap(B[(n-1)/2], B[n-1]);
    }
    sort(med, med+3);

    ans[n-1] = med[1];
    int idx = 1;
    for (int i = n-2; i >= 0; i--) {
        if ((A[i] >= med[idx] && A[i+1] < med[idx])
                || (A[i] > med[idx] && A[i+1] <= med[idx])) {
            idx--;
        } else if ((A[i] <= med[idx] && A[i+1] > med[idx])
                || (A[i] < med[idx] && A[i+1] >= med[idx])) {
            idx++;
        }
        idx = max(0, min(idx, 2));
        ans[i] = med[idx];
    }

    for (int i = 0; i < n; i++) {
        cout << ans[i] << "\n";
    }


    return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
using ll = long long;

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

    string s;
    int w;

    cin >> s;
    cin >> w;
    for (int i = 0; i < s.length(); i += w) cout << s[i];
    cout << endl;

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    repall (i, vec)
        cout << i << ' ';
    cout << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


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

int main(void){
  int n, t;
  vector<int> c(100), a(100);

  cin >> n >> t;
  for(int i = 0; i < n; i ++)
    cin >> c.at(i) >> a.at(i);

  int m = 10000;
  for(int i = 0; i < n; i ++){
    if(a.at(i) <= t && c.at(i) < m){
      m = c.at(i);
    }
  }

  if(m == 10000) cout << "TLE" << endl;
  else cout << m << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline()
# print = lambda: sys.stdout.writeline()
def main():
    n = int(input())
    L = [int(x)-1 for x in input().split()]

    cnt = 0
    for i in range(n):
        if L[L[i]] == i:
            cnt += 1

    print(cnt//2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 13876
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set> 
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int n,k,sum[N],b,MAX;
bool aa[N],a[N];
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		char ch;
		cin>>ch;
		aa[i]=((ch=='1'?true:false));
	}
	for(int i=1;i<=n;i++)
		a[i]=aa[i]^aa[i-1];
	for(int i=1;i<=n;i++)
		sum[i]=sum[i-1]+a[i];
	for(int i=1;i<=n;i++)
	{
		b^=a[i];
		int x=upper_bound(sum,sum+n+1,k*2-(!b)+sum[i])-sum;
		MAX=max(MAX,x-i);
	}
	cout<<MAX;
	return 0;
}

Measured memory_bytes: 768
#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;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define EPS (1e-7)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;

int vx[]={0,1,0,-1};
int vy[]={1,0,-1,0};

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int MAX=1e9;

ll n,s;
bool check(ll B, ll N, ll S){
	ll res=0;
	if(B>N){
		res=N;
	}else{
		while(N>0){
			res+=N%B;
			N/=B;
		}
	}
	if(res==S)return true;
	else return false;
}

int main(){
	cin>>n>>s;
	if(n<s){
		cout<<-1<<endl;
		return 0;
	}else if(n==s){
		cout<<n+1<<endl;
		return 0;
	}else{
		for(ll i=2;i<=sqrt(n);i++){
			if(check(i,n,s)){
				cout<<i<<endl;
				return 0;
			}
		}
		for(ll i=sqrt(n);i>=1;i--){
			if((n-s)%i!=0)continue;
			ll b=(n-s)/i+1;
			if(check(b,n,s)){
				cout<<b<<endl;
				return 0;
			}
		}
	}
	cout<<-1<<endl;
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	ll n, k;
	cin>>n>>k;
	cout<<min(n%k, k - n%k)<<endl;

	return 0;
}

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

int main(){
  int n,m;
  cin >>n >>m;
  vector<ll> h(n);
  rep(i,n) cin >>h[i];
  int num[n] = {0};
  rep(i,m){
    int a,b;
    cin >>a >>b;
    a--; b--;
    if(h[a]<=h[b]) num[a]++;
    if(h[b]<=h[a]) num[b]++;
  }
  int cnt = 0;
  rep(i,n){
    if(num[i]==0) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


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

int main(){
    int n;
    cin>>n;
    int a[n],b[n],c[n-1];

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

    for(int i=0;i<n;i++){
        cin>>b[i];
    }

    for(int i=0;i<n-1;i++){
        cin>>c[i];
    }

    int ans=0,d=0;

    for(int i=0;i<n-1;i++){
        if((a[i]+1)==a[i+1])ans=ans+c[a[i]-1];
    }

    for(int i=0;i<n;i++){
        ans=ans+b[i];
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ll INF = 1e18;
#define pu push
#define pb push_back
#define mp make_pair
#define print(x) cout << (x) << endl;
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define fi first
#define sc second

int main() {
    int A,B,C;
    string S;
    cin >> S;
    if (S=="ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
	int ans = 0;
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < n; i++){
		if(a[a[i] - 1] == i + 1) ans++;
	}
	cout << ans / 2 << endl;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>

int main()
{
    while(1){
    double ave,hensa2n=0,hensa=0;
        int n,i,a[1000]={},cnt=0;
        int sum=0;
        scanf("%d",&n);
        if(n==0)
            break;
        while(cnt<n){
            scanf("%d",&a[cnt]);
            sum+=a[cnt];
            cnt++;
        }
        ave=sum/(double)n;
    for(i=0;i<n;i++)
        hensa2n+=pow((a[i]-ave),2.0);
        hensa=sqrt(hensa2n/n);
        printf("%.7lf\n",hensa);
  }
}



Measured memory_bytes: 2084
#include <bits/stdc++.h>
using namespace std;
string s;
int a,b,c,d;

int calc()
{
	if(a==1&&b==1&&c==1&&d==1) return 1;
	if(a==1&&b==1&&c==0&&d==0) return 1;
	if(a==0&&b==0&&c==1&&d==1) return 1;
	if(a==0&&b==0&&c==0&&d==0) return 1;
	return 0;
}

int main()
{
	cin>>s;
	int len=s.length();
	for(int i=0;i<len;i++){
		if(s[i]=='N') a=1;
		if(s[i]=='S') b=1;
		if(s[i]=='W') c=1;
		if(s[i]=='E') d=1;
	}
	puts(calc()?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=100;
int main(void){
    int M[N][N];
    int n,u,k,v;
    cin >> n;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            M[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        cin >> u >> k;
        u--;
        for(int j=0;j<k;j++){
            cin >>v;
            v--;
            M[u][v]=1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(j) cout << " ";
            cout << M[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int INF = 1e9 + 7;
int main()
{
	SPEED
	int n;
	cin >> n;
	cout << n*n;
	return 0;
}

Measured memory_bytes: 256
local n, x = io.read("*n", "*n")

local L = {}
for i=1, n do
  L[i] = io.read("*n")
end

local cnt = 1
local d = 0

for i = 1, n do
  d = d + L[i]
  if d <= x then
    cnt = cnt + 1
  end
end

print(cnt)

Measured memory_bytes: 760
def main():
    s = int(input())
    mod = 10**9+7
    dp = [0] * (s+1)
    dp[0] = 1
    x = 0
    for i in range(1, s+1):
        if i-3 >= 0:
            x += dp[i-3]
            x %= mod
        dp[i] = x
    print(dp[s])

if __name__ == "__main__":
    main()


Measured memory_bytes: 9188
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = ni();
		int ac = 0;
		int wa = 0;
		int tle = 0;
		int re = 0;
		for (int i = 0; i < n; i++) {
			String s = n();
			if ("AC".equals(s)) {
				ac++;
			}
			if ("WA".equals(s)) {
				wa++;
			}
			if ("TLE".equals(s)) {
				tle++;
			}
			if ("RE".equals(s)) {
				re++;
			}
		}

		out("AC x " + ac);
		out("WA x " + wa);
		out("TLE x " + tle);
		out("RE x " + re);

	}

	/*
	 * 以下メソッド集
	 */
	static double[] sort(double[] r) {
		Arrays.sort(r);
		return r;
	}

	static void debug() {
		out("---");
	}

	static void debug(long a) {
		out("-------");
		out(a);
		out("-------");
	}

	static void debug(String a) {
		out("-------");
		out(a);
		out("-------");
	}

	static long[] sort(long[] n) {
		Arrays.sort(n);
		return n;
	}

	static int ketasuu(int n) {
		String str = "" + n;
		return str.length();
	}

	static int account(String str) {
		String target = "AC";
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if (target.equals(str.substring(i, i + target.length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

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

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

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static double max(double d, double e) {
		return Math.max(d, e);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static long min(long d, long e) {
		return Math.min(d, e);
	}

	static int min(int a, int b) {
		return (int) Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


Measured memory_bytes: 58064
#include<iostream>
#include<vector>
#include<string>

#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
template<class T> inline void chmax(T& a, T b) { if(a < b) a = b; }
template<class T> inline void chmin(T& a, T b) { if(a > b) a = b; }
const ll mod = 1000000007;

int main(){
	int A, B, C, K;
	std::cin >> A >> B >> C >> K;
	bool ok = false;

	int cnt = 0;
	while(A >= B){
		B *= 2;
		cnt++;
	}
	if(cnt > K){
		std::cout << "No" << std::endl;
		return 0;
	}

	while(B >= C){
		C *= 2;
		cnt++;
	}
	if(cnt > K){
		std::cout << "No" << std::endl;
	}else{
		std::cout << "Yes" << std::endl;
	}
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    int mx = 0;
    rep(i, n)
    {
        mx = max(mx, a[i]);
        ans += mx - a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3952
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N,M = II()
A,B = Line(N)
c = []
for i in range(N):
    c.append([A[i],B[i]])

c.sort()
ans = 0
count = 0

for i in range(N):
    x = min(c[i][1], M-count)
    ans += x*c[i][0]
    count += x
    if count==M:
        break

print(ans)

Measured memory_bytes: 76380
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;
typedef pair<int, int> P;
vector<P> v;

int main() {

    int N, M; cin >> N >> M;
    int a, b;
    for (int i = 0; i < M; i++) {
        scanf("%d %d", &a, &b);
        v.push_back(make_pair(b, a));
    }

    sort(v.begin(), v.end());

    int ans = 0;
    int l = -1;
    for (int i = 0; i < v.size(); i++) {
        if (l <= v[i].second) {
            ans++;
            l = v[i].first;
        }
    }

    cout << ans << '\n';
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vi a(n+1), b(n);
  rep(i,n+1) cin >> a[i];
  rep(i,n) cin >> b[i];
  ll ans = 0;
  rep(i,n) {
    ans += min(a[i]+a[i+1], b[i]);
    if(a[i] <= b[i]) b[i] -= a[i];
    else b[i] = 0;
    a[i+1] -= min(a[i+1], b[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long tint;
 
#define forsn(i, s, n) for(int i=s;i<int(n);i++)
#define forn(i, n) forsn(i, 0, n)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend() 
#define NACHO ios::sync_with_stdio(0); cin.tie(NULL);

const int INF = 1111122222;
const int MOD = 1e9+7;

int main(){
	tint x; cin >> x;
	int f = log2(x);
	f++;
	cout << (1LL*1<<f)-1 << "\n";
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main() {
    double a, b, c, d, e, f, x, y;
    cout.precision(3);
    cout << fixed;
    while (cin >> a >> b >> c >> d >> e >> f) {
        x = (c * e - b * f) / (a * e - b * d);
        y = (a * f - c * d) / (a * e - b * d);
        if (x == 0) x = 0;
        if (y == 0) y = 0;
        cout << x << " " << y << endl;
    }
    return 0;
}

Measured memory_bytes: 1280
// AUTHOR:: MOHAMMAD FAISAL
#include<bits/stdc++.h>
using namespace std;

int main()
{
 string s;
  cin >> s;
  string t;
  cin >> t;
  bool flag = true;
  for(int i=0;i<s.size();i++)
    if(s[i]!=t[i])
    {
      flag = false;
      break;
    }
  if(!flag) 
    cout<<"No";
  else
    cout<<"Yes";
  return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>

int main(void){
  int N, v, i, j, k, m;
  scanf("%d", &N);
  int A[N];

  //配列に入力値を代入する
  for(k = 0; k < N; k++){
    scanf("%d", &A[k]);
  }

  //for文ではiを右にずらし、while文ではソート済みの配列をずらしている
  for(i = 1; i < N; i++){
    
    for(m = 0; m < N; m++){
      if(m > 0) printf(" ");
      printf("%d",A[m]);
    }
    printf("\n");
    
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;


  }

  for(m = 0; m < N; m++){
    if(m > 0) printf(" ");
    printf("%d",A[m]);
  }
  printf("\n");
  return 0;
}



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

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

    int sum = 0;

    for (int i = a; i <= b; i++) {
        string str = to_string(i);
        sum += (str[0] == str[4] && str[1] == str[3]);
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
int main(){
    while(1){
        int n;
        std::cin >> n;
        if(n == 0) break;
        std::vector<int> w(n);
        for(int i = 0; i < n; i++)std::cin >> w[i];
        int dp[n + 1][n + 1];
        for(int i = 0; i < n + 1; i++)for(int j = 0; j < n + 1; j++)dp[i][j] = 0;
        for(int h = 2; h < n + 1; h+= 1){
            for(int l = 0; l < n; l++){
                int r = l + h;
                if(r > n) break;
                if(dp[l+1][r -1] == h - 2 && std::abs(w[l] - w[r - 1]) <= 1) dp[l][r] = h;
                for(int mid = l + 1; mid < r; mid++){
                    dp[l][r] = std::max(dp[l][r], dp[l][mid] + dp[mid][r]);
                }
            }
        }
        std::cout << dp[0][n] << std::endl;
    }
}


Measured memory_bytes: 3432
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
#dt = {k:v for k,v in sorted(x.items(), key=lambda i: i[1])}
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

n,m = ip()
graph = {i:[] for i in range(1,n+1)}
for i in range(m):
    a,b = ip()
    graph[a].append(b)
    graph[b].append(a)

parent = {i:-1 for i in range(1,n+1)}
parent[1] = 0
q = [1]
while len(q):
    u = q.pop(0)
    for v in graph[u]:
        if parent[v] == -1:
            q.append(v)
            parent[v] = u

if -1 in list(parent.values()):
    print("No")
    exit()
print("Yes")
for i in range(2,n+1):
    print(parent[i])







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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    vector<int> is_prime( 1000000 + 1 ,0);

    rep(i,N){
        cin >> a[i];
        is_prime[a[i]]++;
    }
    sort(a.begin(),a.end());
    
    for( int i = 1; i <= a[N-1]; i++ ){
        if( is_prime[ i ] > 0){
            for( int j = 2 * i; j <= a[N-1]; j += i ){
                is_prime[ j ] = 0;
            }
        }
    }
    int cnt=0;
    rep(i,a[N-1]+1){
        if(is_prime[ i ] == 1){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;

  vector<pair<int, int>> X(N);
  for (int i = 0; i < N; i++) {
    int given;
    cin >> given;
    X[i] = {given, i};
  }

  sort(X.begin(), X.end());

  vector<int> ans(N);
  int boundary = N/2;

  for (int idx = 0; idx < N; idx++) {
    if (idx < boundary) {
      ans[X[idx].second] = X[boundary].first;
    } else {
      ans[X[idx].second] = X[boundary-1].first;
    }
  }

  for (int x : ans) cout << x << endl;
  return 0;
}

Measured memory_bytes: 5560
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def solve():
    n = int(input())
    fl = [[int(i) for i in input().split()] for _ in range(n)]
    pl = [[int(i) for i in input().split()] for _ in range(n)]
    ans = -1 * 100 * (10 ** 7)
    for cnt in range(1, 2 ** 10 + 1):
        cnt_list = [0]*n
        for i in range(n):
            t = cnt
            digit = 0
            while t > 0:
                if t & 1 != 0 and fl[i][digit - 1] == 1:
                  cnt_list[i] += 1
                t >>= 1
                digit += 1
        tsum = 0
        for i in range(n):
            tsum += pl[i][cnt_list[i]]
        ans = max(tsum, ans)
    print(ans)


if __name__=="__main__":
    solve()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=998244353;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)

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

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            String S = Console.ReadLine();
            DateTime dateTime;
            Boolean isYYMM = DateTime.TryParseExact(S, "yyMM", null, System.Globalization.DateTimeStyles.AssumeLocal, out dateTime);
            Boolean isMMYY = DateTime.TryParseExact(S, "MMyy", null, System.Globalization.DateTimeStyles.AssumeLocal, out dateTime);
            if (isYYMM && isMMYY)
            {
                Console.WriteLine("AMBIGUOUS");
            }
            else if (isYYMM)
            {
                Console.WriteLine("YYMM");
            }
            else if (isMMYY)
            {
                Console.WriteLine("MMYY");
            }
            else
            {
                Console.WriteLine("NA");
            }
        }
    }
}


Measured memory_bytes: 13664
#include <cstdio>

int main() {
    int w, h, x, y, r;
    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
    if (w - x < r || h - y < r || x < r || y  < r) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }

    return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a, b, c;
  cin >> a >> b >> c;
  
  if (a < b && b < c) cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 3108
String  = input()
index = 0
flag = False
while index < len(String) - 1:
    flag = True
    if String[index:index + 7] == "dreamer":
        index += 7
        if String[index:index + 4] == "aser":
            index += 4
        elif String[index:index + 3] == "ase":
            index += 3
    elif String[index:index + 5] == "dream":
            index += 5
    elif String[index:index + 6] == "eraser":
            index += 6
            if String[index:index + 4] == "aser":
                index += 4
            elif String[index:index + 3] == "ase":
                index += 3
    elif String[index:index + 5] == "erase":
                index += 5
    else:
        flag = False
        break
if flag:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3188
def knsu(S):
    N = len(S)
    F = True
    for i in range(N):
        J = N - 1 - i
        if S[i] == S[J]:
            pass
        else:
            F = False
            break

    return F


S = input()
N = len(S)
f1 = knsu(S[:N//2])
f2 = knsu(S[N//2+1:])
f3 = knsu(S)
if f1 and f2 and f3:
    print("Yes")
else:
    print("No")


# if F:
#     print("Yes")
# else:
#     print("No")
# if S[2] == S[3] and S[4] == S[5]:
#      print("Yes")
# else:
#     print("No")
# # coffee


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

const int MAX_N = 110000;
int memo[MAX_N];
int rec (int n) {
    if (n == 0) return 0;
    if (memo[n] != -1) return memo[n];

    int res = n;

    for (int pow6 = 1; pow6 <= n; pow6 *= 6) res = min(res, rec(n - pow6) + 1);
    for (int pow9 = 1; pow9 <= n; pow9 *= 9) res = min(res, rec(n - pow9) + 1);
    return memo[n] = res;
}

int main() {
    int N; cin >> N;
    for (int i = 0; i < MAX_N; i++) memo[i] = -1;
    cout << rec(N) << endl;
}

Measured memory_bytes: 3840
import Control.Applicative
import Control.Monad
import Data.Array
import Data.Array.ST
import Data.Char
import Data.List
import qualified Data.Map as M
import qualified Data.Set as S
import Text.Printf

readInts :: IO [Int]
readInts = map read . words <$> getLine

main :: IO ()
main = do
  n <- readLn
  when (n /= 0) $ do
    ss <- map read . words <$> getLine
    print $ sd n ss
    main

sd :: Int -> [Double] -> Double
sd n ss = sqrt (sum [ (s - m)^2 | s <- ss ] / fromIntegral n)
 where
  m = mean n ss

mean :: Int -> [Double] -> Double
mean n ss = sum ss / fromIntegral n



Measured memory_bytes: 4960
#include <vector>
#include <stack>
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <typeinfo>


typedef long long ll;

void divide_cube(){
	ll a,b,c;
	ll m1,m2;
	std::cin >> a >> b >> c;
	if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
		std::cout << 0 << std::endl;
	else{
		/*
		int ab = a*b;
		int bc = b*c;
		int ca = c*a;
		int result = std::min(ab,bc);
		result = std::min(result,ca);
		*/
		
		m1 = std::min(a,b);
		if(m1 == a)
			m2 = std::min(b,c);
		else
			m2 = std::min(a,c);
		ll result = m1 * m2;
		std::cout << result << std::endl;
	}
}

void STring(){
	std::string x;
	std::cin >> x;
	std::string y,y2;
	int n = x.size();
	int nt = 0;
	int ns = 0;
	//y = x.substr(n-1,1);
	/*
	if(y == "T")
		std::cout << "OK";
	*/
	//std::cout << y << std::endl;
	
	/*
	for(int i = 1; i <= n-1; i++){
		y = x.substr(n-i,1);
		if(y == "T"){
			nt++;
			while()

		}

	}
	// SSTSSTTT
	*/
	/*
	int i = n - 1;
	//std::cout << n << std::endl;
	int tcnt = 0;
	int scnt = 0;
	int result = n;
	while(i >=0){
		//std::cout << i << std::endl;

		y = x.substr(i,1);
		if(tcnt == 0 && y == "S"){
			i--;
		}
		else if(tcnt !=0 && y == "S"){
			i--;
			scnt++;
			if(i < 0)
				result = result - 2*std::min(scnt,tcnt);
		}
		else if(scnt !=0 && y == "T"){
			i--;
			result = result - 2*std::min(scnt,tcnt);
			tcnt = 1;
			scnt = 0;
		}
		else if(scnt == 0 && y == "T"){
			i--;
			tcnt++;
		}
	}
	*/
	//int i = n - 1;
	//std::cout << n << std::endl;
	int tcnt = 0;
	int scnt = 0;
	int result = n;
	for(int i = 0; i<n; i++){
		y = x.substr(i,1);
		if(y=="S")
			scnt++;
		else if(y=="T" && scnt > 0){
			result = result - 2;
			//std::cout << scnt << i << std::endl;
			//std::cout << result << std::endl;
			scnt--;
		}

	}

	std::cout << result << std::endl;

}


int main(){
	//divide_cube();
	STring();
	return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
//ll dx[4] = {1, 0, -1, 0};
//ll dy[4] = {0, 1, 0, -1};

ll dp[102][114514]  = {};
ll sum[102][114514] = {};

int main() {
	IOS();
	ll n, k;
	cin >> n >> k;
	set<ll> s;
	for (ll i = 1; i * i <= n; i++) {
		s.insert(i);
		s.insert(n / i);
	}
	ll m = s.size();
	vector<ll> a(m), b(m);
	map<ll, ll> mp;
	ll cnt = 0;
	for (auto it = s.begin(); it != s.end(); it++) {
		b[cnt]  = *it;
		mp[*it] = cnt;
		if (cnt == 0) {
			a[cnt] = 1;
		} else {
			a[cnt] = b[cnt] - b[cnt - 1];
		}
		cnt++;
	}

	for (int i = 0; i < m; i++) {
		sum[0][i] = 1;
		//dump(a[i]);
	}
	for (int i = 0; i < k; i++) {
		for (int j = 0; j < m; j++) {
			dp[i + 1][j] = a[j] * sum[i][mp[n / b[j]]];
			dp[i + 1][j] %= MOD;
			if (j == 0) {
				sum[i + 1][j] = dp[i + 1][j];
			} else {
				sum[i + 1][j] = sum[i + 1][j - 1] + dp[i + 1][j];
				sum[i + 1][j] %= MOD;
			}
		}
	}
	dump(sum[k][m - 1]);
	return 0;
}


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

int getdiv(int n) {
    int num = n;
    int m = sqrt(n)+ 1;
    int ret = 1;

    for(int i=2;i<m;i++) {
        if((num %i)==0) {
            ret++;
        }
    }

    return ret * 2;
}

int main(void) {
    int N,d,cnt;
    cin >> N;    
    cnt = 0;
    for(int i=1;i<=N;i+=2) {
        d = getdiv(i);
        if(d == 8) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
n, y = map(int, input().split())

for i in range(y // 10000 + 1):
    for j in range((y - 10000 * i) // 5000 + 1):
        if (i*10000 + j*5000+(n-i-j)*1000) == y:
            print(i, j, (n - i - j))
            exit()
print(-1, - 1, - 1)

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

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

    map<int, int> m1, m2;
    for (int i = 0; i < N; i++) m1[D[i]]++;
    for (int i = 0; i < M; i++) m2[T[i]]++;

    for (int i = 0; i < M; i++) {
        if (m1[T[i]] < m2[T[i]]) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 20608
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
using namespace std;
int main() {
    int N, Q, K;
    cin >> N;
    vector<vector<pair<int, int>>> adj(N);
    for (int64_t i = 0, a, b, c; i < N - 1; i++) {
        cin >> a >> b >> c;
        adj[a - 1].push_back(make_pair(b - 1, c));
        adj[b - 1].push_back(make_pair(a - 1, c));
    }
    cin >> Q >> K;
    vector<bool> visited(N, false);
    vector<int64_t> dis(N, 0);
    queue<int> q;
    visited[K - 1] = true;
    q.push(K - 1);
    while (!q.empty()) {
        int t = q.front();
        q.pop();
        visited[t] = true;
        for (const auto& p : adj[t]) {
            if (visited[p.first]) continue;
            q.push(p.first);
            dis[p.first] = dis[t] + p.second;
        }
    }
    for (int i = 0, x, y; i < Q; i++) {
        cin >> x >> y;
        cout << (int64_t)dis[x - 1] + dis[y - 1] << endl;
    }
}

Measured memory_bytes: 8820
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}



//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}

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

	int num = 0;
	if (B > C) {
		num = C + B;
		//完食
	}
	
	else {
			num += B * 2;
			C -= B;
			//cout << A << "," << B << "," << C << endl;
			//cout << num << endl;
			if (A > C) {
				num += C;
			}
			else {

				num += min(A + 1, C);
			}
		}

	cout << num << endl;

	return 0;
}

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

int main()
{

    string str;
    cin>>str;

    int i,len;
    set <char> s;

    for(i=0;i<3;i++)
    {
        s.insert(str[i]);

    }

    len = s.size();

    if(len==3)
        printf("Yes\n");

    else
        printf("No\n");

   return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
int h,w,n;
scanf("%d",&h);
scanf("%d",&w);
scanf("%d",&n);
if(h>w){
    if(n%h==0){printf("%d",n/h);}
    else{printf("%d",n/h+1);}
}
else {
    if(n%w==0){printf("%d",n/w);}
    else{printf("%d",n/w+1);}
}
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        scan.close();

        if (s.charAt(0) == 'R' && s.charAt(1) == 'R' && s.charAt(2) == 'R') {
            System.out.println(3);
            return;
        }

        if (s.charAt(0) == 'S' && s.charAt(1) == 'R' && s.charAt(2) == 'R') {
            System.out.println(2);
            return;
        }
        if (s.charAt(0) == 'R' && s.charAt(1) == 'R' && s.charAt(2) == 'S') {
            System.out.println(2);
            return;
        }

        if (s.charAt(0) == 'S' && s.charAt(1) == 'S' && s.charAt(2) == 'S') {
            System.out.println(0);
            return;
        }

        System.out.println(1);
    }
}


Measured memory_bytes: 35476
#include<bits/stdc++.h>
#define MAX_N 1001
#define rank dfasfds
using namespace std;
int par[MAX_N],rank[MAX_N];

void init(int n){for(int i=0;i<n;i++)par[i]=i,rank[i]=0;}

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

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

struct edge{
  int a,b,c;
  bool operator < (edge t) const{return c<t.c;}
};

int n,m;
edge e[10001];
int solve(int s){
  int cnt=0,used[1001];
  init(1001);
  for(int i=s;i<m;i++){
    if(same(e[i].a,e[i].b)) continue;
    unite(e[i].a,e[i].b);
    used[cnt++]=e[i].c;
  }
  return cnt==n-1? used[(n-1)/2]:1e9;
}


int main(){
  while(1){
  cin>>n>>m;
  if(!n&&!m)return 0;
  for(int i=0;i<m;i++)cin>>e[i].a>>e[i].b>>e[i].c;
  sort(e,e+m);
  int ans=1e9;
  for(int i=0;i<m;i++)ans=min(ans,solve(i));

  cout<<ans<<endl;
  }

  return 0;
}

Measured memory_bytes: 3224
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
bool isprime[1001];
int cnt[1001];

int main(){
    fill(isprime,isprime+1001,true);
    int N;
    cin>>N;
    isprime[0]=isprime[1]=false;
    for(int i=0;i<=1000;i++){
        if(isprime[i]){
            for(int k=2;k*i<=1000;k++){
                isprime[k*i]=false;
            }
        }
    }

    for(int i=1;i<=N;i++){
        int n=i;
        while(n>1){
            for(int j=0;j<=n;j++){
                if(isprime[j]&&n%j==0){
                    n/=j;
                    cnt[j]++;
                    break;
                }
            }
        }
    }
    int64_t ans=1;
    for(int i=1;i<=1000;i++){
        ans*=(cnt[i]+1);
        ans%=1000000007;
    }
    cout<<ans<<endl;
    return 0;
}

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


int main(){
  int a, b;
  cin >> a >> b;
  int n = max(a, b);
  if (n == a){
    a -= 1;
  }else{
    b -= 1;
  }
  n += max(a, b);
  cout << n << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define fs first
#define sc second
#define pb push_back
#define sz size() 
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<string> vs;

const static int INF = 1e8;
const static D EPS = 1e-8;

int main(){
  int n,k,x,y;
  cin >> n >> k >> x >> y;
  cout << min(k,n) * x + max(0,n-k) * y << endl;
}


Measured memory_bytes: 256
def bubbleSort(list_, n):
    count = 0
    for i in xrange(n):
        for j in xrange(n-1, i, -1):
            if list_[j] < list_[j - 1]:
                list_[j], list_[j - 1] = list_[j - 1], list_[j]
                count += 1

    return count

n = input()
nums = map(int, raw_input().split())
count = bubbleSort(nums, n)
print ' '.join(map(str, nums))
print count

Measured memory_bytes: 4228
#include <stdio.h>
 
int main() {
 
  int n,m,i,j;
  int a,b;
  int A[100][100] = {0};
  int B[100] = {0};
  int c[100] = {0};
 
  scanf("%d %d " ,&n,&m);
 
  for(j=0; j<n; j++) {
  for(i=0; i < m; i++) {
    scanf("%d",&a);
    A[j][i] = a;
  }
}
 
  for(j=0; j<m; j++) {
    scanf("%d",&b);
    B[j] = b;
  }
 
  for(j=0;j<n ; j++){ 
  for(i = 0; i<m; i++){
     c[j] = c[j] + A[j][i]*B[i];
    }
  }
 
  for(i=0;i<n;i++) {
    printf("%d\n",c[i]);
  }
  return 0;
}


Measured memory_bytes: 2060