akhauriyash/Code-Regression huggingface dataset:
from operator import itemgetter

n,m = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(m)]
ab.sort(key=itemgetter(1))
count = 0
R = 0
for a, b in ab:
     if a >= R:
            count += 1
            R = b
print(count)

Measured memory_bytes: 64856
#include<iostream>
#include<vector>

int main()
{
  int n;
  int count;
  std::vector<int> p;
  int tmp;
  std::cin >> n;
  for (int i = 0; i < n; i++)
  {
    std::cin >> tmp;
    p.push_back(tmp);
  }
  count = 0;
  for (int i = 0; i < n - 2; i++)
  {
    if ((p[i] > p[i+1] && p[i+1] > p[i+2]) || (p[i] < p[i+1] && p[i+1] < p[i+2]))
      ++count;
  }
  std::cout << count << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    long long int N;
    scanf("%lld",&N);
    for(long long int n=1;n<=3500;n++)for(long long int h=1;h<=3500;h++){
        long long int tmp=n*h*N;
        long long int po=4*n*h-n*N-h*N;
        if(po>0&&tmp%po==0){printf("%lld %lld %lld",n,h,tmp/po);return 0;}
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rel register ll
#define rec register char
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) pc('-'),x=-x;
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
map<ll,int> mp;
int main(){
int i,n=read(),m=read();
ll sum=0,llx=0;
for (i=1;i<=n;++i) llx+=mp[sum],mp[sum]++,sum=(sum+read())%m;
write(llx+mp[sum]),pl;
}

Measured memory_bytes: 4224
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

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

int main(void) {
  int scan; // scanf result
  ull answer; // to output 
  int n; // to input 

  scan = scanf("%d", &n);
  answer = 0;
  for (int k = 1; k <= n; k++) {
    if (k % 5 != 0 && k % 3 != 0) {
      answer += k;
    }
  }

  printf("%llu", answer);
  return (0);
}


Measured memory_bytes: 1732
#include <stdio.h>

int main(void) {

  int n;
  int area;
  int i;

  while(scanf("%d",&n)!=EOF) {

    area=1;

    for(i=1;i<=n;i++) {
      area+=i;
    }

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

  }

  return 0;

}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main()
{
	string s;
	int sum = 0;
	cin >> s;
	for (int i = 0; i < 6; i++) {
		if (s[i] == '1') {
			sum += 1;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#!/usr/bin/python

def main():
    a, b, c, d = [int(x) for x in input().split()]
    if abs(a-c)<=d or abs(a-b)<=d and abs(b-c)<=d:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define NUM 500

int V,E;
int ans;
vector<int> G[NUM];
bool visited[NUM];

void recursive(int node_id,bool is_first){

	visited[node_id] = true;

	if(!is_first){
		/*最初の頂点以外は、出次数-1のエッジを残す
		 (再帰的に考えると、入次の情報は分っているので、残りの1本は引き算で計算できる)
		 */
		ans += (int)G[node_id].size()-1;
	}

	for(int i = 0; i < G[node_id].size(); i++){
		if(visited[G[node_id][i]])continue;
		recursive(G[node_id][i],false);
	}
}

int main(){

	scanf("%d %d",&V,&E);

	for(int i = 0; i < V; i++)G[i].clear();

	int from,to;
	for(int loop = 0; loop < E; loop++){
		scanf("%d %d",&from,&to);
		from--;
		to--;
		G[from].push_back(to);
	}

	for(int i = 0; i < V; i++)visited[i] = false;

	ans = 0;
	for(int i = 0; i < V; i++){
		if(visited[i])continue;
		ans += (int)G[i].size(); //最初の頂点は、すべての出次エッジを残す
		recursive(i,true);
	}

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

	return 0;
}



Measured memory_bytes: 3312
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    /*ll N;
     cin>>N;
     
     vll A(N+1);
     for(ll i=0;i<=N;i++)cin>>A[i];
     if(N==0){
     if(A[0]==1){
     cout<<1<<endl;
     return 0;
     }else {
     cout<<-1<<endl;
     return 0;
     }
     }
     if(A[0]!=0){
     cout<<-1<<endl;
     return 0;
     }
     
     
     vll B(N+1);
     for(ll i=0;i<=N;i++){
     if(i==0){
     B[0]=1;
     }else{
     B[i]=(B[i-1]-A[i-1])*2;
     if(B[i]<A[i]){
     cout<<-1<<endl;
     return 0;
     }
     }
     }
     
     vll C(N+1);
     for(ll i=N;i>=0;i--){
     if(i==N){
     C[i]=A[i];
     }else{
     C[i]=C[i+1]+A[i];
     }
     }
     
     ll ans=0;
     for(ll i=0;i<=N;i++){ans+=min(B[i],C[i]);
     }
     cout<<ans<<endl;
     
     return 0;
     }
     
     int main() {*/
    //ll n,a[100005]={0},b[100005],c[100005],pv,ans=0;
    ll n,pv;
    
    //vll a(100005),b(100005),c(100005);
    bool ok=false;
    cin >> n;
    vll a(n+2),b(n+2),c(n+2);
    for(ll i=0;i<=n;i++){
        cin >> a[i];
    }
    for(ll i=0;i<=n;i++){
        if(i==0){
            if(a[i]>1){
                cout << -1 << endl;
                return 0;
            }
            b[0]=1;
        } else {
            if(ok) b[i]=2*1e17;
            else b[i]=(b[i-1]-a[i-1])*2;
            if(b[i]>=1e17) ok=true;
            if(a[i]>b[i]){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    b[n+1]=1;
    for(ll i=n;i>=0;i--){
        if(i==n){
            c[i]=a[i];
        } else {
            c[i]=c[i+1]+a[i];
        }
    }
    c[n+1]=0;
    for(ll i=0;i<=n+1;i++){
        if(b[i]>c[i]){
            pv=i;
            break;
        }
    }
    ll ans=0;
    for(ll i=0;i<=n;i++){
        if(i<pv){
            ans+=b[i];
        } else {
            ans+=c[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5552
import sys

s = input()
cand_string = ''
cand_string_double = ''
for c in s:
    cand_string += c
    cand_string_double = cand_string * 2
    if cand_string_double == s[0:len(cand_string_double)] and len(cand_string_double) != len(s):
        ans = len(cand_string_double)
print(ans)

Measured memory_bytes: 2940
#include <iostream>
#include <cstring>
#include <algorithm>
#define ll long long
using namespace std;

ll freq[26];
int main() {
  ll n;
  string letters;
  cin >> n >> letters;

  memset (freq, 0, sizeof (freq));

  for (ll i=0; i < n; i++){
    int f = letters[i] - 'a';
    freq[f]++;
  }

  ll ans = 1;
  for (int i=0; i < 26; i++){
    ll d = freq[i]+ 1;
    ans = ans*d;
    ans = ans%1000000007;
  }

  ans = ans - 1;
  cout << ans << endl;
}

Measured memory_bytes: 512
n=int(input())

t = list(map(int,input().split()))

first_sum = sum(t)

memo = [0]*(10**5+1)

for i in range(n):
    memo[t[i]] += 1

q=int(input())

for _ in range(q):
    b,c = map(int,input().split())
    first_sum += (c-b)*memo[b]
    print(first_sum)
    memo[c] += memo[b]
    memo[b] = 0

Measured memory_bytes: 84676
X, K, D = map(int, input().split())

k = round(abs(X) / D)

if k > K:
    if k == 1:
        print(abs(abs(X) - K * D))
    else:
        print(min(abs(abs(X) - K * D), abs(abs(X) - (K - 2) * D)))

else:
    if k % 2 == K % 2:
        print(min(abs(abs(X) - k * D), abs(abs(X) - (k + 2) * D), abs(abs(X) - (k - 2) * D)))

    else:
        print(min(abs(abs(X) - (k + 1) * D), abs(abs(X) - (k - 1) * D), abs(abs(X) - (k + 3) * D), abs(abs(X) - (k - 3) * D)))

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,n,c=1; cin>>n;
  vector<int> p(n),q(n),r;
  for(int i=0;i<n;i++) cin>>p[i];
  for(int i=0;i<n;i++) cin>>q[i];
  for(int i=1;i<=n;i++) r.push_back(i);  
  do{
    if(p==r) a=c;
    if(q==r) b=c;
    c++;
  }while(next_permutation(r.begin(),r.end()));
  cout<<abs(a-b);
}

Measured memory_bytes: 3616
n=int(input())
a= list(map(int,input().split()))
a=[i-1 for i in a]
b= list(map(int,input().split()))
c= list(map(int,input().split()))

count=0
cook=-4
for i in a:
    if i==cook:
        count+=c[i-1]
    
    count+=b[i] 
    cook=i+1
    
print(count)
    

Measured memory_bytes: 3060
if __name__ == "__main__":
    number_strings = []

    while True:
        number_string = input()

        if number_string == '0':
            break

        number_strings.append(number_string)

    sums = list(map(sum, map(lambda number_string: map(int, number_string), number_strings)))

    for sum in sums:
        print(sum)


Measured memory_bytes: 5616
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> C(H);
    for (int i = 0; i < H; i++) {
        cin >> C[i];
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < 2; j++) {
            cout << C[i] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, x) for (ll i = 0; i < (x); i++)
#define chmax(x, a)  do { x = max(x, a); } while(0)

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

ll ans[10001];

int main(void) {
  for (ll x = 1; x <= 100; x++)
  for (ll y = 1; y <= 100; y++)
  for (ll z = 1; z <= 100; z++) {
    ll t = x * x + y * y + z * z  + x * y + y * z + z * x;
    if (t > 10000) continue;
    ans[t]++;
  }
  ll N;
  cin >> N;
  for (ll i = 1; i <= N; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3708
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <bitset>
#include <queue>
using namespace std;

int main()
{
    long long n, ans, suma, sumb;
    cin >> n;
    vector<long long> a(n);
    vector<long long> b(n);
    vector<long long> diff_minus;
    priority_queue<long long> diff_plus;
    ans = 0;
    suma = 0;
    sumb = 0;
    for (int i=0; i<n; ++i){
        cin >> a[i];
        suma += a[i];
    }
    for (int i=0; i<n; ++i){
        cin >> b[i];
        sumb += b[i];
    }
    if(suma < sumb){
        ans = -1;
    }
    else {
        for (int i=0; i<n; ++i){
            if(a[i] == b[i]){
                continue;
            }
            else {
                long long diff = a[i] - b[i];
                if(diff < 0){
                    diff_minus.push_back(diff);
                }
                else if(diff > 0){
                    diff_plus.push(diff);
                }
            }
        }
        long long plus_itr = 0;
        sort(diff_minus.begin(), diff_minus.end());
        long long p = 0;
        for (int i=0; i<diff_minus.size(); ++i){
            long long d = diff_minus[i];
            // cout << i+1 << " -> " << d << endl;
            while(d < 0){
                if(p > 0){
                    if(abs(d) <= abs(p)){
                        p += d;
                        d = 0;
                    }
                    else {
                        d += p;
                        p = 0;
                    }
                    // cout << "(d, p) -> " << d << ", " << p << endl;
                }
                else if(p == 0){
                    p = diff_plus.top();
                    diff_plus.pop();
                    plus_itr++;
                }
            }
        }
        ans = plus_itr + diff_minus.size();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3272
#include <stdio.h>
#include <string.h>
#define mod 1000000007
#define Maxn 10005
#define Maxd 105
char s[Maxn];
int dp[Maxn][Maxd][2],p,d,len;
int dfs(int idx,int z,int t)
{
	if (idx==len) return !z;
	int *res=&dp[idx][z][t];
	if (~*res) return *res;*res=0;
	int x=s[idx]-'0',r=(t?x:9);
	for (int i=0;i<=r;i++)
		*res=(*res+dfs(idx+1,(z+i)%d,t&&i==r))%mod;
	return *res;
}
int main()
{
	memset(dp,-1,sizeof(dp));
	scanf("%s\n%d",s,&d);len=strlen(s);
	printf("%d\n",(dfs(0,0,1)-1+mod)%mod);
	return 0;
}

Measured memory_bytes: 9216
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int DP[60][60][60][60][2][3];
// DP[i][j][k][l][p][q] : 
// プレイヤー１のカードがｉから積まれ、次のカードはｋ
// プレイヤー２のカードがｊから積まれ、次のカードはｌ
// 次がプレイヤー１のターンの場合、p = 0
// パスが連続した回数を q とおく

long long int Sa[100] = {}, Sb[100] = {};

int main(){
    int n, m;
    cin >> n >> m;
    long long int a[100], b[100];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        Sa[i + 1] = max(a[i], 0LL) + Sa[i];
    }
    for(int i = 0; i < m; i++){
        cin >> b[i];
        Sb[i + 1] = max(b[i], 0LL) + Sb[i];
    }
    for(int k = n; k >= 0; k--)for(int l = m; l >= 0; l--)
    for(int i = k; i >= 0; i--)for(int j = l; j >= 0; j--)
    {
        DP[i][j][k][l][0][2] = 0;
        if(k != n){
            if(a[k] == -1){
                DP[i][j][k][l][0][2] = max(DP[i][j][k][l][0][2], DP[i][l][k + 1][l][1][0]);
            }else{
                DP[i][j][k][l][0][2] = max(DP[i][j][k][l][0][2], DP[i][j][k + 1][l][1][0]);
            }
        }
        DP[i][j][k][l][1][2] = 0;
        if(l != m){
            if(b[l] == -1){
                DP[i][j][k][l][1][2] = min(DP[i][j][k][l][1][2], DP[k][j][k][l + 1][0][0]);
            }else{
                DP[i][j][k][l][1][2] = min(DP[i][j][k][l][1][2], DP[i][j][k][l + 1][0][0]);
            }
        }
        DP[i][j][k][l][0][1] = DP[i][j][k][l][1][2];
        if(k != n){
            if(a[k] == -1){
                DP[i][j][k][l][0][1] = max(DP[i][j][k][l][0][1], DP[i][l][k + 1][l][1][0]);
            }else{
                DP[i][j][k][l][0][1] = max(DP[i][j][k][l][0][1], DP[i][j][k + 1][l][1][0]);
            }
        }
        DP[i][j][k][l][1][1] = DP[i][j][k][l][0][2];
        if(l != m){
            if(b[l] == -1){
                DP[i][j][k][l][1][1] = min(DP[i][j][k][l][1][1], DP[k][j][k][l + 1][0][0]);
            }else{
                DP[i][j][k][l][1][1] = min(DP[i][j][k][l][1][1], DP[i][j][k][l + 1][0][0]);
            }
        }
        DP[i][j][k][l][0][0] = DP[k][l][k][l][1][1] + Sa[k] - Sa[i] - Sb[l] + Sb[j];
        if(k != n){
            if(a[k] == -1){
                DP[i][j][k][l][0][0] = max(DP[i][j][k][l][0][0], DP[i][l][k + 1][l][1][0]);
            }else{
                DP[i][j][k][l][0][0] = max(DP[i][j][k][l][0][0], DP[i][j][k + 1][l][1][0]);
            }
        }
        DP[i][j][k][l][1][0] = DP[k][l][k][l][0][1] + Sa[k] - Sa[i] - Sb[l] + Sb[j];
        if(l != m){
            if(b[l] == -1){
                DP[i][j][k][l][1][0] = min(DP[i][j][k][l][1][0], DP[k][j][k][l + 1][0][0]);
            }else{
                DP[i][j][k][l][1][0] = min(DP[i][j][k][l][1][0], DP[i][j][k][l + 1][0][0]);
            }
        }
    }
    cout << DP[0][0][0][0][0][0] << endl;
}


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


int main(){
int n;
cin >> n;
int n2 = 1 << n;
vector<int> s(n2);
rep(i,n2){
    cin >> s[i];
}
vector<int> a;

sort(s.begin(),s.end());
a.push_back(s.back());
s.back() = -1;


rep(i,n) {
    vector<int> p = a;
    sort(p.begin(),p.end());
    int idx = n2-1;

    while(p.size() >0 && idx >= 0){
        if(s[idx] == -1){
            idx--;
            continue;
        }
        if(s[idx] < p.back()){
            a.push_back(s[idx]);
            p.pop_back();
            s[idx] = -1;
        }
        idx--;
    }
    if(p.size() > 0){
        puts("No");
        return 0;
    }
}

puts("Yes");
return 0;

}

Measured memory_bytes: 2932
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
 

public class Main{
          
     
     public static void main(String args[]){
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
         try{
             String line;
             
            while((line=br.readLine())!= null){if(line.isEmpty())break;
             char[] chrs = line.toCharArray();
             if(chrs[0]=='o'&&chrs[1]=='o'&&chrs[2]=='o'
                     ||chrs[3]=='o'&&chrs[4]=='o'&&chrs[5]=='o'
                     ||chrs[6]=='o'&&chrs[7]=='o'&&chrs[8]=='o'
                     ||chrs[0]=='o'&&chrs[3]=='o'&&chrs[6]=='o'
                     ||chrs[1]=='o'&&chrs[4]=='o'&&chrs[7]=='o'
                     ||chrs[2]=='o'&&chrs[5]=='o'&&chrs[8]=='o'
                     ||chrs[0]=='o'&&chrs[4]=='o'&&chrs[8]=='o'
                     ||chrs[2]=='o'&&chrs[4]=='o'&&chrs[6]=='o'
                )System.out.println("o");
             else if(chrs[0]=='x'&&chrs[1]=='x'&&chrs[2]=='x'
                     ||chrs[3]=='x'&&chrs[4]=='x'&&chrs[5]=='x'
                     ||chrs[6]=='x'&&chrs[7]=='x'&&chrs[8]=='x'
                     ||chrs[0]=='x'&&chrs[3]=='x'&&chrs[6]=='x'
                     ||chrs[1]=='x'&&chrs[4]=='x'&&chrs[7]=='x'
                     ||chrs[2]=='x'&&chrs[5]=='x'&&chrs[8]=='x'
                     ||chrs[0]=='x'&&chrs[4]=='x'&&chrs[8]=='x'
                     ||chrs[2]=='x'&&chrs[4]=='x'&&chrs[6]=='x'
                )System.out.println("x");
             else System.out.println("d");
                
            }br.close();
       
         }catch(Exception e){e.printStackTrace();}         
     }
     
}
  

Measured memory_bytes: 16856
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let a = input[0]
let b = input[1]
if (a...b)~=0 {
  print("Zero")
} else if a<0 && (b-a+1)%2>0 {
  print("Negative")
} else {
  print("Positive")
}

Measured memory_bytes: 4080
#1_C
def isprime(x):
    if x == 2:
        return True

    if x < 2 or x%2==0:
        return False

    i = 3
    while i <= x**(1/2):
        if x%i==0:
            return False
        i = i + 2

    return True

n = int(input())
count = 0
for i in range(n):
    x = int(input())
    if isprime(x):
        count += 1
print(count)


Measured memory_bytes: 5660
#include <bits/stdc++.h>
using namespace std;
	
typedef long long ll;
typedef unsigned long long ull;
typedef long double db;
	
#define MOD 1000000007
#define mi 18446744073709551615
#define ff first
#define ss second
#define pb push_back
#define vii vector<int>
#define pii pair<int,int>
#define vpii vector<pii>

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int T=1;
	// cin>>T;
	while(T--)
	{
		ll n=0;
		char ch;
		scanf("%c",&ch);
		//cout<<ch;
		n=(ch-'0')%9;
		// cout<<n<<" ";
		while(ch>='0'&&ch<='9')
		{
			scanf("%c",&ch);
			if(ch>='0'&&ch<='9')
			{
				// cout<<ch;
				n=(n+(ch-'0'))%9;
				// cout<<n<<" ";
			}
		}
		// cout<<n;
		if(!n)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}  
	return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <vector>

using ll = long long;

int main() {
    int N;
    std::cin >> N;
    ll ans = 0;
    std::vector<ll> counts(5);
    for (int i = 0; i < N; ++i) {
        std::string s;
        std::cin >> s;
        char c = s[0];
        if (c == 'M') {
            counts[0] += 1;
        }
        if (c == 'A') {
            counts[1] += 1;
        }
        if (c == 'R') {
            counts[2] += 1;
        }
        if (c == 'C') {
            counts[3] += 1;
        }
        if (c == 'H') {
            counts[4] += 1;
        }
    }
    for (int i = 0; i < 5; ++i) {
        for (int j = 0; j < i; ++j) {
            for (int k = 0; k < j; ++k) {
                ans += counts[i] * counts[j] * counts[k];
            }
        }
    }
    std::cout << ans << std::endl;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int>vec(2*M);
  
  for(int i=0; i<2*M ; i++){
    cin >> vec.at(i);}        //すべての都市を配列として入力する。
  
  for(int i=0; i<N ; i++){   //都市ごとにこのfor文内の処理を実行する。
    int sum=0;               //都市ごとに合計は初期化
    
    for(int j=0; j<2*M ; j++){    //都市ごとに道路の数を数えていく処理
      
      if( i+1 == vec.at(j) ){
        sum +=1;}               //i+1=1の時、都市1の道路の数を数え、＋１する。
      
      if( j == 2*M-1 ){   
        cout << sum << endl;
        break;}
    }
    
    if( i == N-1 ){
      break;}
  }
}

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

int main(){
  char s[19];
  for(int i=0;i < 19;i++){
    cin >> s[i];
  }
  s[5] = ' ';
  s[13] = ' ';

  for(int i=0;i < 19;i++){
   cout << s[i];
  }
  cout << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#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 <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  set<lint> st;
  lint n, m; cin >> n >> m;
  lint AC = 0;
  int cnt[1000000] = {};
  for(int i = 0; i < m; i++) {
    lint p; cin >> p;
    string s; cin >> s;
    if(s == "AC") {
      if(st.count(p)) continue;
      AC++;
      st.insert(p);
    } else {
      if(st.count(p)) continue;
      cnt[p]++;
    }
  }

  lint WA = 0;
  for(int i = 1; i <= n; i++) {
    if(st.count(i)) WA += cnt[i];
  }
  cout << AC << " " << WA << endl;
  
  return 0;
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forn for(int i=0;i<n;i++)
#define pb push_back
#define pob pop.back()
int main()
{
  int x;
  cin>>x;
  if(x==3 || x==5 || x==7) cout<<"YES";
  else cout<<"NO";
  return 0;
  
    
    
}

Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,sum=0;
  cin >> n;
  vector<ll> a(n);
  map<ll,ll> mp;
  for(int i=0;i<n;i++){
    cin >> a[i];
    mp[a[i]]++;
  }
  for(auto i:mp){
    sum += (i.second*(i.second-1))/2;
  }
  for(int i=0;i<n;i++){
    ll v = mp[a[i]];
    ll tmp = sum;
    tmp -= (v*(v-1))/2;
    v--;
    tmp += (v*(v-1))/2;
    cout << tmp << endl;
  }
}


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

using namespace std;

int main(){
  int n,d;
  cin >> n >> d;
  int a = 2*d+1;
  int count = 1;
  for(int i = a;i < n;i += a){
    count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
a,b,c=map(int,input().split())
if a==b==c and a%2==0:
    print(-1)
    exit()
ans=0
while a%2==b%2==c%2==0:
    x=(a+b)//2
    y=(b+c)//2
    z=(c+a)//2
    a=y
    b=z
    c=a
    ans+=1
print(ans)

Measured memory_bytes: 9076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    vector<int> s(3);
    for(int i=0; i<3; i++) cin >> s[i];

    sort(s.begin(), s.end());
    if(s[0] == s[1]) cout << s[2] << endl;
    else cout << s[0] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(v) (ll((v).size()))
#define forn(i,n) for(ll i=0;i<(n);i++)
#define forr(i,n) for(ll i=(n)-1;i>=0;i--)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
#define clr(x) memset(x,0,sizeof(x))

const ll N =1010;
const ll mod =1e9+7;
char c;
ll a[N][N],dp[N][N],n,m;



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

    clr(a);clr(dp);
    cin>>n>>m;forn(i,n)forn(j,m){cin>>c;if(c=='.')a[i][j]=1;}
    dp[0][0]=1;
    forn(i,n)forn(j,m)
    {
    	if(i!=0)if(a[i-1][j])dp[i][j]+=dp[i-1][j];
    	if(j!=0)if(a[i][j-1])dp[i][j]+=dp[i][j-1];
    	dp[i][j]%=mod;
    }
    cout<<dp[n-1][m-1]<<endl;
}


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

const long long INF = 1LL<<60;
long long dp[110][100010];

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

    int weight[110];
    int value[110];
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];

    // dp配列を初期化
    for (int i = 0; i < 110; ++i) {
        for (int j = 0; j < 100010; ++j) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;

    // dp配列を緩和
    for (int i = 1; i <= N; ++i) {
        for (int j = 0; j <= 100000; ++j) {
            dp[i][j] = min(dp[i][j], dp[i - 1][j]);
            if (j >= value[i - 1]) {
                if (dp[i - 1][j - value[i - 1]] + weight[i - 1] <= W) {
                    dp[i][j] = min(dp[i][j], dp[i - 1][j - value[i - 1]] + weight[i - 1]);
                }
            }
        }
    }

    // 価値の最大値を探索
    int ans = 0;
    for (int j = 0; j <= 100000; ++j) {
        if (dp[N][j] != INF) {
            ans = max(ans, j);
        }
    }

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

Measured memory_bytes: 86272
S=str(input())
cnt=0
for i in range(2,len(S)-1):
    if S[i] =='C':
        cnt+=1
if cnt==1:
    if S[0]=='A':
        T = S.replace("C","").replace("A","")
        if T.islower():
            print("AC")
            exit()
print("WA")

Measured memory_bytes: 61688
N = int(input())
# P = list(map(int, input().split()))

if N <= 10:
    print(N)
    exit()

dic = {}
for i in range(11,100):
    if i % 10 == 0:
        continue
    if i % 11 == 0:
        dic[i] = 1
    else:
        dic[i] = 0

for i in range(11, N+1):
    if i % 10 == 0:
        continue
    tmp = str(i)[0] + str(i)[-1]
    dic[int(tmp)] += 1

res = 0
for current, num in dic.items():
    if current % 11 == 0:
        res += num * num
    else:
        tmp = int(str(current)[::-1])
        res += num * dic[tmp]

print(res)


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

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            new Main().solve(in);
        }
    }

    private void solve(Scanner in) {
        int H = in.nextInt(), W = in.nextInt();
        char[][] a = new char[H][W];
        for (int i = 0; i < H; i++) {
            a[i] = in.next().toCharArray();
        }
        char[][] r = new char[H][W];
        char[][] b = new char[H][W];
        // initialize
        for (int i = 0; i < H; i++) {
            Arrays.fill(r[i], DOT);
            Arrays.fill(b[i], DOT);
            r[i][0] = SHA;
            b[i][W - 1] = SHA;
            for (int j = 1; j < W - 1; j++) {
                r[i][j] = (i % 2 == 0) ? SHA : DOT;
                b[i][j] = (i % 2 == 1) ? SHA : DOT;
            }
        }
        // draw
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (a[i][j] == SHA) {
                    r[i][j] = SHA;
                    b[i][j] = SHA;
                }
            }
        }
        show(r);
        System.out.println();
        show(b);
    }

    private static final char DOT = '.', SHA = '#';

    private void show(char[][] cs) {
        for (int i = 0; i < cs.length; i++) {
            System.out.println(new String(cs[i]));
        }
    }
}

Measured memory_bytes: 33180
// abc136d.cpp : Gathering Children
#include <bits/stdc++.h>
using namespace std;
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)

int main(){
	string S; cin>>S; int n = S.length();

	vector<int> ans(n);
	bool sepOrCenter = false; // 切れ目 か 集合場所
	int il, ir, even, odd;
	il = ir = -1;
	up(i,0,n,1){
		if(!sepOrCenter && S[i]=='R'){ // 切れ目
		sepOrCenter = true;
		if(il>=0){
		ans[il] = il%2? odd: even; ans[ir] = ir%2? odd: even;
	}
		even = odd = 0; il = ir = -1;
	}
		else if(sepOrCenter && S[i]=='L'){ // 集合場所（L側）
			sepOrCenter = false;
			il = i; ir = i-1;
		}
		if(i%2) odd++; else even++;
	}
	ans[il] = il%2? odd: even; ans[ir] = ir%2? odd: even;

	ot(ans[0]); up(i,1,n,1) cout<<" "<<ans[i]; ot("\n");
}

Measured memory_bytes: 1024
def main():
    N = int(input())
    A = [-1] + [int(_) for _ in input().split()]
    haco = [0] * (N+1)
    m = 0

    for i in range(1, N+1)[::-1]:
        max_j = N // i
        cc = 0
        for j in range(1, max_j+1):
            cc += haco[i*j]
        cc -= haco[i]
        cc %= 2
        if cc == A[i]: haco[i] = 0
        else:
            haco[i] = 1
            m += 1
    print(m)
    if m:
        for i in range(1, N+1):
            if haco[i]: print(i, end=' ')
        print('')
    return

if __name__ == '__main__':
    main()


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

int main()
{
  int64_t A, B, K;
  cin >> A >> B >> K;
  for (int i = 0; i < K; i++)
  {
    if (i % 2)
    {
      if (B % 2)
        B--;
      A += B / 2;
      B /= 2;
    }
    else
    {
      if (A % 2)
        A--;
      B += A / 2;
      A /= 2;
    }
  }
  cout << A << ' ' << B << endl;
}

Measured memory_bytes: 256
from math import ceil, sqrt


def main():
    n = int(input())
    if n == 2:
        print(1)
        return
    c = 2 + (int(sqrt(n))**2 == n) + (int(sqrt(n - 1))**2 == (n - 1))
    # print(c)
    for k in range(2, ceil(sqrt(n - 1))):
        m = n % k
        if m > 1:
            # print(k, 0)
            continue
        elif m == 1:
            # print(k, 2)
            c += 2
        else:
            p = n // k
            while p % k == 0:
                p //= k
            if p % k == 1:
                # print(k, 1)
                c += 1
            # else:
                # print(k, 0)
    print(c)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
S = input()
S = S + "s"
s = [0] * len(S)

rl = "R"
stock = 0
lidx = 0
for i in range(len(S)):
    #print(S[i])
    if S[i] == rl:
        stock += 1
    else:
        if rl == "R":
            s[i-1] += stock // 2 + stock % 2
            s[i] += stock // 2
            lidx = i
        elif rl == "L":
            s[lidx] += stock // 2 + stock % 2
            s[lidx-1] += stock // 2
        rl = S[i]
        stock = 1

    #print(s)

print(" ".join(map(str, s))[:-1])

Measured memory_bytes: 10484
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
	char str[1001];
	fgets(str,1001,stdin);
	int j;
	int len = strlen(str);
	for(j = 0;j < len;j++)
	{
		if(str[j] >= 'a' && str[j] <= 'z')
		{
			str[j] = str[j] - 'a' + 'A';
		}
		if(str[j] == '\n')
		{
			str[j] = '\0';
			len--;
		}
	}
	puts(str);
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		HashMap<String, Integer> map = new HashMap<>();
		map.put("SUN", 7);
		map.put("MON", 6);
		map.put("TUE", 5);
		map.put("WED", 4);
		map.put("THU", 3);
		map.put("FRI", 2);
		map.put("SAT", 1);
		String target = sc.next();
		System.out.println(map.get(target));
	}
}


Measured memory_bytes: 22740
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        
        new Main().q1();
    }
    
    
    public void q1() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
       
        int ni=0;
        int yon=0;
        int zero=0;
        
        
        for(int i = 0; i < n; i++) {
           long in = sc.nextLong();
           if(in%4==0){
               yon++;
           }else if(in %2 == 0){
               ni++;
           }else{
               zero++;
           }
        }

        //二の倍数は二個並べればOK
        //ni = ni%2;
        //zaroは4が同じ数以上あればOK
        //もし2が一つもなければ4を一つ稼げる
        if(ni==0){
            yon++;
        }
        if(zero > yon){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
        
        
        
    }
    
    
}



Measured memory_bytes: 47152
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };
struct nc{
	int number;
	int count;
};
int main() {
	map<string, int> msi;
	FOR(i, 2, 11){
		queue<string> qs;
		REP(j, 3){
			string s2;
			if (j == 0)REP(k, i)s2 += 'r';
			if (j == 1)REP(k, i)s2 += 'g';
			if (j == 2)REP(k, i)s2 += 'b';
			msi.insert({ s2, 0 });
			qs.push(s2);
		}
		while (!qs.empty()){
			string s3 = qs.front(); qs.pop();
			REP(j, i - 1){
				if (s3[j] == 'r' && s3[j + 1] == 'r'){
					string s4 = s3;
					s4[j] = 'g'; s4[j+1] = 'b';
					if (msi.find(s4) == msi.end()){
						msi.insert({ s4, msi[s3] + 1 });
						qs.push(s4);
					}
					s4[j] = 'b'; s4[j + 1] = 'g';
					if (msi.find(s4) == msi.end()){
						msi.insert({ s4, msi[s3] + 1 });
						qs.push(s4);
					}
				}
				if (s3[j] == 'g' && s3[j + 1] == 'g'){
					string s4 = s3;
					s4[j] = 'b'; s4[j + 1] = 'r';
					if (msi.find(s4) == msi.end()){
						msi.insert({ s4, msi[s3] + 1 });
						qs.push(s4);
					}
					s4[j] = 'r'; s4[j + 1] = 'b';
					if (msi.find(s4) == msi.end()){
						msi.insert({ s4, msi[s3] + 1 });
						qs.push(s4);
					}
				}
				if (s3[j] == 'b' && s3[j + 1] == 'b'){
					string s4 = s3;
					s4[j] = 'r'; s4[j + 1] = 'g';
					if (msi.find(s4) == msi.end()){
						msi.insert({ s4, msi[s3] + 1 });
						qs.push(s4);
					}
					s4[j] = 'g'; s4[j + 1] = 'r';
					if (msi.find(s4) == msi.end()){
						msi.insert({ s4, msi[s3] + 1 });
						qs.push(s4);
					}
				}
			}
		}
	}

	string s;
	while (cin >> s, s != "0"){
		if (msi.find(s) != msi.end()){
			cout << msi[s] << endl;
		}
		else{
			cout << "NA" << endl;
		}
	}
}

Measured memory_bytes: 9528
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <map>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
    string s; cin >> s;
    int n=s.size();
    int res=n;
    for(int i=0;i<26;i++){
        int cnt=0;
        int mx=0;
        for(int j=0;j<n;j++){
            if(s[j]==(char)(i+'a')){
                mx=max(mx,cnt);
                cnt=0;
            }
            else cnt++;
        }
        mx=max(mx,cnt);
        res=min(res,mx);
    }
    printf("%d\n",res);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,a[N],b[N];
bool flag=true;
vector<int>v;

int main()
{
    int res=0;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d",&a[i]);
    for(int i=n; i>=1; i--)
    {
        int ans=0;
        for(int j=i; j<=n; j+=i)
            ans+=b[j];
        if(ans%2!=a[i])
            b[i]=1;
    }
    int cot=0;
    for(int i=1; i<=n; i++)
        if(b[i])
            cot++;
    printf("%d\n",cot);
    int k=0;
    for(int i=1; i<=n; i++)
    {
        if(b[i]&&k==0)
        {
            printf("%d",i);
            k++;
        }
        else if(b[i])
            printf(" %d",i);
    }

}


Measured memory_bytes: 2432
#[allow(unused_imports)]
use std::collections::HashSet;

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let hw = read_vec::<usize>();
    let h = hw[0];
    let w = hw[1];

    let mut masu : Vec<Vec<char>> = Vec::with_capacity(h);
    for _i in 0..h {
        let s : Vec<char> = read::<String>().chars().collect();
        masu.push(s);
    }

    let answer = solve(h, w, &masu);
    println!("{}", answer);
}

fn solve(h: usize, w: usize, masu: &[Vec<char>]) -> usize {
    let mut dp : Vec<Vec<(usize, usize)>> = vec![vec![(0, 0);w];2];
    let mut max = 0;
    
    for i in 0..h {
        let curr = i % 2;
        for j in 0..w {
            if masu[i][j] == '#' {
                dp[curr][j] = (0, 0);
                continue;
            }

            // yoko
            if j == 0 || masu[i][j-1] == '#' {
                let mut j1 = j + 1;
                while j1 < w && masu[i][j1] != '#' {
                    j1 += 1;
                }
                dp[curr][j].0 = j1 - j - 1; 
            } else {
                dp[curr][j].0 = dp[curr][j-1].0;
            }

            // tate
            if i == 0 || masu[i-1][j] == '#' {
                let mut i1 = i + 1;
                while i1 < h && masu[i1][j] != '#' {
                    i1 += 1;
                }
                dp[curr][j].1 = i1 - i - 1;
            } else {
                dp[curr][j].1 = dp[1-curr][j].1;
            }

            let val = dp[curr][j].0 + dp[curr][j].1;
            if val > max {
                max = val;
            }
        }
    }
    return max + 1;
}


Measured memory_bytes: 20732
A1,A2,A3=map(int,input().split())
A_1=abs(A1-A2)+abs(A2-A3)
A_2=abs(A1-A3)+abs(A2-A3)
A_3=abs(A1-A2)+abs(A1-A3)
print(min(A_1,A_2,A_3))

Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>
int main()
{
	char kata[55];
	int N,index;
	int K;
	
	scanf ("%d %d",&N,&K);
	getchar();
	scanf ("%s",&kata);
	getchar();
	
	kata[K-1] += 32;
	
	printf("%s",kata);
	
	return 0;
}

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

#define fi first
#define se second
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const long long N = 110;
const long long Q = 10001;
const long long mod = 1e9 + 7;;
const long long block = sqrt(N);

using namespace std;

long long n, m;

void solve()
{
        cin >> n >> m;
        vector < long long > v;
        for(long long i = 1; i * i <= m; i++){
                if(m % i == 0){
                        v.push_back(i);
                        v.push_back(m / i);
                }
        }
        sort(v.begin(), v.end());
        for(int i = v.size() - 1; i >= 0; i--){
                long long g = v[i];
                if(m / g >= n){
                        cout << g << "\n";
                        break;
                }
        }
}

bool mtest = false; int main()
{
        //fin("input.txt");
        //fout("output.txt");
        //fin("substr3.in");
        //fout("substr3.out");
        ios_base::sync_with_stdio(0);
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


Measured memory_bytes: 256
from math import fabs
N = int(input())

weight_list = list(map(int, input().split()))

total_list = [0] * N
for i in range(N):
    list_one = weight_list[: i + 1]
    list_two = weight_list[i + 1:]
    
    abs_diff = fabs(sum(list_one) - sum(list_two))
    
    total_list[i] = abs_diff
print(int(min(total_list)))

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
using namespace std;



int main(){
    int n;
    cin>>n;
    cout<<pow(n,3);   
}


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

#define endl '\n'
#define N 10000000

using namespace std;

typedef unsigned long long int ulli;

bool criba[N + 1];
int primerFactor[N + 1];
ulli n, sumaHasta[N + 1], dp[N + 1];
vector<int> primos;

ulli f(ulli x)
{
    ulli pf = primerFactor[x], c = x, f1 = 1, f2 = 1;
    while (c%pf == 0)
        c /= pf;
    f1 = x / c;
    f2 = c;
    return (dp[f1] * dp[f2]);
}

void precomputo()
{
    for (int i=2; i<=N; ++i)
        criba[i] = true;
    for (int i=2; i*i<=N; ++i)
    {
        if (criba[i])
        {
            for (int j=i*i; j<=N; j+=i)
            {
                if (criba[j])
                {
                    primerFactor[j] = i;
                    criba[j] = false;
                }
            }
        }
    }
    for (int i=0; i<=N; ++i)
        if (criba[i])
            primos.push_back(i);
    dp[1] = 1;
    sumaHasta[1] = 1 * dp[1];
    for (int i=0; i<primos.size(); ++i)
    {
        ulli indice = primos[i], exp = 1;
        while (indice <= N)
        {
            dp[indice] = (exp + 1);
            ++exp;
            indice *= primos[i];
        }
    }
    for (int i=2; i<=N; ++i)
    {
        if (!dp[i])
        {
            dp[i] = f(i);
        }
        sumaHasta[i] = sumaHasta[i - 1] + (i * dp[i]);
    }
}

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

    precomputo();

    ulli n;
    cin >> n;
    cout << sumaHasta[n] << endl;

    return 0;
}

Measured memory_bytes: 210808
#include <iostream>

typedef unsigned long long ull;

int CountDigit(ull num)
{
	int ret = 0;
	while (num > 0)
	{
		++ret;
		num /= 10;
	}
	return ret;
}

ull dfs(ull total, ull num, int digit)
{
	ull n = num / digit;
	ull ret = 0;
	if (digit == 10)
	{
		ret += total + n + (num % 10);
		ret += total + num;
	}
	else
	{
		ret += dfs(total + n, num % digit, digit / 10);
		ret += dfs(total, num, digit / 10);
	}
	return ret;
}

int main()
{
	ull S;
	std::cin >> S;

	int size = CountDigit(S);
	ull ans = S;
	if (size > 1)
	{
		int digit = 1;
		while (--size > 0)
		{
			digit *= 10;
		}

		ans = dfs(0, S, digit);
	}

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


Measured memory_bytes: 3620
//
//  main.cpp
//  ITP1_8-B
//
//  Created by Saicj on 2015/07/15.
//  Copyright (c) 2015??´ saicj. All rights reserved.
//

#include <iostream>
#include <stdio.h>
using namespace std;

int main(int argc, const char * argv[])
{
    char num[1001];
    
    while (1) {
        
        scanf("%s", num);
        
        if (*num == '0') {
            break;
        }
        
        int result = 0;
        
        for (int i = 0; i < 1000; i ++) {
            
            int temp = num[i] - '0';
            
            if (temp < 0 || temp > 9){
                break;
            }
            
            result += temp;
            
            
        }
        
        printf("%d\n", result);
    }
    
//    printf("\n");
    
    return 0;
}

Measured memory_bytes: 1132
#include <iostream>
#include <vector>
#include <utility>
#include <tuple>
#include <limits>

using namespace std;

int n, m;
vector<tuple<int, int, long long>> edge;
vector<long long> d;

bool find_negative_loop(){
    for(int i = 0; i < n; i++){
        for(auto&& e : edge){
            if(d[get<0>(e)] == -1e9 * n) continue;
            if(d[get<1>(e)] < d[get<0>(e)] + get<2>(e)){
                d[get<1>(e)] = d[get<0>(e)] + get<2>(e);
                if(i == n - 1) return true;
            }
        }
    }
    return false;
}

int main(){
    cin >> n >> m;
    edge.resize(m);
    d.resize(n, -1e9 * n);
    d[0] = 0;
    for(auto&& i : edge){
        int a, b;
        long long c;
        cin >> a >> b >> c;
        if(a - 1 == 0){
            d[b - 1] = c;
        }
        i = make_tuple(a - 1, b - 1, c);
    }
    if(find_negative_loop()){
        long long ans = d[n - 1];
        if(find_negative_loop() && ans != d[n - 1]){
            cout << "inf\n";
        }else{
            cout << ans << "\n";
        }
    }else{
        cout << d[n - 1] << "\n";
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */


ll solve(){
    ll res = 0;
    ll X,Y,Z; cin >> X >> Y >> Z;
    for(res = 1;;res++){
        if(Y*res+Z*(res+1) <= X) continue;
        else break;
    }
    res--;
    return res;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 256