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

#define MAXN 3010
#define ll long long
#define mod 998244353

using namespace std;

ll n, tot, ans, s;

ll a[MAXN], f[MAXN]; 

int main() {
	int t;
	scanf("%lld%lld", &n, &s);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 1; i <= n; i++) {
		for (int j = s; j > a[i]; j--) {
			f[j] = (f[j] + f[j - a[i]]) % mod;
		}
		f[a[i]] = (f[a[i]] + i) % mod;
		ans = (ans + (n - i + 1) * f[s] % mod) % mod;
		f[s] = 0;
	}
	cout << (ll)ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {

    	Scanner sc=new Scanner(System.in);

    	StringBuilder sb1=new StringBuilder();
    	StringBuilder sb2=new StringBuilder();
    	sb1.append(sc.next());
    	sb2.append(sc.next());


    	if(sb1.toString().equals(sb2.reverse().toString())) {
    		System.out.println("YES");
    	}else {
    		System.out.println("NO");
    	}

    }
}



Measured memory_bytes: 21844
n,m = map(int,input().split())
py = [list(map(int,input().split()))+[i] for i in range(m)]
py.sort(key=lambda x:(x[0],x[1]))
cnt = 1
ans = [""]*m
for i in range(m-1):
  ans[py[i][2]] = "0"*(6-len(str(py[i][0])))+str(py[i][0]) + "0"*(6-len(str(cnt)))+str(cnt)
  if py[i][0] == py[i+1][0]:
    cnt += 1
  else:
    cnt = 1
ans[py[m-1][2]]="0"*(6-len(str(py[m-1][0])))+str(py[m-1][0]) + "0"*(6-len(str(cnt)))+str(cnt)
for i in range(m):
  print(ans[i])

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

int main() {
  int H, N;
  scanf("%d%d", &H, &N);
  vector<int> A(N, 0);
  for (int i = 0; i < N; i++) {
    scanf("%d", &A.at(i));
  }

  string ans = "No";
  for (int i = 0; i < N; i++) {
    H -= A.at(i);
    if (H <= 0) {
      ans = "Yes";
      break;
    }
  }

  printf("%s", ans.c_str());
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<utility>
#include<string>
#include<queue>
using namespace std;


int main()
{
	int n, q, totalTime = 0;
	cin >> n >> q;
	queue<pair<string, int> > my_queue;
	for (int i = 0; i < n; i++) {
		string first;
		int last;
		cin >> first >> last;
		my_queue.push(make_pair(first,last));
	}
	while (!my_queue.empty()) {
		pair<string, int> a = my_queue.front();
		my_queue.pop();
		if (a.second > q) {
			a.second -= q;
			totalTime += q;
			my_queue.push(a);
		}
		else {
			totalTime += a.second;
			cout << a.first << " " << totalTime << endl;
		}
	}
    return 0;
}



Measured memory_bytes: 6332
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double DB;
const int maxn = (int)2e5 + 1;
const DB pi = acos((DB)-1);
int main() {
	int T = 1;
	// scanf("%d", &T);
	for(int Case = 1; Case <= T; ++Case) {
		int a, b, hh, mm;
		scanf("%d%d%d%d", &a, &b, &hh, &mm);
		DB x1 = a * cos(2 * pi / 720 * (hh * 60 + mm));
		DB y1 = a * sin(2 * pi / 720 * (hh * 60 + mm));
		DB x2 = b * cos(2 * pi / 60 * mm);
		DB y2 = b * sin(2 * pi / 60 * mm);
//		printf("(%f, %f) (%f, %f)\n", x1, y1, x2, y2);
		DB dis = sqrtl(max((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2), (DB)0));
		printf("%.20f\n", (double)dis);
	}
	return 0;
}

Measured memory_bytes: 4152
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string str1, str2;
	getline(cin, str1);
	getline(cin, str2);
	int len1 = str1.size(), len2 = str2.size();
	if (len1 != len2)
	{
		cout << "No" << endl;
		system("pause");
		return 0;
	}
	string str = str2 + str2;
	int i, j = 0, count, begin;
	for (i = 0; i < 2 * len2; i++)
	{
		if (str1[j] == str[i])
		{
			begin = i;
			count = 1;
			while (str1[++j] == str[++i])
				count++;
			if (count == len1)
			{
				cout << "Yes" << endl;
				system("pause");
				return 0;
			}
			else
			{
				j = 0;
				i = begin;
			}
		}
	}
	cout << "No" << endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 752
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
std::vector<int> change (std::vector<int> v,int i, int j) {
	int tmp = v[i-1];
	v[i-1] = v[j-1];
	v[j-1] = tmp;
	return v;
}
int main () {
	int w,n;
	cin >> w >> n;
	std::vector<int> num(w);
	for(int i = 0; i < w; i++){
		num[i] = i+1;
	}
	for(int i = 0; i < n; i++){
		int a,b;
		scanf("%d,%d",&a,&b);
		num = change(num,a,b);
	}
	for(int i = 0; i < w; i++) {
		cout << num[i]<< endl;
	}
}


Measured memory_bytes: 3208
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define INF (1LL<<59)
#define ff first
#define ss second
#define mod 998244353
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
int gcd(int x,int y)
{
    if(y==0)
        return x;
    else
        return gcd(y,x%y);
}
int expo(int n,int m,int p)   //modULAR EXPONENTIATION
{
    int r=1;
    n=n%p;
    while(m>0)
    {
        if(m%2)
            r=(r*n)%p;
        n=(n*n)%p;
        m=m/2;
    }
    return r%p;
}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;
 
    // This is checked so that we can skip 
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
 
    return true;
}
int32_t main()
{
   IOS;
   /*#ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin); 
   freopen("output.txt","w",stdout);
   #endif 
   /********************* Code starts here ***********************/   
   // int n,ans=inf;
   // cin>>n;
   // vector<int>a(n);
   // for(int i=0;i<n;i++)
   // {
   // 	cin>>a[i];
   // }
   int n;
   cin>>n;
   vector<int>a(n+1);
   for(int i=1;i<=n;i++)
   {
   	cin>>a[i];
   }
   vector<int>b(n+1);
   for(int i=n;i>=1;i--)
   {
   	if(2*i>n)
   	{
   		b[i]=a[i];
   	}
   	else
   	{
   		int c=0,j=2*i;
   		while(j<=n)
   		{
   			c=c+b[j];
   			j+=i;
   		}
   		b[i]=(a[i]-c%2+2)%2;
   	}
   	//cout<<i<<' '<<b[i]<<endl;
   }
   for(int i=1;i<=n;i++)
   {
   	//cout<<b[i]<<endl;
   	int j=i,c=0;
   	while(j<=n)
   	{
   		c=c+b[j];
   		j+=i;
   	}
   	//cout<<c<<' '<<a[i]<<endl;
   	if(((c)%2)!=a[i])
   	{
   		cout<<-1<<endl;
   		return 0;
   	}
   }
   vector<int>ans;
   for(int i=1;i<=n;i++)
   {
   	if(b[i])
   		ans.pb(i);
   	//cout<<b[i]<<endl;
   }
   cout<<ans.size()<<endl;
   for(auto x : ans)
   	cout<<x<<' ';
}		

Measured memory_bytes: 5108
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  int n,a,b;  cin >> n >> a >> b;
  string s;   cin >> s;
  int na=0,nb=0;
  rep(i,n){
    if(s.at(i)=='c')  puts("No");
    else if(s.at(i)=='a'){
      if(na<a+b){
        puts("Yes");
        na++;
      }else{
        puts("No");
      }
    }else if(s.at(i)=='b'){
      if(na<a+b&&nb<b){
        puts("Yes");
        nb++;
        na++;
      }else{
        puts("No");
      }
    }
  }
}

Measured memory_bytes: 896
while True:
    a = input()
    a = a.split(" ")
    for i in range(len(a)):
        a[i] = int(a[i])
    if a[0] == -1 and a[1] == -1 and a[2] == -1:
        break
    if a[0] == -1 or a[1] == -1:
        print("F")
    elif a[0] + a[1] >= 80:
        print("A")
    elif a[0] + a[1] >= 65 and a[0] + a[1] < 80:
        print("B")
    elif a[0] + a[1] >= 50 and a[0] + a[1] < 65:
        print("C")
    elif a[0] + a[1] >= 30 and a[0] + a[1] < 50 and a[2] >=50:
        print("C")
    elif a[0] + a[1] >= 30 and a[0] + a[1] < 50 and a[2] <50:
        print("D")
    elif a[0] + a[1] < 30:
        print("F")


Measured memory_bytes: 5600
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int x=sc.nextInt();
        int y=sc.nextInt();
        System.out.println(x*Math.min(n, k)+y*(n-k>0?n-k:0));
    }
    
 
}

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

int main() {
  int n;
  cin>>n;
  string s;
  cin>>s;
  int x=0;
  int saidai=0;
  for(int i=0;i<n;i++){
    if(s[i]=='I')x++;
    else x--;
    saidai=max(saidai,x);
  }
  cout<<saidai<<endl;
  return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <vector>
#include <numeric>

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main() {
    ll n;
    scanf("%lld", &n);
    vector< vector<ll> > dp(n + 1, vector<ll>(1 << 6, 0));
    // dp.at(i).at(j) = number of different string satisfying the condition with its length of i, and the last three letters are represented by j. (T = 0, G = 1, C = 2, A = 3).
    dp.at(0).at(0) = 1;
    for (ll i = 0; i < n; ++i) for (ll j = 0; j < (1 << 6); ++j) for (ll k = 0; k < 4; ++k) {
        ll f = ((j & 15) << 2) + k;
        if (f == 0b110110 || f == 0b011110 || f == 0b111001 || ((j & (3 << 4)) == 3 << 4 && k == 2 && ((j & (3 << 2)) == (1 << 2) || (j & 3) == 1))) continue;
        dp.at(i + 1).at(((j & 15) << 2) + k) += dp.at(i).at(j);
        dp.at(i + 1).at(((j & 15) << 2) + k) %= MOD;
    }
    printf("%lld\n", accumulate(dp.back().begin(), dp.back().end(), 0LL) % MOD);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int n=3;
int x[3];
int main(void){
pair<int,int>x[3];
for(int i=0;i<3;i++)
    {cin>>x[i].first;x[i].second = 1-i;}
int k,sum=0;cin>>k;
for(int i=0;i<3;i++){
    if(x[i].first-k>=0)
        {sum+=k*x[i].second;break;}
    else
        {sum+=x[i].first*x[i].second;k-=x[i].first;}
}
cout<<sum<<endl;
return 0;}


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

typedef long long ll;
typedef long double ld;
#define pb push_back
#define pll pair<ll,ll>
#define vl vector<ll>
#define vll vector < pll >
#define sl set<ll>
#define mll map<ll,ll>
#define itr :: iterator
#define pf push_front
#define ff first
#define ss second
#define stkl stack <ll>
#define quel queue <ll>
#define pquel priority_queue <ll>
#define rep(i,n) for(i=0;i<n;i++)
#define MOD 1000000007
#define SIZE 100005
#define PI 3.14159265358979323846

#define debug(var) cout << "[" << __LINE__ << "] " << #var << " = " << (var) << endl;

struct edge {
    ll A;
    ll B; 
};

// Implementation of DSU (Union by Rank)
/*
ll parent[SIZE],rank[SIZE];

ll find_set(ll v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

void make_set(ll v) {
    parent[v] = v;
    rank[v] = 0;
}

void union_sets(ll a, ll b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rank[a] < rank[b])
            swap(a, b);
        parent[b] = a;
        if (rank[a] == rank[b])
            rank[a]++;
    }
}
*/
//*********************************************

ll power(ll a, ll b, ll mod){
    ll x = 1, y = a;
    while (b > 0){
        if (b%2){
            x = (x*y)%mod;
        }
        y = (y*y)%mod;
        b /= 2;
    }
    return x%mod;
}   
 
// FOR FINDING MODULAR INVERSE 

ll modular_inverse(ll n, ll mod){
    return power(n, mod-2, mod);
}


bool edgecompare(edge lhs, edge rhs) { if(lhs.B!=rhs.B)return lhs.B < rhs.B;
else return lhs.A<rhs.A;}

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

    string s;
    cin>>s;
    auto prev = '$';
    bool flag = 0;
    for(auto ch:s){
        if(ch == prev){
            flag = 1;
            break;
        }
        prev = ch;
    }

    if(flag){
        cout<<"Bad";
    }
    else cout<<"Good";
    /*ll n,m,i,j,k,flag=0,x;
    ll *a;//[SIZE];
    
    cin>>n;
    a = new ll[n];
    rep(i,n)
    {
        cin>>a[i];
    }

    delete a;*/

   return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<math.h>
#define Max 100005*2
#define INF 1000000000000000000
#define getMax(a,b) a<b?b:a
#define getMin(a,b) a<b?a:b
using namespace std;

vector<pair<int,int>>vec;
vector<int>node;

double distance(int u,int v){
	int x = (vec[u].first-vec[v].first);
	int y = (vec[u].second-vec[v].second);
	return sqrt((x*x)+(y*y));
}

int main(){

	int n,x,y;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&x,&y);
		vec.push_back(make_pair(x,y));
		node.push_back(i);
	}
	int c = 0;
	double s,sum=0;
	do{
		s = 0;

		for(int i=0;i<node.size()-1;i++){
			int u = node[i];
			int v = node[i+1];
			s += distance(u,v);
		}
		sum += s;
		c++;

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


	printf("%.10lf\n",sum/c);

	return 0;
}

Measured memory_bytes: 256
//
// Created by Kiran Chavhan on 19/09/2020.
//

#include<bits/stdc++.h>

#define int long long
#define MOD 1000000007
#define sort(a) sort(a.begin(),a.end())
#define endl '\n'

using namespace std;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s ;
    cin>>s;
    if(s[s.length()-1]=='s')cout<<s<<"es";
    else cout<<s<<'s';
}

Measured memory_bytes: 3640
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,m,k;
	cin>>n>>m>>k;
	vvi w(n,vi(2));
	rep(i,n)rep(j,2)cin>>w[i][j];
	sort(all(w));
	vi in(n),h(n);
	rep(i,n)in[i]=w[i][0],h[i]=w[i][1];

	vi dp(n+1);
	int out=0,t=0;
	rep(i,n){
		t+=dp[i];
		h[i]-=t;
		if(h[i]<0)h[i]=0;
		int c=(h[i]+k-1)/k;
		out+=c;
		int it=upper_bound(all(in),in[i]+2*m)-in.begin();
		t+=c*k;dp[it]-=c*k;
	}
	
	cout<<out<<endl;
}









Measured memory_bytes: 15872
while 1:
    n = int(input())
    if n == 0:
        break

    jewel = []
    for _ in range(n):
        x, y = map(int, input().split())
        jewel.append([x, y])

    m = int(input())
    pos = [10, 10]
    for _ in range(m):
        news, dis = input().split()
        dis = int(dis)

        for i in range(dis):
            if news == "N":
                pos[1] += 1
            elif news == "E":
                pos[0] += 1
            elif news == "W":
                pos[0] -= 1
            else:
                pos[1] -= 1

            if pos in jewel:
                jewel.remove(pos)

    if jewel == []:
        print("Yes")
    else:
        print("No")


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

#define MOD 1000000007
#define pb push_back
#define mp make_pair

template<typename T>
void print(vector<T> &v)
{
    for_each(v.begin(), v.end(), [](auto i){cout << i << ' ';});
    cout << '\n';
}

void f(int testCase)
{
    int n;
    cin >> n;
    vector<pair<long long, long long> > pt(n);
    for(int i = 0; i<n; i++)
        cin >> pt[i].first >> pt[i].second;
    vector<long long> sum(n);
    for(int i = 0; i<n; i++)
        sum[i] = pt[i].first + pt[i].second;
    sort(sum.begin(), sum.end());
    long long ans = abs(sum.back() - sum[0]);
    
    for(int i = 0; i<n; i++)
        sum[i] = pt[i].first - pt[i].second;
    sort(sum.begin(), sum.end());
    ans = max(ans, abs(sum.back() - sum[0]));
    cout << ans << '\n';
    
}

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin >> t;

    for(int i = 1; i<=t; i++)
        f(i);
    return 0;
}

Measured memory_bytes: 7948
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x1,x2,y1,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x=x2-x1;
    int y=y2-y1;
    cout << x2-y << " " << y2+x << " " << x1-y << " " << y1+x << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    char a; cin >> a;
    if(a=='A'){out('T');}
    else if(a=='G'){out('C');}
    else if(a=='C'){out('G');}
    else out('A');

    return 0;
}

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

int main()
{
	double n;
	cin >> n;
	double money = 0;

	vector<vector<string>> xu(n, vector<string>(2));
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			cin >> xu.at(i).at(j);
		}

		if (xu.at(i).at(1) == "JPY")
		{
			money += stod(xu.at(i).at(0));
		}
		else
		{
			money += stod(xu.at(i).at(0)) * 380000.0;
		}
	}

	cout << money << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int N;
    cin >> N;
    if (N == 25)
    {
        cout << "Christmas" << endl;
    }
    else if (N == 24)
    {
        cout << "Christmas Eve" << endl;
    }
    else if (N == 23)
    {
        cout << "Christmas Eve Eve" << endl;
    }
    else
    {
        cout << "Christmas Eve Eve Eve" << endl;
    }

    return 0;
}

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

int main() {
  int h,w,ch,dh,cw,dw;
  cin>>h>>w>>ch>>cw>>dh>>dw;

  string table[h];
  for(int i=0; i<h; i++) cin>>table[i];

  int dist[h][w];
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      if(table[i][j]=='.') dist[i][j]=30000000;
      else dist[i][j] = -1;
    }
  }

  dist[ch-1][cw-1] = 0;
  deque<pair<int, int>> todo;
  for(int i=ch-3; i<=ch+1; i++) {
    for(int j=cw-3; j<=cw+1; j++) {
      if(i<0 || i>=h || j<0 || j>=w || (i==ch-1 && j==cw-1)) continue;

      if(table[i][j]=='.') {
        pair<int, int> add;
        add.first = i;
        add.second = j;
        if(abs(ch-1-i)+abs(cw-1-j)==1) {
          dist[i][j] = 0;
          todo.push_front(add);
        }
        else {
          dist[i][j] = 1;
          todo.push_back(add);
        }
      }
    }
  }

  while(!todo.empty()) {
    pair<int, int> now = todo.front();
    todo.pop_front();
    int a = now.first;
    int b = now.second;
    for(int i=a-2; i<=a+2; i++) {
      for(int j=b-2; j<=b+2; j++) {
        if(i<0 || i>=h || j<0 || j>=w || (i==a && j==b)) continue;

        if(table[i][j]=='.') {
          pair<int, int> add;
          add.first = i;
          add.second = j;

          if(abs(a-i)+abs(b-j)==1) {
            if(dist[i][j]>dist[a][b]) {
              dist[i][j] = dist[a][b];
              todo.push_front(add);
            }
          }
          else {
            if(dist[i][j]>dist[a][b]+1) {
              dist[i][j] = dist[a][b]+1;
              todo.push_back(add);
            }
          }
        }
      }
    }
  }

  int ans = dist[dh-1][dw-1];
  if(ans==30000000) ans=-1;

  cout<<ans<<endl;

  // for(int i=0; i<h; i++) {
  //   for(int j=0; j<w; j++) {
  //     cout<<dist[i][j]<<' ';
  //   }
  //   cout<<endl;
  // }


  return 0;
}

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

class Main {

    void solve(){

	Scanner sc = new Scanner( System.in );

	while ( true ) {
	    int n = sc.nextInt();
	    if ( n == 0 ) break;

	    int less1Cnt = 0;
	    int zeroCnt = 0;
	    for ( int i=0; i<n; ++i ) {
		int k = sc.nextInt();
		if (k <= 1) ++less1Cnt;
		if (k == 0) ++zeroCnt;
	    }

	    if (n == less1Cnt) System.out.println("NA");
	    else System.out.println(n - zeroCnt + 1);
	}
    }

    public static void main( String[] a ) {new Main().solve(); }
}



Measured memory_bytes: 161776
def resolve():
    A, B, M = list(map(int, input().split()))
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    x, y, c = [], [], []
    dis = []
    for i in range(M):
        xt, yt, ct = list(map(int, input().split()))
        dis.append(a[xt-1] + b[yt-1] - ct)
        x.append(xt)
        y.append(yt)
        c.append(ct)

    a.sort()
    b.sort()
    dis.sort()
    ans = min(a[0] + b[0], dis[0])
    print(ans)

    return


resolve()

Measured memory_bytes: 28740
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define spln(i,n) (i==n?'\n':' ')
using namespace std;
int n,m,i,j,a[100005];
string first="First",second="Second";
int check(string first,string second)
{
	int co=0,ce=0,i,pos=0;
	fz1(i,n)co+=(a[i]%2==0);
	if(co&1){
		cout<<first<<endl;
		exit(0);
	}
	fz1(i,n)ce+=(a[i]%2==1);
	if(ce>1){
		cout<<second<<endl;
		exit(0);
	}
	fz1(i,n)if(a[i]&1) pos=i;
	if(a[pos]==1){
		cout<<second<<endl;
		exit(0);
	}
	return pos;
}
int main()
{
	scanf("%d",&n);
	fz1(i,n){
		scanf("%d",&a[i]);
	}
	for(;;)
	{
		int pos=check(first,second);
		a[pos]--;swap(first,second);
		int g=0;fz1(i,n)g=__gcd(g,a[i]);
		fz1(i,n)a[i]/=g;
	}
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;
using static program.Input;
using static program.MyMath;
using static System.Console;

namespace program {
  class Program {
    static string Alp = "abcdefghijklmnopqrstuvwxyz";
    static void Main()
    {
      var input = ScanIntArray();
      var d = input[0];
      var n = input[1];
      int A = 1;
      for(int i=0; i<d; i++) A *= 100;
      int res = A*n;
      if(n==100) res += A;
      WriteLine(res);
    }
  }
    
  static class Input {
    static public int ScanInt() { return int.Parse(Console.ReadLine()); }
    static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
    static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
    static public long ScanLong() { return long.Parse(Console.ReadLine()); }
    static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
    static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
    static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
    static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
    static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
    static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

    static public string ScanStr() { return Console.ReadLine(); }
    static public string[] ScanStrArray() { return ScanStr().Split(); }
  }
  
  static class MyMath {
    public static int GCD(int a, int b) {
        Func<int, int, int> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static long GCD(long a, long b) {
        Func<long, long, long> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
      if(b==0) {
        x=1; 
        y=0;
        return a;
      }
      var d = extGCD(b, a%b, ref y, ref x);
      y -= a/b *x;
      return d;
    }
    public static int LCM(int a, int b) { return a * b / GCD(a, b); }
    public static long LCM(long a, long b) { return a * b / GCD(a, b); }
  }
}


Measured memory_bytes: 13396
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

typedef pair <int, int> pii;

const int MAXN = 500005;
const int MOD = 1000000007;
const int BASE = 10007;

int N;
char s[MAXN];
int hsh[MAXN];
int pot[MAXN];
bool pref[MAXN], suff[MAXN];

void load() {
    scanf("%s", s + 1);
}

inline int add(int x, int y) {
    x += y;
    if (x >= MOD) x -= MOD;
    else if (x < 0) x += MOD;
    return x;
}
    
inline int mul(int x, int y) {
    return (long long)x * y % MOD;
}

int get(int lo, int hi) {
    return add(hsh[hi], -mul(hsh[lo - 1], pot[hi - lo + 1]));
}

pii solve() {
    N = strlen(s + 1);
    pot[0] = 1;
    for (int i = 1; i <= N; i++) {
        hsh[i] = add(mul(hsh[i - 1], BASE), s[i]);
        pot[i] = mul(pot[i - 1], BASE);
    }
    
    bool f = true;
    for (int i = 1; i <= N; i++)
        f &= s[i] == s[1];
    if (f) return pii(N, 1);

    for (int i = 1; i <= N; i++) {
        int p = get(1, i), s = get(N - i + 1, N);
        bool ok_p = true, ok_s = true;
        for (int j = 2; j <= N / i; j++) {
            ok_p &= get((j - 1) * i + 1, j * i) == p;
            pref[j * i] |= ok_p;
            ok_s &= get(N - j * i + 1, N - (j - 1) * i) == s;
            suff[N - j * i + 1] |= ok_s;
        }
    }
    
    if (!pref[N]) return pii(1, 1);
    
    int cnt = 0;
    for (int i = 1; i < N; i++)
        cnt += !pref[i] && !suff[i + 1];
    
    return pii(2, cnt);
}

int main() {
    load();
    pii sol = solve();
    printf("%d\n%d\n", sol.first, sol.second);
    return 0;
}
    


Measured memory_bytes: 5504
import sys
sys.setrecursionlimit(10**6)
edges, vertices = map(int, input().split())
dp = [None for _ in range(edges)]

nodes = [[] for _ in range(edges)]

for i in range(vertices):
    start, end = map(int, input().split())
    nodes[end -1].append(start-1)

for i in range(edges):
    if not len(nodes[i]):
        dp[i] = 0
def find(arr):
    if not len(arr):
        return 0
    for x in arr:
        if dp[x] is None:
            dp[x] = find(nodes[x])
    return 1 + max(dp[x] for x in arr)

for i in range(edges):
    dp[i] = find(nodes[i])

print(max(dp))


Measured memory_bytes: 103844
// contest.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include "bits/stdc++.h"
//実装が重そうな問題はある程度考えてから書く
//初期化を忘れずに（特に二分探索とか）
//コーナーケースを考えて（特に場合分けとか）
//不可解すぎるバグは配列外参照（配列の長さ）を検討
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int LL
#define zero 0LL
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<int> VI;
typedef vector<VI> VII;
typedef pair < ut, ut > pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5 * 1e5 + 1000;
const int SIZE2 = 5010;
const int SIZE3 = 400;
const int SIZE = SIZE1;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
ut N, M, K, X, L, Y;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
LL vals[SIZE], nums[SIZE], maps[SIZE2][SIZE2], answer = zero;
VI edges[SIZE];
queue<int> qu[2];
vector<vector<int> > qu2;
////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////
//LL L;
void init() {

}
LL solve() {
	cin >> N >> K;
	LL C = N / K;
	LL C2 = (N + K / 2) / K;
	if (K % 2) {
		cout << C * C*C << endl;
	}
	else {
		cout << C * C*C + C2 * C2*C2 << endl;
	}
	return 0;
}
signed main() {
	solve();
	return 0;
}

Measured memory_bytes: 12544
using System;
using static System.Console;
using static System.Math;


namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var s = ReadLine().Split();
            int ans = 0;
            for (int i = 0; i < 5;i++)
            {
                if (int.Parse(s[i]) == 0)
                { ans = i + 1; }
            }

            WriteLine(ans);
        }
    }

    public static class MyMath
    {
        public static long Factorical(long n)
        { return n <= 1 ? 1L : n * Factorical(n - 1); }
        public static long Permutation(long n, long m)
        { return Factorical(n) / Factorical(n - m); }
        public static long Combination(long n, long m)
        { return Permutation(n, m) / Factorical(m); }
        public static long Gcd(long n, long m)
        { return n % m == 0 ? m : Gcd(m, n % m); }
        public static long Pow(long n, long m)
        { return (m == 1 || m == 0) ? 1L : n * Pow(n, m - 1); }
    }

}

Measured memory_bytes: 17876
n = gets.chomp.to_i
arr = gets.chomp.split(" ").map(&:to_i)
cnt=0

i_bf = arr.shift
i    = arr.shift
i_af = nil

arr.each do |n|
  i_af = n
  cnt+=1 if (i_bf < i and i < i_af) or (i_bf > i and i > i_af)
  i_bf = i
  i = i_af
end
puts cnt

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

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}

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

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

    string s;
    cin >> s;

    bool outflag = false;
    int flag[30] = {0};
    for(auto itr = s.begin(); itr != s.end(); itr++){
        if(flag[*itr - 'a'] == 0){
            flag[*itr - 'a'] = 1;
        }else{
            outflag = true;
        }
    }

    if(outflag) cout << "no" << endl;
    else cout << "yes" << endl;
}

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

    using namespace std;
    #define ll unsigned long long
    #define rep(i,n) for(ll i=0;i<n;i++)
    #define pb push_back
    #define in insert
    #define test   ll t;cin>>t;while(t--)
    #define bs  binary_search
    #define rep1(x,n) for(ll x=n-1;x>=0;x--) 
    
    #define SORT(x) sort(x.begin(),x.end())
    #define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
    #define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
    #define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
    #define All(x) (x).begin(),(x).end()
    #define rAll(x) (x).rbegin(),(x).rend()
    #define db  double
    #define sc scanf
    #define pf printf
    const ll MAX=1e8;
    //ll d[MAX],h[MAX];
    const double pi=3.14159265358979323846;
    const ll M=2e18 +7;
    ll gcd(ll x,ll y){
    	if(x==0)return y;
    	else return gcd(y%x,x);
    }
    ll lcm(ll x,ll y){
    	return (x*y)/gcd(x,y);
    }
   
      bool isPrime(ll n) 
{  
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6){ 
        if (n % i == 0 || n % (i + 2) == 0){ 
            return false; 
        }
    }
    return true; 
} 
bool pdrome(string s){
    ll n = s.length();
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[n-i-1]){
            return false;
        }
    }
    return true;
}
ll mindig(ll x){
    ll ans = 9;
    ll t = x;
    while(x){
        ans = min(ans,x%10);
        x/=10;
    }
    x = t;
    return ans;
}
ll maxdig(ll x){
    ll ans = 0;
    ll t = x;
    while(x){
        ans = max(ans,x%10);
        x/=10;
    }
    x = t;
    return ans;
}
ll modpow(ll x,ll n,ll M){
	if(n==0)return 1%M;
	ll u=modpow(x,n/2,M);
	u=(u*u)%M;
	if(n%2==1)u=(u*x)%M;
	return u;

}
ll sum(ll a) {
    ll result = 0;
    while (a > 0) {
        result += a % 10;
        a /= 10;
    }
    return result;
}


  
  
    int main() {
    	ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
        unsigned int n,k,ans=0;cin>>n>>k;
        unsigned int a[n+5]={0};
        while(k--){
        	unsigned int d;
        	cin>>d;
        	for(unsigned int x=0;x<d;x++){unsigned int y;cin>>y;a[y]++;}
        }
        for(int x=1;x<=n;x++){
        	if(a[x]==0)ans++;
        }
        cout<<ans;
     
    return 0;
}
    


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

int main(void){
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N-1);
  for(int i = 0; i < N; i++){
    cin >> A[i];
    A[i]--;
  }
  for(int i = 0; i < N; i++){
    cin >> B[i];
  }
  for(int i = 0; i < N-1; i++){
    cin >> C[i];

  }

  int ans = 0;
  for(int i = 0; i < N; i++){
    int eat = A[i];
    ans += B[eat];
    if(i > 0){
      if(A[i] == A[i-1] + 1){
        ans += C[A[i-1]];
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  int cnt = 0;
  for (auto& c : s) cnt += c == 'o';
  cnt += 15 - s.size();
  cout << (cnt >= 8 ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
data = list(zip([int(n) for n in input().split()], [int(n) for n in input().split()]))
dist = []
for pair in data:
    dist.append(abs(pair[0] - pair[1]))
print(sum(dist))
print(pow(sum(n ** 2 for n in dist), 1 / 2))
print(pow(sum(n ** 3 for n in dist), 1 / 3))
print(max(dist))

Measured memory_bytes: 7820
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

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

    vector<long long> A(N+1,0);
    for(int i=0; i<=N; i++){
        cin >> A[i];
    }

    long long tmp=0;
    long long ans=0;
    for(int i=0; i<N; i++){
        long long B;
        cin >> B;

        ans+=min(tmp, A[i]);
        A[i]=max((long long)0,A[i]-tmp);

        tmp=max((long long)0, B-A[i]);
        ans+=min(A[i], B);
    }
    ans+=min(tmp,A[N]);
    cout << ans << endl;
}

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

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<Edge>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}



bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int dfs(int x,int y,int H,int W,vector<vector<char>> &masu){
  if(masu[x][y] == '#'){

  }
}
bool palin(string S){
  int n = S.size();
  bool flag = true;
  if(n%2 == 0){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  else if(n%2 == 1){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}
int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<int> v;
  int x = 0;
  v.push_back(0);
  rep(i,N){
    if(S[i] == 'I') x++;
    else x--;
    v.push_back(x);
  }
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  cout << v[0] << endl;

}

Measured memory_bytes: 256
while True:
    n = int(input())
    if n == 0:
        break
    w = []
    go = 0
    flag = True
    x = 0
    count = 0
    for i in range(n):
        w.append(input())
    else:
        while count < 5:
            for i in range(x,n):
                go += len(w[i])
                if flag == True:
                    if go == 5:
                        flag = False
                        count += 1
                        go = 0
                    if go > 5:
                        x += 1
                        go = 0
                        count = 0
                        break
                if flag == False:
                    if go == 7 and count == 3:
                        flag = False
                        count += 1
                        go = 0
                    if go == 7:
                        flag = True
                        count += 1
                        go = 0
                    if go > 7:
                        x += 1
                        go = 0
                        count = 0
                        flag = True
                        break
                if count == 5:
                    break
    print(x + 1)



Measured memory_bytes: 5612
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,D,A = map(int,readline().split())
m = map(int,read().split())
X, H = zip(*sorted(zip(m,m)))

Xs = sorted(set(X) | set(x + D + D for x in X))
x_to_i = {x:i for i,x in enumerate(Xs)}

L = len(Xs)
d_atk = [0] * L

HP = [0] * L
for x,h in zip(X,H):
    i = x_to_i[x]
    HP[i] = h

d_atk = [0] * L

atk = 0 # 予約済の値を管理
answer = 0
for i in range(L):
    x = Xs[i]
    h = HP[i]
    if h > atk:
        rest = h - atk
        n = (rest + A - 1) // A
        atk += n * A
        answer += n
        d_atk[x_to_i[x+D+D]] = -n * A
    atk += d_atk[i]

print(answer)


Measured memory_bytes: 99724
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int a = sc.nextInt();
		int p = sc.nextInt();
		
		// 計算
		int result = (3*a + p)/2;

		// 出力
		System.out.println(result);
		
	}
}


Measured memory_bytes: 21844
#include<stdio.h>
main(){
  int a[1000000]={0},i,j,n,cnt;
  while(scanf("%d",&n)!=EOF){
    for(i=0;i<=n;i++)a[i]=0;
    cnt=0;
    for(i=2;i<=n;i++){
      if(a[i]==0){
    cnt++;
    for(j=1;i*j<=n;j++){
      a[i*j]=1;
    }      
      }
    }
 
 
    printf("%d\n",cnt);
  }
  return 0;
}


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

int main()
{
	int m = 0;

	for (int i = 0; i < 5; i++) {
		int a;
		cin >> a;

		if (a < 40)
			m += 40;
		else
			m += a;
	}

	cout << m / 5 << endl;

	return 0;
}


Measured memory_bytes: 3124
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String str = scanner.next();
		String order,change;
		int q = scanner.nextInt();
		int a,b;

		for(int i=0;i<q;i++){
			order = scanner.next();

			if(order.equals("print")){

				a = scanner.nextInt();
				b = scanner.nextInt();

				print(str,a,b);

			}else if(order.equals("reverse")){

				a = scanner.nextInt();
				b = scanner.nextInt();

				str = reverse(str,a,b);

			}else{

				a = scanner.nextInt();
				b = scanner.nextInt();
				change = scanner.next();

				str = replaceStr(str,a,b,change);
			}
		}
	}

	private static void print(String str,int a,int b){
		String output = str.substring(a, b+1);
		System.out.println(output);
	}

	private static String reverse(String str,int a,int b){

		char work[] = str.toCharArray();

		int num = b-a+1;
		char tmp;

		for(int i = 0; i < num/2; i++){

			tmp = work[a+i];
			work[a+i] = work[b-i];
			work[b-i] = tmp;
		}

		return String.valueOf(work).substring(0, str.length());
	}

	private static String replaceStr(String str,int a,int b,String change){

		char ch[] = change.toCharArray();
		char work[] = str.toCharArray();

		for(int i = a; i <= b; i++){
			work[i] = ch[i-a];
		}

		return String.valueOf(work).substring(0,str.length());
	}
}



Measured memory_bytes: 29460
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())


W,H,x,y=LI()

if (x*2) == W and (y*2) == H:
    print(H*W*0.5, 1)
else:
    print(H*W*0.5, 0)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
                using namespace std;
                typedef long long ll;
                #define MAX 200005
                bool arr[12];
                bool chk(int a)
                {
                    while(a > 0)
                    {
                        int c = a % 10;
                        if(arr[c])return false;
                        a /= 10;
                    }
                    return true;
                }
                int main()
                {
                      int n,k;scanf("%d%d",&n,&k);

                      for(int i = 0 ; i < k ; i++)
                      {
                            int a;scanf("%d",&a);
                            arr[a] = true;
                      }
                      for(int i = n ; ; i++)
                      {
                            if(chk(i))
                            {
                                printf("%d\n",i);
                                break;
                            }
                      }

                }


Measured memory_bytes: 256
// finish date: 2018/01/11
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

#define bigmod 1000000007
using namespace std;

#define FOR(i, a, b) for(int i=a;i<b;i++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long

int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}

int factorial(int n) {
    int ans = 1;
    FOR(i, 1, n + 1) {
        ans = ans * i;
    }
    return ans;
}

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    FOR(i,1,B+1) {
        if ((A*i) % B == C) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256