akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
vector<int>S;
bool f[111111];
vint p;

signed main(){
    fill_n(f,111111,1);
    vector<int>sq;
    f[0]=f[1]=0;
    for(int i=2;i<=100000;i++){
        if(!f[i])continue;
        p.pb(i);
        sq.pb(i*i);
        for(int j=i+i;j<=100000;j+=i)f[j]=0;
    }

    scanf("%lld",&N);
    map<int,int>cnt;
    rep(i,N){
        int a;
        scanf("%lld",&a);
        for(int j=0;p[j]*p[j]*p[j]<=a;j++){
            int t=p[j]*p[j]*p[j];
            while(a%t==0)a/=t;
        }
        cnt[a]++;
    }

    int ans=0;
    if(cnt.count(1)){
        ans++;
        cnt.erase(cnt.begin());
    }

    each(it,cnt){
        int a=it->fi,c=it->se;
        int b=1;
        int k;
        for(k=0;p[k]*p[k]*p[k]<=10000000000ll;k++){
            int h=0;
            while(a%p[k]==0){
                a/=p[k];
                h++;
            }
            if(h==1){
                b*=p[k]*p[k];
            }
            else if(h==2){
                b*=p[k];
            }
            if(b>10000000000ll)break;
        }
        if(b>10000000000ll){
            ans+=c;
            continue;
        }
        if(a>1){
            if(binary_search(all(p),a)){
                b*=a;
                if(b>10000000000ll){
                    ans+=c;
                    continue;
                }
                b*=a;
                if(b>10000000000ll){
                    ans+=c;
                    continue;
                }
            }
            else if(binary_search(all(sq),a)){
                int t=lower_bound(all(sq),a)-sq.begin();
                b*=p[t];
                if(b>10000000000ll){
                    ans+=c;
                    continue;
                }
            }
            else{
                ans+=c;
                continue;
            }
        }
        if(cnt.find(b)==cnt.end()){
            ans+=c;
        }
        else{
            if(c>=cnt[b]){
                ans+=c;
                cnt[b]=0;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6784
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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

map<ll, ll> num;
ll sum[2000100];
ll ans;

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

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

  ll n;  
  cin >> n;
  vector<ll> a(n);
  REP(i,n) cin >> a[i];

  num[0]++;
  sum[0] = 0;
  FOR(i,1,n+1) {
    sum[i] = sum[i-1]+a[i-1];
    num[sum[i]]++;
  }

  //cerr << 200000*(199999)/2 << endl;
  
  for(auto &e: num){
    if(e.second > 1) {
      ans += (e.second-1)*(e.second)/2;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(void){
   string A,B;
   cin>>A>>B;
   if(A.size()==B.size()){
      if(A[0]>B[0]) cout<<"GREATER"<<endl;
      else if(A[0]<B[0]) cout<<"LESS"<<endl;
      else cout<<"EQUAL"<<endl;
   }else if(A.size()>B.size()){
      cout<<"GREATER"<<endl;
   }else{
      cout<<"LESS"<<endl;
   }
   return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

#define max 100000

int partition(int *,int,int);

int main(){
  int n,i,p;
  int A[max];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  p = partition(A,0,n-1);

  for(i=0;i<n;i++){
    if(i == p)
      printf("[%d] ",A[i]);
    else if(i == n-1)
      printf("%d\n",A[i]);
    else
      printf("%d ",A[i]);
    }
 
  return 0; 
}
int partition(int *A,int p,int r){
  int x,i,j,tmp;
  x = A[r];
  i = p-1;
  
  for(j=p;j<=r-1;j++){
    if(A[j]<= x){
      i = i+1;

      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }

  A[r] = A[i+1];
  A[i+1] = x;
  
  return i+1;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long int i64;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string>) {}
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << a << endl; err(++it, args...); }
template<typename T1,typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& buf) {
  return os << "(" << buf.first << ": " << buf.second << ")"; }
#define DefOut(Con) template<typename T>ostream&operator<<(ostream&os,Con<T>&A){ bool f = false; os << "{"; \
  for (auto &e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
#define DefOut2(Con) template<typename K,typename V>ostream&operator<<(ostream&os,Con<K,V>&A) \
{ bool f = false; os << "{"; for (auto &e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
template<typename T>ostream &operator << (ostream &os,vector<vector<T>>& A) {
  for (auto &B: A) os << '\n' << B; return os; }
DefOut(vector) DefOut(set) DefOut(multiset) DefOut2(map) 
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1000000007;
long long const INF = 1e18;
#define PI 3.14159265358979323846
/***********************************************************************/

int32_t main() {

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

  int n; cin >> n;
  map<string,set<pair<int,int>>> m;
  for (int i = 0; i < n; ++i) {
    string s; cin >> s;
    int x; cin >> x;
    m[s].insert({-x,i});
  }
  for (auto it = m.begin(); it != m.end(); ++it) {
    for (auto e: it->second) {
      cout << e.second + 1 << '\n';
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

i64 dp[51][5001];

int main() {
    int N,A; cin>>N>>A;
    int x[N]; REP(i,N) cin>>x[i];
    REP(i,N) x[i] -= A;
    dp[0][2500] = 1;
    REP(j,N) {
        REP(i,5001) {
            dp[j+1][i] += dp[j][i];
            dp[j+1][i+x[j]] += dp[j][i];
        }
    }
    cout<<dp[N][2500]-1<<endl;
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

map<int, int> prime_divisor(int x){
    map<int, int> res;
    for(int i = 2; (ll)i * i <= x; ++i){
        while(x % i == 0){
            ++res[i];
            x /= i;
        }
    }
    if(x != 1)  ++res[x];
    return res;
}

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

ll modinv(ll a, ll m){
    ll b = m, u = 1, v = 0;
    while(b){
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if(u < 0)   u += m;
    return u;
}

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

    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> common;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        map<int, int> prime = prime_divisor(a[i]);
        for(auto it : prime){
            if(common.find(it.first) == common.end()){
                common[it.first] = it.second;
            }
            else{
                common[it.first] = max(common[it.first], it.second);
            }
        }
    }
    ll mul = 1;
    for(auto it : common){
        mul = mul * modpow((ll)it.first, it.second, mod) % mod;
        // cerr << "(" << it.first << "," << it.second << ") ";
        // cerr << mul << "\n";
    }
    ll res = 0;
    for(int i = 0; i < n; ++i){
        ll add = mul * modinv((ll)a[i], mod) % mod;
        chadd(res, add);
    }
    cout << res << endl;
}

Measured memory_bytes: 768
N, C, K, *T = map(int, open(0).read().split())
T.sort()
head, tail = 0, 1  # half-open interval
cnt = 0
while tail <= N:
    while tail < N and tail - head < C and T[head] + K >= T[tail]:
        tail += 1
    cnt += 1
    head, tail = tail, tail + 1
print(cnt)

Measured memory_bytes: 14052
#include <bits/stdc++.h>
using namespace std;
int dp[105][105][305];
long long w[105];
int v[105];
int main()
{
    long long W;
    int ans = 0, n;
    scanf("%d%lld", &n, &W);
    for (int i = 0; i < n; i++) {
        scanf("%lld%d", &w[i], &v[i]);
    }
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= n; j++) {
            for (int k = 0; k <= 3 * j; k++) {
                dp[i + 1][j][k] = max(dp[i][j][k], dp[i + 1][j][k]);
                if (k - (w[i] - w[0]) >= 0) dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j - 1][k - (w[i] - w[0])] + v[i]);
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            for (int k = 0; k <= 3 * j; k++) {
                if (W - j * w[0] >= k) ans = max(ans, dp[i][j][k]);
                //printf("dp[%d][%d][%d] = %d\n", i, j, k, dp[i][j][k]);
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 12800
import sys
from sys import stdin
input = stdin.readline

n = int(input())
D = {}
for i in range(n):
    s = input()
    if s[0] == "i":
        D[s[7:]] = 11111111111111111111111111111111111
    else:
        print("yes" if s[5:] in D else "no")



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

using ll=long long;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int div1(ll x){
  return x%1000000007;
}

int xy(int x,int y){
    if (x ==1 && y== 1) return 400000;
    return 0;
}

main(){
    int n=in(),sum=0;
    deque<ll> a;
    for (int i=0;i<n;i++) a.push_back(in());
    ll m=0;
    bool fb=true;
    while(!a.empty()){
        if (fb){
            m+=a.front();
            a.pop_front();
            if (m>0) fb=false;
        }
        else {
            m-=a.back();
            a.pop_back();
            if (m<0) fb=true;
        }
    }
    cout << abs(m) << endl;
}

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

int main(){
  int N;
  cin >> N;
  int Ans=0;
  for(int i=1; i<=9; i++){
    if(N%i==0 && N/i<=9){
      Ans=1;
      break;
    }
  }
  if(Ans==1){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
//daddy's back in town, back to rolling the damn hash yoooo babeeeeees//
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
#define int ll
const ll mod = 1000000007;
int n, k, ans, a[100010], f[100010]; //c[i]-combinari i din k

int pw(int x, int y){
	if(y==0) return 1;
	int a=pw(x, y/2)%mod;
	return ((a*a)%mod)*(y%2 ? x : 1)%mod;
}

int inv(int x){
	return pw(x, mod-2);
}

int ff(int k, int m){
	int ans=f[m];
	ans*=inv(f[k]);
	ans%=mod;
	ans*=inv(f[m-k]);
	ans%=mod;
	return ans;
}

int32_t main(){
	ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	cin>>n>>k;
	for(int i=1; i<=n; i++) cin>>a[i];
	sort(a+1, a+n+1);
	f[0]=1;
	for(int i=1; i<=n; i++) f[i]=f[i-1]*i, f[i]%=mod;
	for(int i=1; i<=n; i++){
		int f=i, l=n-i+1;
		if(f>=k) ans+=a[i]*ff(k-1, f-1);
		ans%=mod;
		if(l>=k) ans-=a[i]*ff(k-1, l-1);
		ans%=mod; ans+=mod; ans%=mod;
	}
	cout<<ans;
}

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

int main()
{
   int64_t n,a,b;
   char s[10][10];
   for(int i=0;i<3;i++)
   {
       for(int j=0;j<3;j++){
        cin>>s[i][j];
        //if(i==j) cout<<s[i][j];
       }
   }
   for(int i=0;i<3;i++)
   {
       for(int j=0;j<3;j++){
        //cin>>s[i][j];
        if(i==j) cout<<s[i][j];
       }
   }

    return 0;
}


Measured memory_bytes: 256
while True:
    try:
        W, H, x, y = map(int, input().split())
        
        if (x*2 == W) and (y*2 == H):
            res = 1
        else:
            res = 0
            
        print("%.6f %d" % (W*H/2, res))
    except:
        break

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

int main()
{
  int cnt = 0, a, b;
  long long int price = 0, num = 0;
  while (~scanf("%d,%d", &a, &b)) {
    price += (a * b);
    num += b;
    ++cnt;
  }

  cout << price << endl;
  cout << static_cast<int>(num / static_cast<double>(cnt) + 0.5) << endl;
}

Measured memory_bytes: 0
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        double area = (a*b*Math.sin(Math.toRadians(c)))/2;
        double length = a+b+Math.sqrt(Math.pow(a,2)+Math.pow(b,2)-(2*a*b*Math.cos(Math.toRadians(c))));
        double h = (2*area)/a;
        System.out.println(String.format("%.5f",area));
        System.out.println(String.format("%.5f",length));
        System.out.println(String.format("%.5f",h));
    }
}


Measured memory_bytes: 26316
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
N = int(input())

sum = 0
for _ in range(N) :
  L, R = map(int, input().split())
  sum += R-(L-1)

print (sum)
  

Measured memory_bytes: 38896
#include <algorithm>
#include <cstdlib>
#include<iostream>
#include<vector>
#include<map>
using namespace std;

int main(int argc, char const *argv[])
{
    vector<vector<char>> arr;
    arr.resize(3);
    for(int i=0;i<3;i++){
        arr[i].resize(3);
    }
    for(int col=0;col<3;col++){
        for(int raw=0;raw<3;raw++){
            cin>>arr[col][raw];
        }
    }
    cout<<arr[0][0]<<arr[1][1]<<arr[2][2]<<endl;
    /* code */
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	ll h;
	cin>>h;
	ll ans=0;
	ll val=1;
	while ( h)
	{
		h=h/2;
		ans=ans+val;
		val=val*2;
	}
	cout<<ans<<'\n';

}

Measured memory_bytes: 256
import math
A, B, H, M =map(int, input().split())
Min = 60*H + M
long_v = 0.5
short_v = 6
diff = 5.5*Min%360
print((A**2 + B**2 - 2*A*B*math.cos(math.radians(diff)))**0.5)

Measured memory_bytes: 62280
#include <stdio.h>

int main() {
	long long int N, A, B;
	scanf("%lld%lld%lld",&N,&A,&B);
	if ((N - N / (A + B) * (A + B)) >= A) {
		printf("%lld", N / (A + B) * A + A);
	}
	else {
		printf("%lld", N / (A + B) * A + (N - N / (A + B) * (A + B)));
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<vector>
#include<array>
#include<cmath>
#include <algorithm>

using namespace std;
#define ull unsigned long long
int gcd(int a, int b) {
	if (a % b == 0) {	
			return b;
	}
	else {
			return gcd(b,a%b);
	}
}
int main() {
	// 初期処理(iostream軽くする)
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	int temp = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			for (int k = 1; k <= n; k++) {
				temp += gcd(gcd(i, j), gcd(i, k));
			}
		}
	}

	cout << temp;
	return 0;
}

Measured memory_bytes: 3660
import math
import collections


def C(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N = int(input().split()[0])
a_list = list(map(int, input().split()))

counter = collections.Counter(a_list)
ans_dict_1 = {}
ans_dict_2 = {}

for k, v in counter.items():
    if v >= 2:
        ans_dict_1[k] = C(v, 2)
    if v >= 3:
        ans_dict_2[k] = C(v - 1, 2)
total_w = sum(ans_dict_1.values())

for k in range(N):
    n = a_list[k]

    if counter[n] >= 3:
        w = total_w - ans_dict_1[n] + ans_dict_2[n]
    elif counter[n] >= 2:
        w = total_w - ans_dict_1[n]
    else:
        w = total_w
    print(w)



Measured memory_bytes: 120652
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main()
{

    int n, m;
    cin >> n >> m;
    vector<int> f(n + 3);
    int a = 0, b = 0;
    for (int i = 0; i < m; i++) {
        int x;
        string p;
        cin >> x >> p;
        if (p == "WA") {
            if (f[x] <= m) {
                f[x]++;
            }
        }
        else {
            if (f[x] <= m) {
                b += f[x];
                f[x] = m + 5;
                a++;
            }
        }
    }

    cout << a << " " << b << endl;

    return 0;

}


Measured memory_bytes: 768
#include <iostream>
#include <stdio.h>
using namespace std;

int m[10][10];
int ax[12]={0,1,0,-1,1,1,-1,-1,0,2,0,-2};
int ay[12]={-1,0,1,0,-1,1,1,-1,-2,0,2,0};

void dfs(int x,int y,int size){
  m[x][y]+=1;
  if(size==1){
    for(int i=0;i<4;i++){
      if(x-ax[i]<0 || x-ax[i]>9 || y-ay[i]<0 || y-ay[i]>9) continue;
      m[x-ax[i]][y-ay[i]]+=1;
    }
  }else if(size==2){
    for(int i=0;i<8;i++){
      if(x-ax[i]<0 || x-ax[i]>9 || y-ay[i]<0 || y-ay[i]>9) continue;
      m[x-ax[i]][y-ay[i]]+=1;
    }
  }else if(size==3){
    for(int i=0;i<12;i++){
      if(x-ax[i]<0 || x-ax[i]>9 || y-ay[i]<0 || y-ay[i]>9) continue;
      m[x-ax[i]][y-ay[i]]+=1;
    }
  }

}


int main(){
  int x,y,size,clear=0,color=0;

  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      m[i][j]=0;
    }
  }

  while(scanf("%d,%d,%d",&x,&y,&size) != EOF){
    dfs(x,y,size);
  }

  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      if(m[i][j]==0){
	clear++;
      }else if(m[i][j]>color){
	color=m[i][j];
      }

    }
  }

  cout << clear << endl;
  cout << color << endl;

}

Measured memory_bytes: 1204
fn main(){
  let n: usize = read();
  let mut sdv: Vec<Vec<i32>> = Vec::new();

  for _ in 0 .. n {
    sdv.push(read_vec());
  }

  let mut dp: Vec<Vec<(f64, i32, usize)>> = vec![vec![(1000000000.0, 0, 0);n]; (1 << n)];
  
  for i in 0 .. n {
    dp[1 << i][i] = (0f64, sdv[i][2], 16usize);
  }
  
  for s in 1 .. (1 << n) {
    for i in 0 .. n {
      if s & (1 << i) > 0 {
        for j in 0 .. n {
          if s & (1 << j) == 0 {
            let &(ot, _, _) = &dp[s|(1 << j)][j];
            let &(ct, cc, _) = &dp[s][i];
            let nt = time((sdv[i][1] - sdv[j][1]).abs(), cc) + ct; 
            if ot > nt {
              dp[s|(1 << j)][j] = (nt, cc + sdv[j][2], i);
            }
          }
        }
      }
    }
  }
  
  let mut ti: usize = 16;
  let mut tt: f64 = 1000000000.0;
  let mut ts: usize = (1 << n) - 1;
  
  for i in 0 .. n {
    let &(t, _, _) = &dp[ts][i];
    if tt > t {ti = i; tt = t}
  }

  let mut ans: Vec<i32> = Vec::new();
  ans.push(sdv[ti][0]);
  
  loop {
    let &(_, _, i) = &dp[ts][ti];
    if i == 16 { break; }
    ts = ts & !(1 << ti);
    ti = i;
    ans.push(sdv[ti][0]);
  }

  for i in 0 .. n {
    if i == n-1 {
      println!("{}", ans[n-1-i]);
    } else {
      print!("{} ", ans[n-1-i]);
    }
  }
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}

fn time(l: i32, c: i32) -> f64 {
  (l as f64) * (70.0 + (c as f64) * 20.0) / 2000.0
}



Measured memory_bytes: 17316
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<map>
#include<set>
#include<cstring>
#include<string>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define SZ(a) (int)((a).size())
using namespace std;
typedef long long ll;
typedef double db;
typedef pair <int, int> Pii;
typedef pair <ll, int> Pli;
typedef unsigned long long ull;
const double eps = 1e-8;
const ll infll = 0x7fffffffffffffff;
const int mod = (int)(1e9) + 7;
const int inf = 0x7fffffff;
const int maxn = (int)(2e5) + 7;
const int maxm = 300;

ll N, M;

int main() {
	
	scanf("%lld%lld", &N, &M);
	if (N & 1) {
		for (ll i = 1; i <= M; i++) 
			printf("%lld %lld\n", i, N - i + 1);
	} else {
		ll lim = N / 2 - 1;
		if (lim & 1) lim = lim / 2 + 1;
		else lim /= 2;//能够构造出的个数中奇数个数
		for (ll i = 1; i <= M; i++) 
			printf("%lld %lld\n", i, N - i + 1 - (i > lim));
	}

	return 0;
}		

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

const int CASES = 3;

void solve(){
    ll S;
    cin >> S;

    ll x1 = 10e8, y1 = 0, x2 = 0, y2 = 0;
    y2 = (S / x1);
    if(y2 < 10e8){
        ++y2;
    }
    ll sum = x1 * y2 - S;
    // S = x1 * y2 - x2 * y1
    for(ll i = 1; i <= 10e9; ++i){
        y1 = i;
        if(sum % y1 != 0) continue;
        x2 = sum / y1;
        if(x2 <= 10e8){
            break;
        }
    }
    cout << "0 0 " << x1 << " " << y1 <<  " " << x2 <<  " " << y2 << '\n';
    return;
}

int main() {
    #ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
    #else

    solve();

    #endif
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    V<int> a(n), b(n), c(n);
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];
    V< V<int> > dp(3, V<int>(n + 1, 0));
    for (int i = 1; i <= n; i++) {
        chmax(dp[0][i], max(dp[1][i - 1], dp[2][i - 1]) + a[i - 1]);
        chmax(dp[1][i], max(dp[0][i - 1], dp[2][i - 1]) + b[i - 1]);
        chmax(dp[2][i], max(dp[0][i - 1], dp[1][i - 1]) + c[i - 1]);
    }
    cout << max({dp[0].back(), dp[1].back(), dp[2].back()}) << '\n';
    return 0;
}


Measured memory_bytes: 5812
N = int(input())
A = list(map(int,input().split()))
prefix_freq = {0 : 1} 
cur = 0
for i in range(N):
  cur += A[i]
  prefix_freq[cur] = prefix_freq.get(cur,0) + 1

ans = 0
for key in prefix_freq.keys():
  if prefix_freq[key] > 1:
    ans += prefix_freq[key] * (prefix_freq[key] - 1) // 2
print(ans)

Measured memory_bytes: 39844
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var k = int.Parse(line[1]);
        var c = int.Parse(line[2]);
        var s = Console.ReadLine().Trim();
        var L = getL(n, k, c, s);
        var R = getR(n, k, c, s);
        getAns(L, R);
    }
    static void getAns(int[] L, int[] R)
    {
        var ans = new List<int>();
        for (int i = 1; i < L.Length; i++)
            if (L[i] == R[i]) ans.Add(L[i]);
        Console.WriteLine(string.Join("\n", ans));
    }
    static int[] getR(int n, int k, int c, string s)
    {
        var a = new int[k + 1];
        var p = n - 1;
        var kc = k;
        while (p >= 0 && kc >= 1)
        {
            if (s[p] == 'o')
            {
                a[kc--] = p + 1;
                p -= c + 1;
            }
            else p--;
        }
        return a;
    }
    static int[] getL(int n, int k, int c, string s)
    {
        var a = new int[k + 1];
        var p = 0;
        var kc = 1;
        while (p < n && kc <= k)
        {
            if (s[p] == 'o')
            {
                a[kc++] = p + 1;
                p += c + 1;
            }
            else p++;
        }
        return a;
    }
}


Measured memory_bytes: 26076
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
int MOD=1000000007;
int n,m;
int k[15];
int s[15][15];
int p[15];
int res;
void solve(vector<bool> const& status){
    int ans=0;
    vector<int> sum(m+1,0);
    rep1(i,m){
        rep1(j,k[i]){
            if(status[s[i][j]])sum[i]++;
        }
    }
    bool flag=true;
    rep1(i,m){
        if(sum[i]%2!=p[i])flag=false;
    }
    if(flag)res++;
}
void calc(vector<bool> status,int cur){
    if(cur==n+1)solve(status);
    else{
    //cout<<cur<<endl;
        calc(status,cur+1);
        status[cur]=true;
        calc(status,cur+1);
    }
}
signed main(){
    cin>>n>>m;
    res=0;
    rep1(i,m){
        cin>>k[i];
        rep1(j,k[i])cin>>s[i][j];
    }
    rep1(i,m)cin>>p[i];
    vector<bool> status(n+1,false);
    calc(status,1);
    int ans=res;
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

ll dp[13][100'008];

int main()
{
    ciosup;
    string s;
    cin >> s;
    int n = s.size();
    //cout << n << endl;
    dp[0][0] = 1;
    int genam = 1;
    REP(i, n)
    {
        if (i == 0){
            genam = 1;
        }else
        {
            genam = (genam * 10) % 13;
        }
        if (s[n - i - 1] == '?')
        {
            REP(k, 10)
            {
                int amari = ((k * genam) % 13);
                //cout << "te" << amari << endl;
                REP(j, 13)
                {
                    dp[(j + amari) % 13][i + 1] = (dp[(j + amari) % 13][i + 1] + dp[j][i]) % MOD;
                }
            }
            //cout << "ki" << endl;
        }
        else
        {
            int amari = (( (int)(s[n - i - 1] - '0') * genam) % 13);
            REP(j,13)
            {
                dp[(j + amari) % 13][i + 1] = (dp[(j + amari) % 13][i + 1] + dp[j][i]) % MOD;
            }
        }
    }
    //cout << dp[1][1] << endl;
    cout << dp[5][n] << endl;
}

Measured memory_bytes: 10704
import sys
from collections import deque, defaultdict
import copy
import bisect
sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import product, permutations,combinations
import fractions
from operator import itemgetter

import sys
def input():
	return sys.stdin.readline().strip()

N = int(input())
S = []
for i in range(N):
	S.append(input())

graph = [[] for _ in range(N)]
for i in range(N):
	for j in range(i):
		if S[i][j] == "1":
			graph[i].append(j)
			graph[j].append(i)

max_num = 0
for root in range(N):
	group = [-1]*N
	group[root] = 0
	group_n = [root]
	num = 1
	judge = 0
	while len(group_n) > 0:
		group_next = []
		for node in group_n:
			for node_next in graph[node]:
				if group[node_next] == -1:
					group[node_next] = num
					group_next.append(node_next)
				elif group[node_next] == num - 1:
					judge = 1
					break
			if judge == 1:
				break
		if judge == 1:
			break
		else:
			num += 1
			group_n = copy.deepcopy(group_next)
	if judge == 0:
		max_num = max(max_num, num)

if max_num > 0:
	print(max_num - 1)
else:
	print(-1)

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

// Function to find pair with given difference in the array
// This method handles duplicates in the array

int main()
{
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
        cin>>arr[i];
        int c=0;
    for(int i=1;i<n-1;i++)
        if(arr[i]>=arr[i-1]&&arr[i]<=arr[i+1]||((arr[i]<=arr[i-1]&&arr[i]>=arr[i+1])))
        c++;
    cout<<c;
	return 0;
}


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

using namespace std;

using ll = long long;


void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
	int n;
	string s;

	cin >> n >> s;

	int dots = count(s.begin(), s.end(), '.');
	int pd = 0;

	int ans = dots;

	for (int i = 1; i <= (int) s.size(); i++)
	{
		pd += (s[i - 1] == '.');

		ans = min(ans, (i - pd) + (dots - pd));
	}

	cout << ans << endl;
}


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

	cout << fixed;

#ifdef LOCAL
	ifstream fin("../input.txt");

	solve(fin);

	cout << setprecision(4) << "clock: " << clock() / (double) CLOCKS_PER_SEC << endl;
#else
	cout << setprecision(20);

	solve();
#endif

	return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

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

    int N, M; cin >> N >> M;
    int lo = 1, hi = N;
    F0R(i, M) {
        int A, B; cin >> A >> B;
        lo = max(lo, A); hi = min(hi, B);
    }
    cout << max(hi - lo + 1, 0) << endl;


    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

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

long long int N, M, a[55], b[55], c[55], d[55], i, j, mi, mj;

int main(){
    scanf("%lld%lld", &N, &M);
    for(i = 0; i < N; ++i){
        scanf("%lld%lld", a + i, b + i);
    }
    for(i = 0; i < M; ++i){
        scanf("%lld%lld", c + i, d + i);
    }
    for(i = 0; i < N; ++i){
        mi = 1145141919810LL;
        mj = 1;
        for(j = 0; j < M; ++j){
            if(abs(a[i] - c[j]) + abs(b[i] - d[j]) < mi){
                mi = abs(a[i] - c[j]) + abs(b[i] - d[j]);
                mj = j;
            }
        }
        cout << mj + 1 << endl;
    }
    //cout <<  << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma once
#pragma once
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<math.h>
#include <iomanip>
#define rep(i,n) for(auto i=0;i<(n);i++)
#define all(vs) (vs).begin(),(vs).end()
#define roundup(A,B) (A)/(B)+((A)%(B)==0?0:1)
#define read(type,name) type name;cin>>name
using namespace std;


/*
	3桁の数字からなる、重複を許す数字列はN^3パターンになる。O(1)
*/
void A() {
	read(int, i);
	cout << i * i * i << endl;
}
void B() {

}
void C() {

}
void D() {

}
void E() {

}
void F() {

}



int main() {
	A();
}

Measured memory_bytes: 3624
package main

import (
	"fmt"
)

func main() {
	var a, b, k int
	fmt.Scanf("%d %d %d", &a, &b, &k)
	var nums []int
	for i := 1; i <= 100; i++ {
		if a%i == 0 && b%i == 0 {
			nums = append(nums, i)
		}
	}
	fmt.Println(nums[len(nums)-k])
}

Measured memory_bytes: 512
n = int(input())
s = input()
M = 0
for i in range(1, n):
    cnt = 0
    s1 = s[0:i]
    s2 = s[i:len(s)]
    t = {}
    for x in s1:
        if x not in t: t[x]=1
    for k in s2:
        if k not in t: t[k]=0
        if t[k] == 1: t[k]+=1
    for x, y in t.items():
        if y==2: cnt+=1
    M = max(cnt, M)
print(M)

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

const int MAXN = 1e5;
const int INF = 1e9;

int vec[MAXN][3];
int dp[MAXN][3];
int n;

int solve(int n, int id, int act)
{
	
	if(id < 0) return 0;
	
	int ans = 0;
	if (dp[id][act] != -1) return dp[id][act];
	
	
	for(int i= 0; i < 3; i++)
		if(i != act)
			ans = max(ans, vec[id][act]+solve(n, id-1, i));
	
	return  dp[id][act] = ans;
}


int main()
{
	cin >> n;
	
	for(int i = 0; i < n; i++)
		cin >> vec[i][0] >> vec[i][1] >> vec[i][2];
	
	
	int ans = 0;
	
	for(int i = 0; i < 3; i++)
	{
		memset(dp, -1, sizeof dp);
		ans = max(ans, solve(n-1, n-1, i));
	}
		
	cout << ans << '\n';
}

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

int main() {
  int Ans;
  int A; cin >>A;
  //int B; cin >>B;
  Ans=((A%1000)==0)?0:1000-(A%1000);
  cout << Ans << '\n';
  return 0;
}


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

int cmp(const void *a,const void *b)
{
  return *(long int*)a - *(long int*)b;
}

//差の最大公約数を求める
int main()
{
  long int N,i,j,count;
  long int X,x[100001],dif[100000],difmin=1000000000,gcd;
  scanf("%ld %ld",&N,&X);
  for(i=0;i<N;i++){
    scanf("%ld",&x[i]);
  }
  x[N] = X;
  qsort(x,N+1,sizeof(long int),cmp);
  for(i=0;i<N;i++){
    dif[i] = x[i+1] - x[i];
    if(difmin>dif[i])difmin=dif[i];
  }
  for(j=difmin;j>0;j--){
    if(difmin%j==0){
      count = 0;
      for(i=0;i<N;i++){
        if(dif[i]%j==0)count++;
      }
      if(count==N){
        gcd = j;
        break;
      }
    }
  }
  printf("%ld",gcd);
  return 0;
}
/* **********************************
cd Documents\c
*********************************** */


Measured memory_bytes: 1788
N = int(input())
p = list(map(int,input().split()))
p_sort = sorted(p)
p_len = len(p)
ans = [0]*p_len
for i in range(p_len):
  ans[i] = p[i]-p_sort[i]

if ans.count(0) >= p_len-2:
  print('YES')
else:
  print('NO')

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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    bool state = false;
    int N; cin >> N;
    set<string> st;
    rep(i, N){
        string S; cin >> S;
        st.insert(S);
    }
    int M; cin >> M;
    rep(i, M){
        string S; cin >> S;
        if(st.count(S) == 1){
            if(state) cout << "Closed by " << S << endl;
            else cout << "Opened by " << S << endl;
            state = !state;
        }
        else cout << "Unknown " << S << endl;
    }
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    int MIN = 200 * 200 * 100;
    for (int i = -100; i <= 100; i++) {
        int sum = 0;
        rep(j, n) {
            sum += (a[j] - i) * (a[j] - i);
        }
        MIN = min(sum, MIN);
    }
    cout << MIN << endl;
}

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

int main(){
    int N,X,r=0,m;
    cin >> N >> X;
    vector<int> vec(N);
    for (int i=0;i<N;i++){
        cin >> vec[i];
    }

    r+=N;
    X-=accumulate(vec.begin(),vec.end(),0);
    m=*min_element(vec.begin(),vec.end());
    r+=X/m;
cout << r << endl;
}

Measured memory_bytes: 256
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_B&lang=jp




import sys
input = sys.stdin.readline



M, W = map(int, input().split())                                # M: 品物の種類 W: 重量制限
single = True                                                   # True = 重複なし

price_list = [0]
weight_list = [0]
for _ in range(M):
    price, weight = map(int, input().split())
    price_list.append(price)
    weight_list.append(weight)


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

dp_min = 0                                                      # 総和価値の最小値


dp = [[dp_min] * (W + 1) for _ in range(M + 1)]                 # 左端と上端の境界条件で W, M を一個ずつ多めに取る
""" dp[item <= M ][weight <= W] = 重さ上限を固定した時の"最大"価値 """

for item in range(M+1):                                         # 左端の境界条件
    dp[item][0] = 0                                             # 重さ 0 を実現するのに必要な品物の個数は 0 個

# for weight in range(W+1):                                     # 上端の境界条件
#     dp[0][weight] = dp_max                                    # 0 種類の品物で実現できる重量は存在しない　（dpの初期化で自動的に課せる場合が多い）


for item in range(1,M+1):                                       # 境界条件を除いた M 回のループ（※ f[item] = g.f[item-i] の漸化式なので、list index out of range となる）
    for weight in range(1, W + 1):
        if weight < weight_list[item]:                          # weight (重量価値) < weight_list[item] (品物の重量) の時は無視してよい
            dp[item][weight] = dp[item - 1][weight]
        else:
            temp = dp[item - single][weight - weight_list[item]] + price_list[item]  # single = True: 重複なし
            if temp > dp[item-1][weight]:                       # max(dp[item-1][weight], temp)
                dp[item][weight] = temp
            else:
                dp[item][weight] = dp[item-1][weight]

print(dp[M][W])


Measured memory_bytes: 25508
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
    ll n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    int t[100010];
    t[0] = 0;
    for(int i=1; i<n; i++){
        if(s[i] == 'C' && s[i-1] == 'A'){
            t[i] = t[i-1] + 1;
        }else{
            t[i] = t[i-1];
        }
    }

    ll l[100010], r[100010];
    for(int i=0; i<q; i++){
        cin >> l[i] >> r[i];
    }
    for(int i=0; i<q; i++){
        cout << t[r[i]-1] - t[l[i]-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 2944
def solve():
    N,M = map(int, input().split())
    accepted = [False]*(N+1)
    AC_num = [0]*(N+1)
    WA_num = [0]*(N+1)
    res = [0,0]
    for _ in range(M):
        p, submit_res = input().split()
        p = int(p)
        if not accepted[p]:
            if submit_res == 'WA':
                WA_num[p] += 1
                # res[1] += 1
            else:
                # res[0] += 1
                AC_num[p] += 1
                accepted[p] = True
                
    res = [sum(accepted[i]*n for i,n in enumerate(AC_num)), sum(accepted[i]*n for i,n in enumerate(WA_num))]
    print(' '.join(map(str, res)))
    
solve()

Measured memory_bytes: 5364
#include<bits/stdc++.h>
using namespace std;
#define int long long int


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(9)<<fixed;
	
	int x,n;
	cin>>x>>n;
	map<int,int> m;
	int t;
	for(int i=0;i<n;i++)
	{
		cin>>t;
		m[t]=1;
	}
	int t1=x;
	while(m[t1]==1)
		t1--;
	int d1=x-t1;
	t1=x;
	while(m[t1]==1)
		t1++;
	int d2=t1-x;
	if(d1<=d2)
		cout<<x-d1<<endl;
	else
		cout<<x+d2<<endl;

	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
const ll INF = numeric_limits<ll>::max();

vector<ll> a;
vector<vector<ll>> net;
vector<ll> ans;
vector<ll> dp;

void solve(ll cur, ll par){
    const ll ai = a.at(cur);
    const ll idx = lower_bound(ALL(dp), ai) - dp.begin();
    const ll prev = dp.at(idx);
    dp.at(idx) = min(prev, ai);
    const ll maxlen = lower_bound(ALL(dp), INF) - dp.begin();
    ans.at(cur) = maxlen;
    for(ll nxt : net.at(cur)){
        if(nxt == par){ continue; }
        solve(nxt, cur);
    }
    dp.at(idx) = prev;
}

int main(){
    ll n;
    cin >> n;
    a.resize(n);
    REP(i, n){
        cin >> a.at(i);
    }
    net.resize(n);
    REP(i, n - 1){
        ll ui, vi;
        cin >> ui >> vi;
        ui--; vi--;
        net.at(ui).push_back(vi);
        net.at(vi).push_back(ui);
    }

    ans.resize(n);
    dp.resize(n);
    fill(ALL(dp), INF);
    solve(0, -1);
    for(ll x : ans){
        cout << x << endl;
    }
}


Measured memory_bytes: 33148
x=int(input())

n=2*10**5
is_prime=[True]*(n+1)
is_prime[0]=False
is_prime[1]=False
for i in range(2,int(n**0.5)+1):
  if not is_prime[i]:
    continue
  for j in range(i*2,n+1,i):
    is_prime[j]=False

for i in range(x,n):
  if is_prime[i]:
    print(i)
    break
  else:
    continue

Measured memory_bytes: 4596
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;


public class Main
{
	
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		ArrayList<String> wordArray = new ArrayList<String>();
		ArrayList<String> dicArray = new ArrayList<String>();
		ArrayList<Integer> dicCount = new ArrayList<Integer>();
		
		while(true)
		{
			//入力
			int n = Integer.valueOf(sc.nextLine());
			if(n==0)
				break;
			wordArray.clear();
			dicArray.clear();
			dicCount.clear();
			for(int i=0;i<n;i++)
			{
				String word = sc.nextLine();
				String[] wordSplit = word.split(" ");
				for(int j=0;j<wordSplit.length;j++)
				{
					wordArray.add(wordSplit[j]);
				}
			}
			Collections.sort(wordArray);
			
			//検索
			String k = sc.nextLine();
			String tmp = "";
			int count = 1,maxCount = -1;
			for(int i=0;i<wordArray.size();i++)
			{
				if(wordArray.get(i).charAt(0)==k.charAt(0))
				{
					if(tmp.equals(wordArray.get(i)))
					{
						count++;
						dicCount.set(dicCount.size()-1,count);
					}
					else
					{
						tmp = wordArray.get(i);
						dicArray.add(tmp);
						dicCount.add(1);
						count = 1;
						
					}
					if(maxCount<count)
						maxCount=count;
				}
				
			}
			//出力
			int flg=0;
			for(int i=0;i<5;i++)
			{
				int index = dicCount.indexOf(maxCount);
				if(index!=-1)
				{	
					if(i!=0)
						System.out.print(" ");
					System.out.print(dicArray.get(index));
					dicArray.remove(index);
					dicCount.remove(index);
					flg=1;
				}
				else
				{
					maxCount--;
					i--;
				}
				if(maxCount<0)
					break;
			}
			if(flg==0)
				System.out.print("NA");
			System.out.println();

		}
	}

}

Measured memory_bytes: 51148
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

int main() {
    int n;
    cin >> n;
    cout << n * n * n;
}

Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<stack>

int eval(std::stack<std::string> &stc){
    int a, b;
    if(stc.top() == "+"){
        stc.pop();
        a = std::stoi(stc.top());
        stc.pop();
        b = std::stoi(stc.top());
        stc.pop();
        return a+b;
    } else if (stc.top() == "-") {
        stc.pop();
        a = std::stoi(stc.top());
        stc.pop();
        b = std::stoi(stc.top());
        stc.pop();
        return b-a;
    } else if (stc.top() == "*") {
        stc.pop();
        a = std::stoi(stc.top());
        stc.pop();
        b = std::stoi(stc.top());
        stc.pop();
        return a*b;
    }
}


int main(){
    int ans = 0;
    std::string str;
    std::stack<std::string> stc;
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);


    while(std::cin >> str){
       stc.push(str);
       if(stc.top() == "+" || stc.top() == "-" || stc.top() == "*") {
           str = std::to_string(eval(stc));
           stc.push(str);
       }
    }

    std::cout << stc.top() << std::endl;
    return 0;
}

Measured memory_bytes: 3296