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

namespace AtCoder_solve
{
    class Program
    {
        static void Main(string[] args)
        {
            /* string[] data1 = Console.ReadLine().Split(' ');
             string[] data2 = Console.ReadLine().Split(' ');*/
            long n = long.Parse(Console.ReadLine());
            string[] data3 = Console.ReadLine().Split(' ');
            string ans = "";

            var memo = new bool[1000000000];

            for(int i = 0; i < n; i++)
            {
                long a = long.Parse(data3[i]);
                if (memo[a])
                {
                    ans = "NO";
                    break;
                }
                else
                {
                    ans = "YES";
                    memo[a] = true;
                }
            }




            Console.WriteLine(ans);
            
            
        }
    }
}


Measured memory_bytes: 1003548
a = int(input())
List_a=list(map(int,input().split()))
List_b=list(map(int,input().split()))
List_c=list(map(int,input().split()))
B = 0
count = 0
key = 0
for i in List_a:
  B += List_b[i-1]
  if count > 0 and key+1 ==i:
    B += List_c[i-2]
  key = i
  count += 1
 
print(B)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n;
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	int ans=8;
	int now=400;
	while(now<=1800){
		if(n>=now&&n<now+200){
			cout<<ans;
			re 0;
		}
		ans--;
		now+=200;
	}
	re 0;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
#include <ctime>
#include <numeric>
using namespace std;
static const double EPS = 1e-6;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const double pi=acos(-1);
int dx[]={0,1,0,-1,1,1,-1,-1},dy[]={1,0,-1,0,1,-1,1,-1};

int vb[128];

bool cl(string &in){
  set<char>val;
  FOR(it,in){
    if(isalpha(*it))val.insert(*it);
    if(*it=='&')*it=' ';
  }

  vector<char> app;
  FOR(it,val)app.pb(*it);
  rep(i,1<<SZ(app)){
    rep(j,SZ(app))vb[app[j]]=!!(i&(1<<j));

    stringstream ss(in.substr(1,SZ(in)-2));
    string va;
    bool ok=true;
    while(ss>>va){
      if(va[0]=='~')ok&=!vb[va[1]];
      else ok&=vb[va[0]];
    }
    if(ok)return true;
  }
  return false;
}

main(){
  string in;
  while(cin>>in,in!="#"){
    FOR(it,in)if(*it=='|')*it=' ';
    stringstream ss(in);
    bool ok=false;
    while(ss>>in){
      if(cl(in)){
        ok=true;
        break;
      }
    }
    cout<<(ok?"yes":"no")<<endl;
  }
}

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

int main() {
    int n;
    bool f_possible = true;
    cin >> n;
    int a[n];
    map<int, int> mp;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        mp[a[i]]++;
        if(n%2 == a[i]%2) f_possible = false;
        if(mp[a[i]] >= 3) f_possible = false;
        if(a[i] == 0 && mp[0] >= 2) f_possible = false;
    }
    if(!f_possible) {
        cout << 0 << '\n';
        return 0;
    }
    int N = mp.size();
    if(n%2 == 1) N--;
    long long int ans = 1;
    for(int i = 0; i < N; ++i) {
        ans <<= 1;
        ans %= 1000000007;
    }

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


Measured memory_bytes: 3584
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <algorithm>

using namespace std;

struct edge{int to, cost;};
typedef pair<int,int> P;
int pre[100000];
int nex[100000];

int V;
vector <edge> G[100000];
int d[100000];
int d2[100000];

void dijkstra(int s){
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d+100000, 500000);
	fill(pre, pre+100000, -1);
	fill(nex, nex+100000, -1);
	d[s] = 0;
	que.push(P(0,s));

	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i=0; i<G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				pre[e.to] = v;
				que.push(P(d[e.to], e.to));
			}
		}
	}

}

void dijkstra2(int s){
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d2, d2+100000, 500000);
	fill(pre, pre+100000, -1);
	fill(nex, nex+100000, -1);
	d2[s] = 0;
	que.push(P(0,s));

	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if(d2[v] < p.first) continue;
		for(int i=0; i<G[v].size(); i++){
			edge e = G[v][i];
			if(d2[e.to] > d2[v] + e.cost){
				d2[e.to] = d2[v] + e.cost;
				pre[e.to] = v;
				que.push(P(d2[e.to], e.to));
			}
		}
	}

}


int main(){
	int N;
	int num[100000];

	scanf("%d",&N);

	for(int i=0;i<N;i++){
		num[i] = 0;
	}

	for(int i=0;i<N-1;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		a--; b--;
		edge e1;
		e1.to = b; e1.cost = 1;
		edge e2;
		e2.to = a; e2.cost = 1;
		G[a].push_back(e1);
		G[b].push_back(e2);
		num[a]++;
		num[b]++;
	}

	dijkstra(0);
	dijkstra2(N-1);

	int f = 0;
	int s = 0;

	for(int i=0;i<N;i++){
		if(d[i]<=d2[i]){
			f++;
		}else{
			s++;
		}
	}

	if(f>s){
		printf("Fennec\n");
	}else{
		printf("Snuke\n");
	}



	return 0;
}


Measured memory_bytes: 8304
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main()
{
    int a,b,i;
    string g="";
    cin>>a>>b;
    string x=to_string(a);
    string y=to_string(b);
    if(a>b){
        for(i=0;a>i;i++)
            g+=y;
    }
    else
        for(i=0;b>i;i++)
            g+=x;
    cout<<g;
}   
      

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    long long int n,bot,top,xa,xb;
    scanf("%lld %lld %lld",&n,&bot,&top);
    if(n==1){
        if(bot==top){
            printf("1\n");
            return 0;
        }else{
            printf("0\n");
            return 0;
        }
    }
    if(bot>top){
        printf("0\n");
        return 0;
    }
    xa=bot*(n-1)+top;
    xb=top*(n-1)+bot;
    printf("%lld\n",xb-xa+1);
    return 0;
}


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

// 2??°?????????sum??¨??????????????????????????°?????¢???
int nsum_two(int m, int n, int sum)
{
    int nsum = 0;
    for (int i = m; i < (sum / 2.0); i++)
    {
        if ((sum - i) > n) continue; //?????§?????????n????¶?????????????????????§??????
        nsum++;
    }
    return nsum;
}
        
int main()
{
    while (true)
    {
        int n, x;
        cin >> n >> x;
        if (n == 0 && x == 0) break;
        int nsum_three = 0;
        for (int j = 1; j < (x / 3); j++)
        {
            nsum_three += nsum_two(j + 1, n, x - j);
        }
    cout << nsum_three << endl;
    }
    return 0;
}

Measured memory_bytes: 3092
$b=-1;
$n=<STDIN>;
chomp $n;
for($i=0;$i<$n;$i++)
{
$a=<STDIN>;
chomp $a;
if($a-$b>1){print "-1";exit;}
if($a -$b==1){$c++;}
else{$c+=$a;}
$b=$a;
}
$c--;
print "$c";


Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.nextString();

            int min = Integer.MAX_VALUE;
            for (int i = 0; i < s.length() - 2; i++) {
                min = Math.min(min, Math.abs(753 - Integer.parseInt(s.substring(i, i + 3))));
            }

            out.println(min);
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 22740
#include <iostream>
using namespace std;
long long five(long long a)
{
	return a * a * a * a * a;
}
int main()
{
	long long x;
	cin >> x;
	for (long long a = -119; a <= 119; a++)
	{
		for (long long b = -119; b <= 119; b++)
		{
			if (five(a) - five(b) == x)
			{
				cout << a << ' ' << b << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3584
// 3_abc130_c
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
#define MOD (1000000007)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << w * h / 2 << " ";
    if(x == w / 2 && y == h / 2) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}


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


int main()
{
	int minn(10), t;
	int ct[5];
	
	for (int i = 0; i < 5; ++i)
		scanf("%d", ct + i);
	for (int i = 0; i < 5; ++i)
		if ((t = ct[i] % 10)) {
			minn > t && (minn = t);
			ct[i] += 10 - t;
		}
	printf("%d\n", ct[0] + ct[1] + ct[2] + ct[3] + ct[4] + minn - 10);
	return 0;
}



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

int main()
{
int N,x;scanf("%d %d",&N,&x);
vector<int> a(N);
for(int i=0;i<N;i++)scanf("%d ",&a[i]);
sort(a.begin(),a.end());
int nc=0;
while(x>=a[nc]&&nc<N){x-=a[nc];nc++;}
if(x>0&&nc==N)nc--;
printf("%d\n",nc);
}

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

int main() {
    int x, y, i;
    for (i = 0; i < 3001; i++) {
        cin >> x >> y;
        if (x == 0 && y == 0) {
            break;
        }
        else {
            if(x < y) {
                cout << x << " " << y << endl;
            }
            else {
                cout << y << " " << x << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3072
#include<iostream>
#include<bits/stdc++.h>
#define pb push_back
using namespace std;

int n;
vector<pair<int, int> > graph[2505];
vector<pair<int, int> > rgraph[2505];

int from_source[2505];
int to_goal[2505];

void dfs(int pos){
	from_source[pos] = 1;
	int sz = graph[pos].size();
	for(int i=0;i<sz;i++){
		int v= graph[pos][i].first;
		if(from_source[v] != 1){
			dfs(v);
		}
	}
}

void dfs2(int pos){
	to_goal[pos] = 1;
	int sz = rgraph[pos].size();
	for(int i=0;i<sz;i++){
		int v= rgraph[pos][i].first;
		if(to_goal[v] != 1){
			dfs2(v);
		}
	}
}
int32_t main()
{
	int m, p;

	cin>>n>>m>>p;

	for(int i=0;i<m;i++){
		int u, v, ci;
		cin>>u>>v>>ci;
		graph[u].push_back({v,p-ci});
		rgraph[v].push_back({u, 0});
	}

	int dist[2505];
	for(int i=1;i<=n;i++) dist[i] = INT_MAX;
	dist[1] = 0;

	for(int v=0;v<n-1;v++){
		for(int i=1;i<=n;i++){
			int sz = graph[i].size();
			for(int j=0;j<sz;j++){
				pair<int, int> k = graph[i][j];
				if(dist[i] != INT_MAX && dist[k.first] > dist[i] + k.second){
					dist[k.first] = dist[i] + k.second;
				}
			}
		}
	}

	int f = 1;
	memset(from_source, -1, sizeof(from_source));
	memset(to_goal, -1, sizeof(to_goal));
	dfs(1);
	dfs2(n);

	for(int i=1;i<=n;i++){
		int sz = graph[i].size();
		for(int j=0;j<sz;j++){
			pair<int, int> k = graph[i][j];
			if(dist[i] != INT_MAX && dist[k.first] > dist[i] + k.second && from_source[k.first] == 1 && to_goal[k.first] == 1){
				f = 0;
			}
		}
	}

	if(f == 1){
		int ans = -1*dist[n];
		if(ans < 0) ans = 0;
		cout<<ans<<endl;
	}
	else cout<<-1<<endl;

	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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 modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  char b;
  cin >> b;
  map<char, char> l;
  l['A']='T';
  l['T']='A';
  l['C']='G';
  l['G']='C';
  cout << l[b];
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
#define f2(i,j,k) for(int i=j;i>k;i--)
using namespace std;
int main(){
    long long k;
    double n;
    cin>>n>>k;
    double ans=0;
    f(i,1,n+1){
        long double a=1/n;
        long long now=i;
        while(now<k){
            now*=2;
            a/=2;
        }
        ans+=a;
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3740
color_used = [0 for i in range(9)]

N = int(input())
a = [int(i) for i in input().split()]
for i in range(N):
    for j in range(1,9):
        if a[i] < 400*j:
            color_used[j-1] += 1
            break
    else:
        color_used[8] += 1

c = 0
for i in range(8):
    if color_used[i]:
        c += 1
# ma = min(8, c+color_used[8])
ma = c+color_used[8]
mi = max(c, 1)

print(mi, ma)


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
n = int(input())
ab = list()
for _ in range(n - 1):
    ab.append(list(map(int, input().split())))

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

tree = [[] for i in range(n)]
for a, b in ab:
    tree[a - 1].append(b - 1)
    tree[b - 1].append(a - 1)

c.sort(reverse=True)

ans = [-1 for _ in range(n)]

ans[0] = c[0]
c.pop(0)
q = list()
q.append(0)

while(len(q) != 0):
    v = q[0]
    q.pop(0)
    for u in tree[v]:
        if ans[u] != -1:
            continue
        ans[u] = c[0]
        c.pop(0)
        q.append(u)

print(sum(ans[1:]))
print(" ".join([str(a) for a in ans]))

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



struct Info{

	bool operator<(const struct Info &arg) const{
		if(left != arg.left){

			return left < arg.left;
		}else{

			return right < arg.right;
		}
	};

	ll color,left,right;
};

int N;
ll table[7][2000005];
map<int,int> MAP;
Info info[200005];


void init(int first_N){
	while(N < first_N)N *= 2;
}

void update(int index,int loc,ll value){
	loc += N-1;

	if(table[index][loc] >= value)return;

	table[index][loc] = value;

	if(N == 1)return;

	int parent = (loc-1)/2;

	while(true){
		table[index][parent] = max(table[index][2*parent+1],table[index][2*parent+2]); //親は左右の子の大きい方の値を持つ

		if(parent == 0)break;
		else{
			parent = (parent-1)/2;
		}
	}
}


ll query(int index,int search_left,int search_right,int node_id,int node_left,int node_right){

	if(search_right < node_left || search_left > node_right)return -HUGE_NUM;

	if(search_left <= node_left && search_right >= node_right){
		return table[index][node_id];
	}

	ll left_max = query(index,search_left,search_right,2*node_id+1,node_left,(node_left+node_right)/2);
	ll right_max = query(index,search_left,search_right,2*node_id+2,(node_left+node_right)/2+1,node_right);

	return max(left_max,right_max);
}


int main(){

	int num_panel,num_robot;
	ll X,Y;

	scanf("%d %d %lld %lld",&num_panel,&num_robot,&X,&Y);

	vector<int> V;
	V.push_back(0);

	for(int i = 0; i < num_robot; i++){

		scanf("%lld %lld %lld",&info[i].color,&info[i].left,&info[i].right);
		V.push_back(info[i].left);
		V.push_back(info[i].right);
	}

	sort(V.begin(),V.end());
	V.erase(unique(V.begin(),V.end()),V.end());

	for(int i = 0; i < V.size(); i++){

		MAP[V[i]] = i;
	}

	int first_N = V.size();
	N = 1;
	init(first_N);

	for(int i = 0; i < 7; i++){
		for(int k = 0; k <= 2*N-2; k++){

			table[i][k] = -HUGE_NUM;
		}
	}

	update(0,0,0);

	sort(info,info+num_robot);

	ll ans = 0;
	ll tmp_value;

	for(int i = 0; i < num_robot; i++){

		tmp_value = query(0,0,MAP[info[i].left]-1,0,0,N-1)+(info[i].right-info[i].left+1)*X; //過去最大値+今回の値(重なりなし)

		//重なりあり
		for(int k = 1; k <= 3; k++){
			if(k == info[i].color){

				tmp_value = max(tmp_value,query(k,MAP[info[i].left],MAP[info[i].right]-1,0,0,N-1)+info[i].right*X);

			}else{

				tmp_value = max(tmp_value,query(k+3,MAP[info[i].left],MAP[info[i].right]-1,0,0,N-1)+
						(info[i].left+info[i].right-1)*X+(info[i].left-1)*Y);
			}
		}

		ans = max(ans,tmp_value);

		update(0,MAP[info[i].right],tmp_value); //全体
		update(info[i].color,MAP[info[i].right],tmp_value-info[i].right*X);
		update(info[i].color+3,MAP[info[i].right],tmp_value-info[i].right*(2*X+Y));
	}

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

	return 0;
}



Measured memory_bytes: 85444
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int,int>;


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;
ll SUM(ll n){
    ll ans=0;
    for(ll i=1;i<=n;i++)ans+=i;
    return ans;
}

int main(){
    int R,G,B,N; cin >> R >> G >> B >> N;
    ll count=0;
    int r=0;
    while(N-r*R>=0){
        int g=0;
        while(N-r*R-g*G>=0){
            if((N-r*R-g*G) % B == 0){count++;}
            g++;
        }
        r++;
    }
    cout << count << endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];
    int a, b;
    vector<int> C;
    for (int i = 1; i <= N; i++) C.push_back(i);
    int cnt = 1;
    if (A==C) a = cnt;
    if (B==C) b = cnt;
    while (next_permutation(C.begin(), C.end())) {
        cnt++;
        if (A==C) a = cnt;
        if (B==C) b = cnt;
    }
    cout << abs(b-a) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <functional>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

struct Graph {
    struct Edge {
        bool operator>(Edge o) { return d > o.d; }
        int d, i;
    };
    Graph(int n) : e(n), v(n) {}
    void add_edge(int i, int j, int l) {
        e[i].push_back({ l, j });
    }
    void dijkstra(int i) {
        priority_queue<Edge, vector<Edge>, greater<>> q;
        fill(v.begin(), v.end(), 1 << 30);
        q.push({ v[i] = 0, i });
        while (!q.empty()) {
            auto p = q.top(); q.pop();
            if (p.d > v[p.i]) continue;
            for (auto o : e[p.i]) {
                int d = p.d + o.d;
                if (d < v[o.i]) {
                    v[o.i] = d;
                    q.push({ d, o.i });
                }
            }
        }
    }
    vector<vector<Edge>> e;
    vector<int> v;
};

int n, m, R;
int r[8];
int d[8][8];

int64_t foo(int m, int j, int t) {
    if (m == 0) return t;

    int64_t s = 1 << 30;
    for (int i = 0; i < R; i++) {
        if (!(m & 1 << i)) continue;
        s = min(s, foo(m ^ 1 << i, i, t + (j < 0 ? 0 : d[j][i])));
    }
    return s;
}

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

    cin >> n >> m >> R;

    for (int i = 0; i < R; i++) {
        cin >> r[i];
        r[i]--;
    }

    Graph g(n);
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;

        g.add_edge(a, b, c);
        g.add_edge(b, a, c);
    }

    for (int i = 1; i < R; i++) {
        g.dijkstra(r[i]);
        for (int j = 0; j < i; j++) {
            d[i][j] = d[j][i] = g.v[r[j]];
        }
    }

    cout << foo((1 << R) - 1, -1, 0) << endl;

    return 0;
}

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

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


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
#include <cctype>

using namespace std;

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

int n, q;
int A[2000];
int M[2000];

bool solve(int i, int sum, int M_j)
{
	if(i > n) return false;

	if(sum == M_j) return true;

	// A[i]を利用しない場合
	if(solve(i + 1, sum, M_j)) return true;
	// A[i]を利用する場合
	if(solve(i + 1, sum + A[i], M_j)) return true;

	return false;
}

int main()
{
	cin >> n;
	REP(i, n)
		cin >> A[i];

	cin >> q;
	REP(i, q)
		cin >> M[i];


	REP(i, q) {

		if(solve(0, 0, M[i]))
			cout << "yes";
		else
			cout << "no";

		cout << endl;

	}

		return 0;
}

Measured memory_bytes: 1164
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 200100;

int n, a[N], b[N];

int main() {

	scanf("%d", &n);

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

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

	long long res = 0;

	for (int i = n - 1; i >= 0; i--) {
		int k = min(b[i], a[i + 1]);
		res += k;
		b[i] -= k;
		a[i + 1] -= k;
		int l = min(b[i], a[i]);
		res += l;
		b[i] -= l;
		a[i] -= l;
	}

	printf("%lld\n", res);

	return 0;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<string> S(N);
    REP(i,N) cin >> S[i];

    ll ans = 0;

    REP(k,N){
        vector<string> T(N, string(N,' '));
        REP(i,N) REP(j,N) T[i][(j+k)%N] = S[i][j];

        bool ok = true;
        REP(i,N) REP(j,N){
            if(T[i][j] != T[j][i]) ok = false;
        }
        if(ok) ans++;
    }
    cout << ans * N << endl;
}

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

using namespace std;

int gcd(int x, int y) {
  if (y == 0) {
    return x;
  }
  return gcd(y, x % y);
}

int main() {
  int n, k;
  cin >> n >> k;
  
  vector<int> a(n);
  int ma = 0;
  int g = -1;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    ma = max(ma, a[i]);
    if (g == -1) g = a[i];
    else g = gcd(g, a[i]);
  }
  if (k <= ma && k % g == 0) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> a(3*N);
    for(int i=0; i < 3*N; i++){
        cin >> a[i];
    }

    sort(a.begin(), a.end(), greater<int>());

    long max = 0;

    for(int i=0; i < N; i++){
        //cout << a[2 * i + 1] << endl;
        max += a[2 * i + 1];
    }

    cout << max << endl;

}

Measured memory_bytes: 1408
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = sum(b)
for i in range(n-1):
    if a[i]+1==a[i+1]:
        ans += c[a[i]-1]
print(ans)

Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func even(n int) bool {
	if n%2 == 0 {
		return true
	}
	return false
}

func travel(n int, t, x, y []int) string {
	post, posx, posy := 0, 0, 0
	for i, _ := range t {
		difft := abs(t[i] - post)
		diffx := abs(x[i] - posx)
		diffy := abs(y[i] - posy)
		if difft < diffx+diffy {
			return "No"
		}
		if even(difft) != even(diffx+diffy) {
			return "No"
		}
		post = t[i]
		posx = x[i]
		posy = y[i]
	}
	return "Yes"
}

func main() {
	var n int
	fmt.Scan(&n)
	time := make([]int, n)
	x := make([]int, n)
	y := make([]int, n)
	for i := range time {
		fmt.Scan(&time[i])
		fmt.Scan(&x[i])
		fmt.Scan(&y[i])
	}
	fmt.Println(travel(n, time, x, y))
}


Measured memory_bytes: 5504
import scala.io.StdIn.{readInt, readLine}
object Main {
    def main(args: Array[String]): Unit = {
        val len = readInt
        val arr = readLine.split(" ").map(_.toInt)
        val n = mergeSort(arr, 0, len - 1)
        println(arr.mkString(" "))
        println(n)
    }
    def mergeSort(arr: Array[Int], left: Int, right: Int): Int = {
        if (right - left > 0) {
            val compare = right - left + 1
            val mid = (left + right) / 2
            val r1 = mergeSort(arr, left, mid)
            val r2 = mergeSort(arr, mid + 1, right)
            merge(arr, left, mid, right)
            compare + r2 + r1
        } else {
            0
        }
    }
    def merge(arr: Array[Int], left: Int, mid: Int, right: Int): Unit = {
        val leftHalfLen = mid - left + 1// 左半分の配列の要素数
        val tmp = arr.slice(left, mid + 1) // 左半分の配列 
        var leftPtr = 0
        var rightPtr = mid + 1
        for (i <- (left to right)) {
            if (leftPtr == leftHalfLen) {// 左半分を最後まで評価し終わった場合
                rightPtr += 1
            } else if (rightPtr == right + 1) { // 右半分を最後まで評価し終わった場合
                arr(i) = tmp(leftPtr)
                leftPtr += 1
            } else { // 左半分、右半分どちらも評価する要素が残っている場合
                if (tmp(leftPtr) <= arr(rightPtr)) {
                    arr(i) = tmp(leftPtr)
                    leftPtr += 1
                } else {
                    arr(i) = arr(rightPtr)
                    rightPtr += 1
                }
            }
        }
    }
}


Measured memory_bytes: 353780
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			int K = sc.nextInt();
			int[] h = new int[N];
			for (int i=0;i<N;i++) {
				h[i]=sc.nextInt();
			}
			Arrays.sort(h);

			int A=N-K+1;
			int[] dif = new int[A];
			for (int i=0;i<A;i++) {
				dif[i]=h[K-1+i]-h[i];
			}
			Arrays.sort(dif);
			System.out.println(dif[0]);
	}
}

Measured memory_bytes: 49808
import java.util.*;class Main{public static void main(String[]z){String r="",c=r;for(Scanner s=new Scanner(System.in);s.hasNext();){z=s.next().split(",");if(25<=new Double(z[1])/Math.pow(new Double(z[2]),2))r+=z[0]+"\n";}System.out.print(r==c?"ツ該ツ督鳴づ按つオ":r);}}

Measured memory_bytes: 12000
#include <stdio.h>

int main()
{
  int n,m,i,p;
  int ac[100005]={0},wa[100005]={0};
  int WA=0,AC=0;
  char s[3];

  scanf("%d%d", &n,&m);

  for(i=0; i<m; i++){
    scanf("%d",&p);
    scanf("%s",s);
    if(ac[p]==1)
      continue;
    else if(s[0] == 'A')
      {
      WA += wa[p];
      ac[p]++;
      AC++;
      }
    else
      wa[p]++;
  }

  printf("%d %d", AC,WA);
  return 0;
}


Measured memory_bytes: 2516
#include<bits/stdc++.h>
using namespace std;
int ans,n,k,a,b,lim;

int main(){
    cin >> n >> k;

    if(n%2==0){
            lim=n/2;
    for(int i=0;i<k;i++){
        cin >> a >> b;
        if(a>lim)a=n-a+1;
        if(b>lim)b=n-b+1;
        if(min(a,b)%3==1)cout << 1 << endl;
        else if(min(a,b)%3==2)cout << 2 << endl;
        else cout << 3 << endl;
        }
    }else{
        lim=n/2+1;
    for(int i=0;i<k;i++){
        cin >> a >> b;
        if(a>lim)a=n-a+1;
        if(b>lim)b=n-b+1;
        if(min(a,b)%3==1)cout << 1 << endl;
        else if(min(a,b)%3==2)cout << 2 << endl;
        else cout << 3 << endl;
        }
    }


return 0;
}

Measured memory_bytes: 1160
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
//#define         ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         mod                         1000000007
#define         INF                         2e18
#define         EPS                         1e-15
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;

vector<ll>v;
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n,t,x,y;
    sfl(n),sfl(t);
    v.clear();
    FOR(i,n){
        sfl(x),sfl(y);
        if( y<=t ){
            v.pb(x);
        }
    }
    ll sz = v.size(),ans;
    if( sz==0 ){
        printf("TLE\n");
    }
    else{
        sort(all(v));
        ans = v[0];
        pfl(ans);
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
  int n,ans;
  int m[6]={500,100,50,10,5,1};
  while(1){
    scanf("%d",&n);
    if(n==0) break;
    ans=0;
    n=1000-n;
    for(int i=0;i<6;i++){
      ans+=n/m[i];
      n%=m[i];
    }
    printf("%d\n",ans);
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
string a;
int b,c,i;
bool flag;
int main()
{
    getline(cin,a);
    while(a[i]>='0'&&a[i]<='9') b=b*10+(int)(a[i]-'0'),i++;
    i++;
    if(a[i]=='+')
    flag=1;
    
    i++;
    i++;
    while(a[i]>='0'&&a[i]<='9') c=c*10+(int)(a[i]-'0'),i++;
    if(flag) cout<<b+c;
    else cout<<b-c;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long n,m,i,j,k,x,y,z;
    x=0;
    cin>>n>>m;
    for (i=0;i<n;i++)
    {
    	cin>>arr[i];
    	x+=arr[i];
	}
	if (x%(4*m)==0)
	{
		y=x/(4*m);
		z=0;
		for (i=0;i<n;i++)
		{
			if (arr[i]>=y)
			{
				z++;
			}
		}	
	}
	else
	{
		y=x/(4*m);
		z=0;
		for (i=0;i<n;i++)
		{
			if (arr[i]>y)
			{
				z++;
			}
		}		
	}
	if (z>=m)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int input[] = new int[n];
		
		for(int i = 0; i < n; i++) {
			input[i] = sc.nextInt();
		}
	
		for(int i = 0; i < n; i++) {
			if(input[i]%2 == 0 && input[i]%3 != 0 && input[i]%5 != 0) {
				System.out.println("DENIED");
				return;
			}
		}
		
		System.out.println("APPROVED");
	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define int long long int
vector<int>g[200005];
bool vis[200005];
int ans;
void dfs(int src)
{

    vis[src]=true;
    ans++;
    for(auto x: g[src])
    {
        if(!vis[x])
        dfs(x);
    }
}

signed main()
{
  int n,m;
  cin>>n>>m;
  while(m--)
  {
      int x,y;
      cin>>x>>y;
      g[x].push_back(y);
      g[y].push_back(x);
  }
  int mx=0;
  for(int i=1;i<=n;i++)
  {
      if(!vis[i])
      {
          ans=0;
          dfs(i);
         mx=max(mx,ans); 
      }
  }
  cout<<mx<<endl;
	return 0;
}


Measured memory_bytes: 20868
#include<iostream>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)

int main(){
  ll n,m,x[100010],y[100010],k[100010]={};
  bool a[100010]={1};
  cin>>n>>m;
  fr(i,m){
    cin>>x[i]>>y[i];
    x[i]--;
    y[i]--;
  }
  fr(i,n) k[i]=1;
  fr(i,m){
    k[x[i]]--;
    k[y[i]]++;
    if(a[x[i]]>0){
      if(k[x[i]]<1) a[x[i]]=0;
      a[y[i]]=1;
    }
  }
  ll ans=0;
  fr(i,n) if(a[i]>0) ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 2688
#include <stdio.h>
int main(){
  int n,a,r=0,s=1000;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a);
    if(r<a)r=a;
    if(s>a)s=a;
  }
  printf("%d",r-s);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline void read(T &x){
    register short f=1;x=0;char c=getchar();
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=f;
}
template<typename T>inline void write(T x){
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
template<typename T>inline void writeln(T x){
    write(x),putchar('\n');
}
int main(){
    int n,a[210],ans=0;
    read(n);
    for(int i=1;i<=2*n;i++)read(a[i]);
    sort(a+1,a+2*n+1);
    for(int i=1;i<=2*n;i+=2)ans+=a[i];
    writeln(ans);
    return 0;
}

Measured memory_bytes: 256
#include <algorithm> 
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int res =0 ;
    for(int i= 1; i<= n; i++){
        for(int j =1 ; j<=n; j++){
            for(int k =1 ;k<=n ;k++){
                res += __gcd(i,__gcd(j,k));
            }
        }
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 3636
use std::cmp::max;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse! {
        it,
        n: usize,
        a: [usize;3],
        b: [usize;3],
    };
    let mut maxab = n;
    for i in 0..(n + 1) {
        for j in 0..(n + 1) {
            let s = a[0] * i + a[1] * j;
            if s > n {
                break;
            }
            let r = n - s;
            let k = if a[2] > b[2] { 0 } else { r / a[2] };
            maxab = max(maxab, i * b[0] + j * b[1] + k * b[2] + r - k * a[2]);
            if a[1] >= b[1] {
                break;
            }
        }
        if a[0] >= b[0] {
            break;
        }
    }
    let n = maxab;
    let mut dp = vec![(0..n + 1).collect::<Vec<usize>>(); 4];
    for i in 0..3 {
        for j in 1..(n + 1) {
            dp[i + 1][j] = max(
                dp[i][j],
                if j >= b[i] && a[i] > b[i] {
                    dp[i + 1][j - b[i]] + a[i]
                } else {
                    0
                },
            )
        }
    }
    println!("{}", dp[3][n]);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


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

int main(){
 int n;cin>>n;
  vector<int> arr(n);
  for(int i = 0; i < n; i++) cin>>arr[i];
  int sum = 0;
  for(int i = 0; i < n; i++)for(int j = i+1; j<n; j++) sum+=(arr[i]*arr[j]);
  cout<<sum;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	input = input.split(" "); // 1行目がinput[0], 2行目がinput[1], …に入る
    // ここに処理を書く
    var N = input[0]
    var D = input[1]
    var count = 0
    var range = 0
    while (range < N) {
        range = range + Number(D) + 1 + Number(D)
        count++
    }

    
	// console.logは標準出力に1行出力します (自動的に最後に改行が入ります)
	console.log(count);
}

// ※この行以降は編集しない (標準入力から一度に読み込みMainを呼び出します)
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
int main(){
  int m,n;
  cin >>m>>n;
  while(m!=0){
    int now=0;
    string s[n+1];
    for(int i=1;i<=n;i++){
      cin >> s[i];
    }
    list<int> l;
    for(int i=1;i<=m;i++){
      l.push_back(i);
    }

    for(int i=1;i<=n;i++){
      if((i%3==0)&&(i%5==0)){
        if(s[i]!="FizzBuzz"){
          now++;
          l.pop_front();
        }else{
          l.push_back(l.front());
          l.pop_front();
        }
      }else if(i%3==0){
        if(s[i]!="Fizz"){
          now++;
          l.pop_front();
        }else{
          l.push_back(l.front());
          l.pop_front();
        }
      }else if(i%5==0){
        if(s[i]!="Buzz"){
          now++;
          l.pop_front();
        }else{
          l.push_back(l.front());
          l.pop_front();
        }
      }else{
        stringstream ss;
        string s2;
        ss <<i;
        ss >>s2;
        if(s[i]!=s2){
          now++;
          l.pop_front();
        }else{
          l.push_back(l.front());
          l.pop_front();
        }
      }
      if(now==m-1)break;
    }
    l.sort();
    for(int i=1;i<m-now;i++){
      cout <<l.front()<<" ";
      l.pop_front();
    }
    cout <<l.front()<<endl;
    cin >>m >>n;
  }
  return 0;
}

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

using Graph=vector<vector<int>>;
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    Graph g(n);
    for(int i=0;i<n-1;i++){
        int x,y;
        cin>>x>>y;
        x--,y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    vector<int> st(n,-1);
    function<int(int)> dfs=[&](int v){
        if(st[v]!=-1) return st[v];
        bool win=false;
        for(int to:g[v]){
            if(a[to]<a[v]){
                win=win||(!dfs(to));
            }
        }
        // cerr<<v<<" "<<win<<endl;
        return st[v]=win;
    };
    for(int i=0;i<n;i++) dfs(i);
    vector<int> res;
    for(int i=0;i<n;i++) if(st[i]) res.push_back(i);
    for(int i=0;i<res.size();i++){
        cout<<res[i]+1;
        if(i+1!=res.size()) cout<<" ";
    }
    cout<<endl;
        
    
    return 0;
}

Measured memory_bytes: 512
def my_f(l, lq, q):
  p=0
  for i in range(q):
    if l[lq[i][1]-1]-l[lq[i][0]-1]==lq[i][2]:
      p+=lq[i][3]
  return p
  
n,m,q = (int(x) for x in input().split())

pmax = 0

lq=[]
for i in range(q):
  lq.append(list(map(int, input().split())))
  
l=[0]*10
while l[0] < m:
  l[0]+=1
  l[1]=l[0]-1
  while l[1] < m:
    l[1]+=1
    l[2]=l[1]-1
    while l[2] < m:
      l[2]+=1
      l[3]=l[2]-1
      while l[3] < m:
        l[3]+=1
        l[4]=l[3]-1
        while l[4] < m:
          l[4]+=1
          l[5]=l[4]-1
          while l[5] < m:
            l[5]+=1
            l[6]=l[5]-1
            while l[6] < m:
              l[6]+=1
              l[7]=l[6]-1
              while l[7] < m:
                l[7]+=1
                l[8]=l[7]-1
                while l[8] < m:
                  l[8]+=1
                  l[9]=l[8]-1
                  while l[9] < m:
                    l[9]+=1
                    ptmp = my_f(l, lq, q)
                    if ptmp > pmax:
                      pmax = ptmp

print(pmax)

Measured memory_bytes: 9288
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<string>
#include<map>

using namespace std;

int main(void) {
	int N;
	cin >> N;
	map<string, int>mp;
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		mp[s]++;
	}
	long long ans = 0;
	for (auto p : mp) {
		int s = p.second;
		ans += (long long)s * (s - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<pair<int, int>> v(N);
    int A, B;
    for (int i = 0; i < N; i++) {
        cin >> A >> B;
        v[i] = make_pair(B, A);
    }

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

    long long sum = 0;
    for (int i = 0; i < N; i++) {
        sum += v[i].second;
        if (sum > v[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
typedef vector<vector<ll> > Graph;
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; }
const ll INF = 1e9;

// auto mod int
// depends on Template

const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// combination mod prime
// depends on Template, Modint
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

vector<pair<ll, ll> > prime_factorize(ll N) {
    vector<pair<ll, ll> > res;
    for (ll a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

//input
ll n,m;

int main(){
    cin >> n >> m;
    auto div = prime_factorize(m);
    mint ans = 1;
    combination c(1e7);
    rep(i,div.size()){
        int e = div[i].second;
        ans *= c(e+n-1,n-1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 159524
N = int(input())
T, A = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]
ans = -1
nearest = float('inf')
for k, h in enumerate(H, 1):
    tmp = abs(A - (T - 0.006 * h))
    if tmp < nearest:
        ans = k
        nearest = tmp
print(ans)

Measured memory_bytes: 3064