akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AOZ
{
	class MainClass
	{
		static void Main(string[] args)
		{
			int h, w;
			StringBuilder ans = new StringBuilder();
			do
			{
				var input_arr = Console.ReadLine().Split(' ');
				h = int.Parse(input_arr[0]); w = int.Parse(input_arr[1]);
				if (h == 0 && w == 0)
					break;
				else
				{
					StringBuilder sb = new StringBuilder();
					for (int h_i = 0; h_i < h; h_i++)
					{
						for (int w_i = 0; w_i < w; w_i++)
						{
							sb.Append("#");
						}
						sb.AppendLine();
					}
					ans.AppendLine(sb.ToString());
				}
			} while (true);
			Console.Write(ans.ToString());
		}
	}
}



Measured memory_bytes: 15936
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<int, int> qii;
typedef pair<int, int> pii;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rept(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}


//最大公約数を返す関数
int gcd(int n) {
	return 0;
}


//最小公倍数を返す関数
int mcd(int n) {
	return 0;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1-x2),2) + pow(abs(y1-y2),2));
}


int main()
{
	int w, h, x, y;
	cin >> w >> h >> x >> y;

	double ans_area =double(w) * double(h) / 2;


	if (2 * x == w && 2 * y == h){
		cout <<fixed <<setprecision(8)<< double(w) * double(h) / 2 << " " << 1 << endl;
	}
	else {
		cout << fixed << setprecision(8) << double(w) * double(h) / 2 << " " << 0 << endl;
	}

	system("pause");
	return 0;
}

Measured memory_bytes: 752
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
	ll n;
	cin >> n;
	char arr[26];
	for(int i=0;i<26;i++)
		arr[i] = i+'a';
	vector<char> ans;
	while(n--){
		ll rem = n%26;
		ans.push_back(arr[rem]);
		n /= 26;
	}
	for(int i=ans.size()-1;i>=0;i--)
		cout << ans[i];
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main(){
  ll N,A[200007],X;
  cin >> N;
  if(N%2==0){
    rep(i,N){
      cin >> X;
      if(i%2==0){
        A[N/2+i/2]=X;
      }
      else{
        A[N/2-(i+1)/2]=X;
      }
    }
  }
  else{
    rep(i,N){
      cin >> X;
      if(i%2==0){
        A[N/2-i/2]=X;
      }
      else{
        A[N/2+(i+1)/2]=X;
      }
    }
  }
  rep(i,N){
    cout << A[i];
    if(i<N-1){
      cout << " ";
    }
    else{
      cout << endl;
    }
  }
}

Measured memory_bytes: 3712
import collections
N = int(input())
cA = collections.Counter([int(_) for _ in input().split()])
cand = set(range(1, 1000001))
ans = 0
for a in sorted(cA.keys()):
    if a in cand:
        if cA[a] == 1:
            ans += 1
        for c in range(a, 1000001, a):
            if c in cand:
                cand.remove(c)
print(ans)


Measured memory_bytes: 179236
#include<bits/stdc++.h>
#define Accepted 0
using namespace std;
typedef long long ll;
const int maxn = 1000000 + 10;
int T, cases, n, m;
int a[maxn];
map<int, int>Map1, Map2;
int main()
{
	cin >> n;
	int Max1 = 0, Max2 = 0, sMax1 = 0, sMax2 = 0;
	int m1 = 0, m2 = 0, sm1 = 0, sm2 = 0;
	for(int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		if(i & 1)
		{
			Map1[x]++;
			if(Max1 < Map1[x])
			{
				if(m1 != x)sMax1 = Max1, sm1 = m1;//次大值
				Max1 = Map1[x], m1 = x;
			}
			else if(sMax1 < Map1[x])
			{
				sMax1 = Map1[x], sm1 = x;
			}
		}
		else
		{
			Map2[x]++;
			if(Max2 < Map2[x])
			{
				if(m2 != x)sMax2 = Max2, sm2 = m2;//次大值
				Max2 = Map2[x], m2 = x;
			}
			else if(sMax2 < Map2[x])
			{
				sMax2 = Map2[x], sm2 = x;
			}
		}
	}
	int ans;
	if(m1 != m2)ans = n - (Max1 + Max2);
	else ans = n - max(Max1 + sMax2, Max2 + sMax1);
	cout<<ans<<endl;
	return Accepted;
}

Measured memory_bytes: 4992
#include<stdio.h>
int a, b;
int main(void){
	a=getchar();
	b=getchar();
	if(a==b){goto bad;}
	a=getchar();
	if(a==b){goto bad;}
	b=getchar();
	if(a==b){goto bad;}
	puts("Good");
	return 0;
	bad:
	puts("Bad");
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define mem(a,val) memset(a,val,sizeof(a))
#define ps(x,noOfDecimal) fixed<<setprecision(noOfDecimal)<<x

using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	std::ios::sync_with_stdio(false);
	int t = 1;
	// cin >> t;
	while (t--) {
		int n;
		cin >> n;
		long double val;

		if (n & 1) {
			int x = n / 2 + 1;
			int y = n ;
			// cout << x << " " << y << endl;
			val = (x / (double) y);
			cout << ps(val, 10);
		}
		else {
			cout << "0.5000000000";
		}


	}
	return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <algorithm>
#define ka first
#define	am second
using namespace	std;
int main(){
  int n,m,ma,a[15],b[15],r;
  pair<int,int> li[15];
  cin>>n>>m>>ma;
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n;i++) cin>>b[i];
  for(int i=0;i<n;i++) li[i]=make_pair(a[i],b[i]);
  sort(li,li+n);
  if(ma==3){
    for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) for(int k=j+1;k<n;k++){
          int tmp=0,nokori=m;
          tmp+=li[k].ka*min(li[k].am,nokori);
          nokori-=min(li[k].am,nokori);
          tmp+=li[j].ka*min(li[j].am,nokori);
          nokori-=min(li[j].am,nokori);
          tmp+=li[i].ka*min(li[i].am,nokori);
	  nokori-=min(li[i].am,nokori);
          tmp+=nokori;
          r=max(r,tmp);
        }
  } else if(ma==2){
    for(int j=0;j<n;j++) for(int k=j+1;k<n;k++){
	int tmp=0,nokori=m;
        tmp+=li[k].ka*min(li[k].am,nokori);
        nokori-=min(li[k].am,nokori);
	tmp+=li[j].ka*min(li[j].am,nokori);
	nokori-=min(li[j].am,nokori);
	tmp+=nokori;
	r=max(r,tmp);
      }
  } else {
    for(int k=0;k<n;k++){
      int tmp=0,nokori=m;
      tmp+=li[k].ka*min(li[k].am,nokori);
      nokori-=min(li[k].am,nokori);
      tmp+=nokori;
      r=max(r,tmp);
    }
  }
  cout<<r<<endl;
  return 0;
}

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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

typedef long long Weight;
const Weight WEIGHT_INF = std::numeric_limits<Weight>::max()/4;

struct Edge {
    int src, dst;
    Weight weight;
};
bool operator<(const Edge& a, const Edge& b) {
    return (a.weight < b.weight);
};
bool operator>(const Edge& a, const Edge& b) {
    return (a.weight > b.weight);
};
typedef std::vector<Edge> Edges;
typedef std::vector<Edges> Graph;

Graph g;
int N;
int Q, K;
std::vector<Weight> costs;
std::vector<int> trace;
void dijkstra(int start){
    int n = g.size();
    costs.resize(n, WEIGHT_INF);
    costs[start] = 0;
    trace.resize(n, -2);

    std::priority_queue<Edge, std::vector<Edge>, std::greater<Edge>> q;
    q.push((Edge){-1, start, 0});
    while(!q.empty()) {
        Edge e = q.top();
        q.pop();

        if(trace[e.dst] != -2) continue;
        trace[e.dst] = e.src;
        EACH(it, g[e.dst]) {
            if(costs[it->dst] > e.weight + it->weight){
                costs[it->dst] = e.weight + it->weight;
                q.push((Edge){it->src, it->dst, e.weight + it->weight});
            }
        }
    }
}

int main() {
    std::cin >> N;
    g.resize(N);
    REP(i, N-1) {
        int a, b, c;
        std::cin >> a >> b >> c;
        --a, --b;
        g[a].push_back(Edge{a, b, c});
        g[b].push_back(Edge{b, a, c});
    }

    std::cin >> Q >> K;
    dijkstra(K-1);
    REP(i, Q) {
        int x, y;
        std::cin >> x >> y;
        --x, --y;
        std::cout << costs[x] + costs[y] << std::endl;
    }
}

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

void solve(){
  int n; cin >> n; 
  map<int, int> mp;
  int ans = 0;
  for(int i = 0; i < n; ++i){
    int tmp; cin >> tmp;
    mp[tmp]++;
  }
  int cnt = 0;
  int total = mp.size();
  for(auto m: mp){
    if(m.second > 1) cnt += (m.second-1);
  }
  if(cnt%2==0) cout << total << endl;
  else cout << total -1 << endl;
}

int main(){
  solve();
  return 0; 
}

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

#define M 999997
#define NIL (-1)
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long teto = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    teto += p*(getChar(str[i]));
    p *= 5;
  }
  return teto;
}

int h1(int key){ return key%M; }//ハンドアウト
int h2(int key){ return key%(M-1)+1; }//ハンドアウト

int find(char str[]){
  int i,j;
  long long teto;
  teto = getKey(str);
  i=0;
  while(1){
    j=(h1(teto)+(i*h2(teto)))%M;//メモリの位置を探すぜ！
  if(H[j][0]=='\0'||i==M)return 0;
  if(strcmp(H[j],str)==0)return 1;
     else i=i+1;
  }
}



int insert(char str[]){
  int i,j;
  long long teto;
  teto=getKey(str);
  i=0;
  while(i!=M){
    j=(h1(teto)+(i*h2(teto)))%M;//メモリの位置を探すぜ！
    if(H[j][0]=='\0'){
      strcpy(H[j],str);
      break;
    }
    else{
      i=i+1;
    }
  }
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    h=insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}

Measured memory_bytes: 14280
#include <iostream>

using namespace std;

int main(){
	int n;
	long *l,*r;
	long ans=0;

	cin>>n;

	l= new long[n];
	r= new long[n];

	for(int i=0; i<n; i++)
		cin>>l[i]>>r[i];

	for(int i=0; i<n; i++)
		ans+= r[i]-l[i]+1;

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
def f_b():
    n, *h = map(int, open(0).read().split())
    c = n
    for i in range(1, n):
        for j in range(i):
            if h[j]>h[i]:
                c -= 1; break
    print(c)

if __name__ == "__main__":
    f_b()


Measured memory_bytes: 2940
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
typedef long long LL;
const int MAXN=int(2e2+5);
#define exp 1
int n,k;
char s[MAXN];
vector<int>G[MAXN];
int d[MAXN];
queue<int>Q;
int dep[MAXN],fa[MAXN][MAXN];
int Come(int x) {
    memset(dep,0,sizeof(dep));
    memset(fa,0,sizeof(fa));
    int ret=-1;
    dep[x]=1,Q.push(x);
    while(!Q.empty()) {
        int u=Q.front();Q.pop();
        for(int i=0;i<G[u].size();i++) {
            int v=G[u][i];
            if(fa[u][v])
                continue;
            if(dep[v]&&dep[v]!=dep[u]+1)
                return -1;
            if(dep[v]&&dep[v]==dep[u]+1) {
                fa[v][u]=1;
                continue;
            }
            fa[v][u]=1,dep[v]=dep[u]+1;
            Q.push(v);
            ret=max(ret,dep[v]);
        }
    }
    return ret;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) {
        scanf("%s",s+1);
        for(int j=1;j<=n;j++)
            if(s[j]=='1') {
                G[i].push_back(j);
                d[i]++;
            }
    }
    int Ans=-1;
    for(int i=1;i<=n;i++)
        if(d[i])
            Ans=max(Ans,Come(i));
    printf("%d",Ans);
}


Measured memory_bytes: 768
N = int(input())
T, A = map(int, input().split(' '))
H_N = list(map(int, input().split(' ')))

P_N = [abs(T - h * 0.006 - A) for h in H_N]

palace_point = P_N.index(min(P_N)) + 1
print(palace_point)

Measured memory_bytes: 3060
#include <iostream> // cout, endl, cin
#include <vector>   // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
using namespace std;

int main(void)
{
  long long int i, x;
  for(long long int i = 1;i <= 10000;i++)
  {
    cin >> x;
    if(x == 0) break;
    else cout << "Case " << i << ": " << x << endl;
  }
  return 0;
}


Measured memory_bytes: 3012
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

ll mod = 1000000007;

signed main()
{
    int n, m;
    cin >> n >> m;
    vector<ll> dp(n + 1);
    vector<bool> isa(n + 1, false);
    dp[0] = 1;
    dp[1] = 1;
    rep(i, m)
    {
        int a;
        cin >> a;
        isa[a] = true;
    }
    rep(i, n + 1)
    {
        if (i > 1)
        {
            if (!isa[i - 1])
            {
                dp[i] += dp[i - 1];
            }
            if (!isa[i - 2])
            {
                dp[i] += dp[i - 2];
            }
            dp[i] %= mod;
            //            cout << dp[i] << endl;
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 4024
#include <iostream>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;
int ky[8] = {-1,1,-2,2,-2,2,-1,1}; 
int kx[8] = {-2,-2,-1,-1,1,1,2,2};
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int ddy[8] = {-1,0,1,-1,1,-1,0,1};
int ddx[8] = {-1,-1,-1,0,0,1,1,1};
typedef long long ll;
#define pi pair
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define rep1(i,a,b) for(int i = a; i < b; i++)
#define rep2(i,a,b) for(int i = a; i <= b; i++) 
#define INF 999999999999
const double PI = acos(-1.0);
ll a,b,c,d;
ll ans;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> a >> b >> c >> d;
    ans = max(a*c,a*d);
    ans = max(ans,b*c);
    ans = max(ans,b*d);
    cout << ans;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int mod = (int) 1e9 + 7;
const int N = 200005;

int h, w, n;
int dp[3005];
int fact[N];
int inv[N];
vector < pair <int, int> > vec;

inline int add(int a, int b) {
  return (1ll * a + b) % mod;
}

inline int sub(int a, int b) {
  long long ans = (1ll * a - b) % mod;
  return (ans + mod) % mod;
}

inline int mul(long long a, long long b) {
  a %= mod; b %= mod;
  return (1ll * a * b) % mod;
}

inline int fp(int a, int b) {
  int ans = 1;
  while (b > 0) {
    if (b & 1) {
      ans = mul(ans, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return ans;
}

inline int invr(int x) {
  return fp(x, mod - 2);
}

int comb(int n, int k) {
  int ans = (1ll * fact[n] * inv[n - k]) % mod;
  return (1ll * ans * inv[k]) % mod;
}

int main() {
  fact[0] = 1;
  for (int i = 1; i < N; i++) {
    fact[i] = (1ll * fact[i - 1] * i) % mod;
  }
  for (int i = N - 1; i >= 0; i--) {
    inv[i] = invr(fact[i]);
  }
  cin >> h >> w >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    vec.push_back({x, y});
  }
  vec.push_back({h, w});
  sort(vec.begin(), vec.end());
  n = vec.size();
  for (int i = 0; i < n; i++) {
    dp[i] = comb(vec[i].first + vec[i].second - 2, vec[i].first - 1);
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < i; j++) {
      if (!(vec[j].first <= vec[i].first && vec[j].second <= vec[i].second)) continue;
      int aa = vec[i].first - vec[j].first;
      int bb = vec[i].second - vec[j].second;
      dp[i] = sub(dp[i], mul(dp[j], comb(aa + bb, aa)));
    }
  }
  cout << dp[n - 1] << endl;
  return 0;
}


Measured memory_bytes: 1920
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        String line1 = sc.nextLine();
        String[] array = line1.split(" ");
        
        long a = Long.parseLong(array[0]);
        long b = Long.parseLong(array[1]);
        long k = Long.parseLong(array[2]);
        
        if(a > 0 && k > 0)
        {
            if(k >= a)
            {
                k -= a;
                a = 0;
            }
            else
            {
                a -= k;
                k = 0;
            }
        }
        if(b > 0 && k > 0)
        {
            if(k >= b)
            {
                k -= b;
                b = 0;
            }
            else
            {
                b -= k;
                k = 0;
            }
        }
        
        System.out.println(a + " " + b);
    }
}


Measured memory_bytes: 23764
use std::io;


fn main() {
    let n = read_one::<usize>();
    let cc = vec!['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
    let ss = read_one::<String>().chars().collect::<Vec<_>>();
    for c in ss {
        let idx = ((c as u8) - 'A' as u8 + n as u8) % 26;
        print!("{}", cc[idx as usize]);
    }
    println!();
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int vis[100010]={1,1,0},a[100010]={0,0};
int main()
{
    for(int i=2;i<=500;i++)
        for(int j=i*i;j<=100000;j=j+i)
        if(!vis[j])
            vis[j]=1;
    for(int i=3;i<=100000;i++)
    {
        a[i]=a[i-1];
        if(!vis[i]&&!vis[(i+1)/2])
            a[i]++;
    }
    int t,l,r;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d",&l,&r);
        cout<<a[r]-a[l-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 1408
N, M = gets.chomp.split.map(&:to_i)
aa = Array.new(M)
bb = Array.new(M)

M.times do |i|
  aa[i], bb[i] = gets.chomp.split.map(&:to_i) 
end

for i in 1..N do
  puts aa.count(i) + bb.count(i)
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a == 1) {
		a = 13;
	}
	else {
		a -= 1;
	}
	if (b == 1) {
		b = 13;
	}
	else {
		b -= 1;
	}

	if (a > b) {
		cout << "Alice" << endl;
	}
	else if (a == b) {
		cout << "Draw" << endl;
	}
	else {
		cout << "Bob" << endl;
	}

}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N,K = inputMap()
    D = inputList()
    
    base = list(range(10))
    for vol in D:
        base.remove(vol)
        
    ans = ""
    NN = str(N)
    flg = False
    for i,val in enumerate(NN):
        isInp = False
        for j,vol in enumerate(base):
            if flg == True:
                ans += str(vol)
                isInp = True
                break
            tmp = int(val)
            if tmp == vol:
                ans += val
                isInp = True
                break
            elif tmp < vol:
                flg = True
                ans += str(vol)
                isInp = True
                break
            else:
                continue
        
        if isInp == False:
            ans += "*"
    
    if "*" not in ans:
        print(ans)
        sys.exit()
    
    ans = list(ans)
    ans_T = ""
    if ans[0] == "*" or 1 == 1:
        if base[0] != 0:
            ans_T += str(base[0])
        else:
            ans_T += str(base[1])
        for i in range(len(str(N))):
            ans_T += str(base[0])
        print(ans_T)
        sys.exit()
        
    '''
    mem = []
    for i in ans:
        if i == str(base[-1]):
            mem.append(1)
        elif i == "*":
            mem.append(2)
        else:
            mem.append(0)
    
    ttt = ""
    tmp = ""
    flg = False
    for i, val in enumerate(ans):
        if mem[i] == 2:
            ttt += str(base[0])
            flg = True
        else:
            ttt += "-"
        if flg == False:
            tmp = val
            
    print("".join(ans))
    '''
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 38640
// Lets go to the next level 
// AIM CM at CF *__* asap 
// Hit A,B,C and D faster and reach Candidate Master
// Remember you were also a novice when you started, 
// hence never be rude to anyone who wants to learn something
// Never open a ranklist untill and unless you are done with solving problems, wastes 3/4 minuts 
// Donot treat CP as a placement thing, love it and enjoy it, you will succeed for sure.  


#include <bits/stdc++.h>
using namespace std;
#define mod (int)1000000007
#define MOD (int)10000000007
// Big two primes 
#define X 1001100011100001111ll
#define M 26388279066623ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for0e(i, n) for (int i = 0; i <= n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int long long 
#define ll long long
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int> 
#define F first
#define S second
#define pi pair<int, int>
#define ppi pair<pair<int,int> , int >
#define vii vector<pi>
const int MAXN = (int)((1e5) + 100);
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}  
int cbrt(int x){ int lo=1,hi=min(2000000ll,x);while(hi-lo>1){int mid=(lo+hi)/2;if(mid*mid*mid<x){lo=mid;}else hi=mid;}if(hi*hi*hi<=x) return hi;else return lo;} 
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const int N =  (int)(1e6+5); 


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

    for(int i=1;i<=b;i++){
        if((a*i)%b == 0){
            cout<<a*i<<endl;
            break;
        }
    }
  rr;
}

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

int main(){
	int n,m;
	while(1){
		cin>>n>>m;
		if(!n && !m)break;
		int vote[m];
		int rank[m];
		for(int i=0;i<m;i++){
			vote[i]=0;
			rank[i]=i+1;
		}
		int raise;
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				cin>>raise;
				if(raise)vote[j]++;
			}
		}
		for(int i=0;i<m;i++){
			for(int j=m-1;j>i;j--){
				if(vote[j-1]<vote[j]){
					int alt=rank[j];
					rank[j]=rank[j-1];
					rank[j-1]=alt;
					alt=vote[j];
					vote[j]=vote[j-1];
					vote[j-1]=alt;
				}
			}
		}
		cout<<rank[0];
		for(int i=1;i<m;i++){
			cout<<" "<<rank[i];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
using namespace std;
long long maxn;
long long sum;
long long mp[510][510];
int main(){
	int H,W,h,w;
	scanf("%d%d%d%d",&H,&W,&h,&w);
	if(H % h == 0 && W % w == 0){
		printf("No");
		return 0;
	}
	else if(h == 1 && w == 1){
		printf("No");
		return 0;
	}
	maxn = (int)H*W / (h*w) + 100;
	//printf("Yes\n");
	for(int i = 1;i <= H;i ++){
		for(int j = 1;j <= W; j++){
			if(i % h == 0 && j % w == 0){
				mp[i][j] = - maxn*(h*w-1) - 1;
				//printf("%lld",- maxn*(h*w-1) - 1);
			}
			else{
				mp[i][j] = maxn;
				//printf("%lld",maxn);
			}
			sum += mp[i][j];
			//printf("\n");
		}
	}
	if(sum < 0){
		printf("No");
	}
	else{
		printf("Yes\n");
		for(int i = 1;i <= H;i ++){
			for(int j = 1;j <= W;j ++){
				printf("%lld ",mp[i][j]);
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 4096
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

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


using namespace std;
int main() {
	
	string p;
	int n = 0;
	cin >> p;
	for (int i = 0; i < p.size(); i++) {
		n += p[i] - '0';
	}
	cout << n << endl;

	return 0;
}

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

int main()
{
  long N;
    cin >> N;
  // int型の2次元配列(3×4要素の)の宣言
  vector<long> d(N);  
    for (int i = 0; i < N; i++)
    {
//        cin >> data.at(1).at(i);
//        data.at(2).at(i)=i+1;
              cin >> d.at(i);
//    cout<<d.at(i)<<endl;
    }
  std::sort(d.begin(), d.end() );
  long num;
  if(d.at(N/2)-d.at(N/2-1)!=0){
    num=d.at(N/2)-(d.at(N/2-1));
  }else{
    num=0;
  }
  cout<<num<<endl;
    return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<string>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<map>
#include<set>

using namespace std;

inline int read()
{
	int ans=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}

const int N=2e5+5,M=1e6;
int n,a[N],vis[M*2],ans;

int main()
{
	n=read();
	for(int i=1;i<=n;++i)
		a[i]=read();
	sort(a+1,a+1+n);
	for(int i=1;i<=n;++i)
	{
		if(!vis[a[i]])
		{
			ans++,vis[a[i]]=2;
			for(int j=a[i]*2;j<=M;j+=a[i])
				vis[j]=1;
		}
		else if(vis[a[i]]==2)
			ans--,vis[a[i]]=1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 7776
N = gets.to_i
P = gets.split.map(&:to_i)
Q = gets.split.map(&:to_i)
a = nil
b = nil

if P == Q then
  puts 0
else
  [*1..N].permutation(N).to_a.each_with_index do |z, index|
    a = index if P == z
    b = index if Q == z
    break if a != nil && b != nil
  end
  puts (a-b).abs
end

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

int main() {
  ll n,k,q;
  cin>>n>>k>>q;
  vector<ll> vec;
  for(ll i=0; i<n; i++){
  	vec.push_back(k);
  }
  for(ll i=0; i<q; i++){
  	ll a;
    cin >> a;
    vec[a-1]++;
  }
  for(ll i=0; i<n; i++){
    vec[i] -= q;
  	if(vec[i]<=0) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
}

Measured memory_bytes: 1524
#include <iostream>
#include <deque>
#include <algorithm>
using namespace std;

int main() {
  string first;
  cin >> first;
  deque<char> S;
  for(int i=0;i<first.size();i++){
    S.push_back(first.at(i));
  }

  int Q;
  cin >> Q;
  bool flag =true;
  for(int i=0;i<Q;i++){
    int op;
    cin >> op;
    if(op==1){
      flag = !flag;
    }
    if(op==2){
      int F;
      char C;
      cin >> F >> C;
      if(flag){
        if(F==1){
          S.push_front(C);
        }
        else{
          S.push_back(C);
        }
      }
      else{
        if(F==1){
          S.push_back(C);
        }
        else{
          S.push_front(C);
        }
      }
    }
  }
  if(!flag){
    reverse(S.begin(),S.end());
  }
  for(int i=0;i<S.size();i++){
    cout << S.at(i);
    if(i==S.size()-1){
      cout << endl;
    }
  }
}


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

void solve() {
    ll K, N; cin >> K >> N;
    vector<ll> A(N); rep(i, N) cin >> A[i];

    vector<ll> B(N); rep(i, N-1) B[i] = A[i+1] - A[i];
    B[N-1] = K - A[N-1] + A[0];
    ll all_B = 0; rep(i, N) all_B += B[i];

    ll min_dist = INF;
    rep(i,N){
        ll dist = all_B - B[i];
        if(dist < min_dist){
            min_dist = dist;
        }
    }

    cout << min_dist << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 3456
#include<iostream>
#include<vector>
#include<algorithm>
 
#define ll long long
ll MAX = 1000000000+7;
 
using namespace std;
 
ll modF(ll a) {
    if (a<0) return modF((a%MAX)+MAX);
    else return (a%MAX);
}
 
int main() {
    ll t=1;
    while (t--) {
        ll n, k, i, a, po=0, ni=0, ans=1;
        vector<ll> vcp, vcn;
        cin >> n >> k;
        for (i=0;i<n;i++) {
            cin >> a;
            if (a<0) {
                a=-a;
                ni++; vcn.push_back(a);
            }
            else {
                po++; vcp.push_back(a);
            }
        }
        if (po>0) sort(vcp.begin(),vcp.end());
        if (ni>0) sort(vcn.begin(),vcn.end());
 
        if (po==0) {
            if (k%2==0) {
                for (i=0;i<k;i++) {
                    ans = ans * (-vcn[ni-1]);
                    ans = modF(ans);
                    ni--;
                }
            }
            else {
                for (i=0;i<k;i++) {
                    ans = ans * (-vcn[i]);
                    ans = modF(ans);
                }
            }
        }
        else if (ni==0) {
            for (i=0;i<k;i++) {
                ans = ans * vcp[po-1];
                ans = modF(ans);
                po--;
            }
        }
        else {
            if (k%2==1) {
                ans = vcp[po-1];
                po--; k--;
            }
            while (k>1 && (po>=2 || ni>=2)) {
                ll propo = 0;
                if (po>=2) propo = vcp[po-1]*vcp[po-2];
                ll proni = 0;
                if (ni>=2) proni = vcn[ni-1]*vcn[ni-2];
 
                if (propo>proni) {
                    propo = modF(propo);
                    ans = ans*propo;
                    ans = modF(ans);
                    po = po-2;
                }
                else {
                    proni = modF(proni);
                    ans = ans*proni;
                    ans = modF(ans);
                    ni = ni-2;
                }
                k=k-2;
            }
            while (k>0) {
                if (po>0) {
                    ans = ans*vcp[po-1];
                    ans = modF(ans);
                    po--; k--;
                }
                else if (ni>0) {
                    ans = ans*(-vcn[ni-1]);
                    ans = modF(ans);
                    ni--; k--;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 5384
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

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

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

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n, m;
  cin >> n >> m;
  vector<string> g(n);
  REP(i, n) cin >> g[i];

  mcf_graph<ll, ll> flow(2 + 2 * n * m);

  int s = 2 * n * m, t = 2 * n * m + 1;

  ll f = 0;
  map<P, bool> mp;
  REP(i, n) {
    REP(j, m) {
      if(g[i][j] == '#') continue;
      if(g[i][j] == 'o') {
        f++;
        mp[{i, j}] = true;
        flow.add_edge(s, i*m+j, 1, 0);
      }
      flow.add_edge(n*m+i*m+j, t, 1, 0);
    }
  }


  REP(i1, n) {
    REP(j1, m) {
      if(!mp[{i1, j1}]) continue;
      if(g[i1][j1] == '#') continue;
      vector<vector<bool>> sel(n, vector<bool>(m));
      sel[i1][j1] = true;
      FOR(i2, i1, n) {
        FOR(j2, j1, m) {
          if(g[i2][j2] == '#') continue;
          if(i2 != i1 && g[i2-1][j2] != '#') sel[i2][j2] = sel[i2][j2] | sel[i2-1][j2];
          if(j2 != j1 && g[i2][j2-1] != '#') sel[i2][j2] = sel[i2][j2] | sel[i2][j2-1];
          if(!sel[i2][j2]) continue;

          //cout << i1 << ":" << j1 << " " << i2 << ":" << j2 << endl;


          ll cost = i2 - i1 + j2 - j1;
          flow.add_edge(i1 * m + j1, n * m + i2 * m + j2, 1, INF - cost);
        }
      }
    }
  }

  //flow.add_edge(s, t, INF, INF);
  auto val = flow.flow(s, t, f);

  cout << - val.second + INF * f << endl;


  return 0;
}


/*
9 10
.#.....#..
.#..#..##o
.....#..##
.###.#..oo
#.#...##o#
..#..#.###
#......#..
....###..o
.......oo#
 */


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

int main() {
  int64_t n,a,b;
  cin>>n>>a>>b;
  cout<<((n/(a+b))*a+min(n%(a+b),a))<<endl;
}

Measured memory_bytes: 256
# 二項係数を"やるだけ"にしてくれるライブラリ
MAX = 510000
MOD = 1000000007
factrial = [0]*MAX
inverse = [0]*MAX
factrial_inverse = [0]*MAX


# テーブルを作る前処理
def COMinit():
    global factrial, inverse, factrial_inverse
    factrial[0] = 1
    factrial[1] = 1
    inverse[1] = 1
    factrial_inverse[0] = 1
    factrial_inverse[1] = 1
    for i in range(2, MAX):
        factrial[i] = factrial[i-1] * i % MOD
        inverse[i] = MOD - inverse[MOD % i] * (MOD//i) % MOD
        factrial_inverse[i] = factrial_inverse[i-1] * inverse[i] % MOD


# 二項係数計算
def COM(n, k):
    global factrial, inverse, factrial_inverse
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return factrial[n] * (factrial_inverse[k] * factrial_inverse[n-k] % MOD) % MOD


# 前処理完了
COMinit()


N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

# 最大値を固定してそのパターン数を数える
max_value_sum = 0
for i in range(N):
    max_value_sum += (A[i] * COM(i, K-1) + MOD) % MOD

# 最小値を固定してそのパターン数を数える
A.reverse()
min_value_sum = 0
for i in range(N):
    min_value_sum += (A[i] * COM(i, K-1) + MOD) % MOD

ans = max_value_sum - min_value_sum + MOD

print(ans % MOD)


Measured memory_bytes: 74592
object Main extends App {
	def minus(x: Int, y: Int): Int = {
		return y - x;
	}

	val N = io.StdIn.readLine;

	val a = N.split(" ")(0).toInt;
	val b = N.split(" ")(1).toInt;
	val c = N.split(" ")(2).toInt;

	if(minus(a,b) == minus(b,c)) println("YES")
	else println("NO")
}

Measured memory_bytes: 25528
#C
N,M=map(int,input().split())
re=[0 for i in range(N+1)]
P=[0 for i in range(N+1)]
x=0
y=0
for i in range(M):
    p,S=input().split()
    p=int(p)
    if re[p]=="AC":
        continue
    elif S=="WA":
        P[p]+=1
    elif S=="AC":
        re[p]="AC"
        y+=1
for i in range(1,N+1):
    if re[i]=="AC":
        x+=P[i]
print(y,x)

Measured memory_bytes: 53680
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int  a,b,c,d;
  cin>> a >> b >> c >> d;
  string result;
  while(true){
    c-=b;
    if( c<=0){
      result = "Yes";
      break;}
    a-=d;
    if(a<=0){
      result = "No";
      break;}
  }
  cout<<result<<endl;
}




Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef tuple<int,int,int> T;
typedef vector<P> vp;
typedef vector<T> vt;

int main(void) {
  string s;
  cin >> s;
  if(s[0]=='7' ||s[1]=='7'||s[2]=='7'){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



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

  int t=(a+x-1)/x;
  int l=b/x;

  cout<<l-t+1<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

int main(){
  ld N,sum=0,X[1000];
  cin >> N ;
  rep(i,N){
    cin >> X[i];
    sum+=X[i];
  }
  sum/=N;
  ld D = 1000000;
  ll ans;
  rep(i,N){
    if(fabs(sum-X[i])<D){
      ans=i;
      D=fabs(sum-X[i]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int N, a[110];
	int i,j,tmp;
	int alice = 0, bob = 0;
	int ans;


	(void)scanf("%d", &N);

	for (i = 0; i <N; i++) {
		(void)scanf("%d", &a[i]);
	}

	for (i = 0; i < N; i++) {
		for (j = i + 1; j < N; j++) {
			if (a[i] < a[j]) {
				tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}
	for (i = 0; i < N; i++) {
		if (i % 2 == 0) {
			alice += a[i];
		}
		else {
			bob += a[i];
		}
	}
	ans = alice - bob;

	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 1732
import java.util.Scanner;

public class Main {

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

		String a = sc.next();
		Integer count = 0;

		for (Integer i = 0; i < 3; i++) {
			if (a.substring(i, i + 1).equals("o")) {
				count++;
			}

		}

		System.out.println(700 + 100 * count);

	}

}


Measured memory_bytes: 35496
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int K;
    cin>>K;
    bool dame = true;
    int a2=7;
    for(int i=1;i<=K;i++)
    {
        int a1=a2%K;
        if(a1==0)
        {
            cout<<i<<endl;
            dame=false;
            break;
        }
        a2=10*a1+7;
    }
    if(dame)
    {
        cout<<-1<<endl;
    }
}

Measured memory_bytes: 3612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String str2 = str.replace(",", " ");

		System.out.println(str2);


	}

}


Measured memory_bytes: 8404
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication34
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] values = new int[3];
            values = Console.ReadLine()
                .Split(' ')
                .Select(x => int.Parse(x))
                .ToArray();
            Solve(values[0], values[1], values[2]);
        }

        static void Solve(int a, int b, int c)
        {
            Say(isSplittable(a, b, c));
        }

        static bool isSplittable(int a, int b, int c)
        {
            return a + b == c ||
                b + c == a ||
                c + a == b;
        }

        static void Say(bool b)
        {
            string res = b ? "Yes" : "No";
            Console.WriteLine(res);
        }
    }

}


Measured memory_bytes: 2776
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
const int INF = 1000000007;
const ll mod = 1000000007;
#define MAX_N 2200000
ll f[MAX_N];
ll invf[MAX_N];
ll modpow(ll  a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll nCm(ll n,ll m){return ((f[n]*invf[m])%mod)*invf[n-m]%mod;  }
signed main(){
    int n,m;cin >> n >> m;
    for(int i = 1;i <= 210000;i++){
        if(i == 1)f[i] = 1;
        else f[i] = (f[i-1]*i)%mod;
    }

    if(n == m+1){
        int ans = (f[n]*f[m])%mod;
        cout << ans << endl;



    }
    else if(m == n+1){
        int ans = (f[n]*f[m])%mod;
        cout << ans << endl;

    }
    else if(n == m){
        int ans = (f[n]*f[m])%mod;
        ans = (ans*2)%mod;
        cout << ans << endl;

    }
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 4352
S=input()
T=input()

import sys

##後ろから順に考える
code=list(S)
code.reverse()
S=list(S)
S.reverse()
T=list(T)
T.reverse()


for i in range(len(S)-len(T)+1):
    count=0
    for j in range (len(T)):
        if S[i+j]==T[j] or S[i+j]=='?':
            code[i+j]=T[j]
            count+=1
            if count==len(T):
                for k in range (len(S)):
                    if code[k]=='?':
                        code[k]='a'
                code.reverse()
                print(''.join(code))
                sys.exit()
            
        else:
            code=list(S)
        
print ('UNRESTORABLE')

Measured memory_bytes: 3064
n = int(input())
for _ in range(n):
  r, t = map(int, input().split())
  if t % 30 == 0:
    angles = [t // 30]
  else:
    angles = [t // 30, t // 30 + 1]
  if r % 100 == 0:
    dists = [r // 100]
  else:
    dists = [r // 100, r // 100 + 1]
  ans = []
  for angle in angles:
    for dist in dists:
      ans.append(angle * 5 + dist)
  print(*ans)


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;
#define rep(i,s,e) for(int i = (int)(s); i < (int)(e); ++i)
#define per(i,s,e) for(int i = (int)(s)-1; i >= (int)(e); --i)

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;

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

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

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

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

int main(){
  int n,k; cin >> n >> k;
  vector<ll> v(k,0);
  rep(i,1,n+1)v[i%k]++;
  ll ans = 0;
  rep(i,0,k){
    int x = (k-i)%k;
    if((x+x)%k!=0)continue;
    ans += v[i] * v[x] * v[x];
  }
  cout << ans << endl;
  return 0;
}


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


int main() {
	string s;
	cin >> s;

	// A,C,G,T のみを含む部分文字列の長さの最大値

	int l[int((s.size() + 1))];



	for (int i = 0; i < (sizeof(l) / sizeof(l[0])); i++){
		l[i] = 0;
	}


	//cout << l << endl;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
			l[i+1] = l[i] + 1;
		}
		else {l[i+1] = 0;}
	}


	int ans = -1;
	for (int i = 0; i < (sizeof(l) / sizeof(l[0])); i++) {
		if (ans < l[i]){
			ans = l[i];
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256