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

bool check(string s, int x) {
  auto np = string::npos;
  if (s.find("3") == np || s.find("5") == np || s.find("7") == np)
    return false;
  return stoi(s) <= x;
}

const string str = "357";
int f(int x, int d, string acc) {
  int cnt = 0;
  if (d == 0)
    return check(acc, x) ? 1 : 0;
  else
    for (auto c : str)
      cnt += f(x, d - 1, acc + c);
  return cnt;
}

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

  int ans = 0;
  for (int i = 3; i <= 9; i++)
    ans += f(N, i, "");
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
	using namespace std;
	typedef long long int ll;
	#define pb push_back
	#define mp make_pair
	#define sz(a) ll(a.size())
	#define trace(c,x) for(auto &x:c)
	#define F first
	#define S second		
	ll mod = 1e9 + 7;   //change acc to question

ll fastexpo(ll x,ll y)
{
	ll a=1;
	while(y>0)
	{
		if(y&1)a = (a*x)%mod;
		y/=2;
		x=(x*x)%mod;
	}	
	return a;
}

ll dp[103][100005];
ll a[103];
int n;


int main()
{

	ios::sync_with_stdio(false);
	int k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	
	for(int i=0;i<n;i++)
		dp[i][0] = 1;

	for(int i=1;i<=a[0];i++)
		dp[0][i] = 1 ;
	for(int i=1;i<=k;i++)
		dp[0][i]  = (dp[0][i-1]+dp[0][i])%mod ;


	for(int i=1;i<n;i++)
	{
		for(int j=1;j<=k;j++)
		{
			int lim = min(ll(j),a[i]);
			if(lim==j)
				dp[i][j] = dp[i-1][j];
			else
				dp[i][j] = (dp[i-1][j] - dp[i-1][j-lim-1] + mod)%mod;
		}	
		for(int j=1;j<=k;j++)
			dp[i][j] = (dp[i][j] + dp[i][j-1])%mod;	
	}	
	if(k==0)
		cout<<dp[n-1][k]<<endl;
	else
		cout<<(dp[n-1][k]-dp[n-1][k-1]+mod)%mod<<endl;

	return 0;

	}	

Measured memory_bytes: 80128
N = int(input())
h_list = list(map(int, input().split()))
def chmin(a, b):
    if a > b:
        return b
    else:
        return a
import numpy as np
dp_list = [np.inf] * N
dp_list[0] = 0
dp_list[1] = abs(h_list[1] - h_list[0])
for i in range(2, N):
    dp_list[i] = chmin(dp_list[i], dp_list[i-1] + abs(h_list[i-1] - h_list[i]))
    dp_list[i] = chmin(dp_list[i], dp_list[i-2] + abs(h_list[i-2] - h_list[i]))
print(dp_list[-1])

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

const int N = 10010;

typedef long long LL;

int flag[N], prime[N], pcnt;

inline void sieve() {
	for (int i = 2; i <= N - 10; i++) {
		if (!flag[i]) prime[++pcnt] = i;
		for (int j = 1; j <= pcnt && i * prime[j] <= N - 10; j++) {
			flag[i * prime[j]] = 1;
			if (i % prime[j] == 0) break;
		}
	}
}

LL G[510][510];

LL gcd(LL a, LL b) {
	return b ? gcd(b, a % b) : a;
}

inline LL lcm(LL a, LL b) {
	return a / gcd(a, b) * b;
}

template<typename... T>
inline LL lcm(LL a, T... b) {
	LL t = lcm(b...);
	return a / gcd(a, t) * t;
}

int main() {
	int n; scanf("%d", &n), sieve();
	if (n == 2) return puts("4 7\n23 10"), 0;
	for (int i = 0; i <= n + 1; i++)
		for (int j = 0; j <= n + 1; j++) G[i][j] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++) if ((i + j) & 1) {
			int a = i + j, b = i - j; a = (a - 1) / 2, b = (b + n + 1) / 2;
			G[i][j] = (LL)prime[a] * prime[b + n - 1];
		}
	for (int i = 1; i <= n; i++, puts(""))
		for (int j = 1; j <= n; j++) {
			if (!((i + j) & 1)) G[i][j] = (LL)lcm(G[i - 1][j], G[i][j - 1], G[i + 1][j], G[i][j + 1]) + 1;
			printf("%lld ", G[i][j]);
		}
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std;

const ll MOD=998244353;
int n,s,a[3005];
ll f[3005][3005][2][2];

ll dp(int cur,int sum,bool open,bool close){
	if(cur==n) return (sum==s&&close==true)*1LL;
	if(sum>s) return 0;
	ll &res=f[cur][sum][open][close];
	if(~res) return res;
	res=0LL;
	if(close) (res+=dp(cur+1,sum,open,close))%=MOD;
	else if(!open){
		(res+=dp(cur+1,sum,false,false))%=MOD;
		(res+=dp(cur+1,0,true,false))%=MOD;
		(res+=dp(cur+1,a[cur],true,false))%=MOD;
		(res+=dp(cur+1,a[cur],true,true))%=MOD;
	}
	else{
		(res+=dp(cur+1,sum,open,close))%=MOD;
		(res+=dp(cur+1,sum+a[cur],open,close))%=MOD;
		(res+=dp(cur+1,sum,true,true))%=MOD;
		(res+=dp(cur+1,sum+a[cur],true,true))%=MOD;
	}
	return res;
}

int main() {
	#ifdef kvutxdy
	freopen("C:/Users/khanh/OneDrive/RoadtoPurple/Code/Codeforces/input.in", "r", stdin);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cin>>n>>s;
	for(int i=0;i<n;++i) cin>>a[i];
	memset(f,-1,sizeof f);
	cout<<dp(0,0,false,false);
}

Measured memory_bytes: 282752
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
N=ni()
A=na()
A.sort()
dic={}
ans=0
for i in A:
    if(i in dic):
        dic[i]+=1
    else:
        dic[i]=1
for key, value in dic.items():
    if(key==value):
        continue
    elif(key>value):
        ans+=value
    else:
        ans+=value-key


print(ans)

Measured memory_bytes: 17700
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ctoi(x) x-'0'
#define pshb(a) cin >> x;a.push_back(x)
#define fr(i,n) for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false);
using namespace std;
int main()
{
    ll n ; cin>>n ;
    string s ;
    cin>>s ;
    for (int i = 0 ; i< s.size() ; i++)
    {
       ll cnt = n ;
        char t = s[i] ;
        while (cnt--)
        {
            t++ ;
            if (t>'Z')
                t = 'A' ;
        }
        s[i] = t  ;
    }
    cout<<s ;
}




Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x,i=1;
		while(n >= i){
			x = i;
			if(x%3==0){
				System.out.printf(" %d",i);
			}
			else if(x%10==3){
				System.out.printf(" %d",i);
			}
			else{
				while(x != 0){
					x = x/10;
					if(x%10==3){
					System.out.printf(" %d",i);
					break;
					}
				}
			}
			i++;
		}
		System.out.printf("\n");
	}
}

Measured memory_bytes: 31988
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

h, w = inintm()
grid = []
now = [0,0]
fw = 0
fh = 0

for i in range(h):
    grid.append(input())

while now != [h-1,w-1]:
    if now[0] == h-1:
        if fh == 0 and now[1] != 0:
            if grid[h-1][now[1]+1] == "#" and grid[h-1][now[1]-1] == ".":
                now = [h-1, now[1]+1]
                fh = 1
        else:
            if grid[h-1][now[1]+1] == "#":
                now = [h-1, now[1]+1]
                fh = 1
            else:
                print("Impossible")
                exit()
    elif now[1] == w-1:
        if fw == 0 and now[0] != 0:
            if grid[now[0]+1][w-1] == "#" and grid[now[0]-1][w-1] == ".":
                now = [now[0]+1, w-1]
                fw = 1
            else:
                print("Impossible")
                exit()
        else:
            if grid[now[0]+1][w-1] == "#":
                now = [now[0]+1, w-1]
                fw = 1
            else:
                print("Impossible")
                exit()
    else:
        if grid[now[0]+1][now[1]] == "#" and grid[now[0]][now[1]+1] == ".":
            now = [now[0]+1, now[1]]
        elif grid[now[0]+1][now[1]] == "." and grid[now[0]][now[1]+1] == "#":
            now = [now[0], now[1]+1]
        else:
            print("Impossible")
            exit()

if fh == 0 and grid[h-1][w-2] == "#" and (h >= 2 and w >= 2):
    print("Impossible")
    exit()

print("Possible")

Measured memory_bytes: 9300
#include <iostream>
#include <math.h>
#include <string.h>
using namespace std;

int main() {
	int A,B,C ,ans = 0;
	cin >> A >> B >> C;
	if ((A >= C&&C >= B)|| (B >= C&&C >= A))
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
import math

N = int(input())
P = [int(i) for i in input().split()]
Q = [int(i) for i in input().split()]

def f(A):
  l = list(range(1,N+1,1))
  a = 0
  for i in range(N):
    a += math.factorial(N-1-i) * (l.index(A[i])-1)
    del l[l.index(A[i])]
  return a

print(abs(f(P)-f(Q)))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()	
using namespace std;
typedef long long ll;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000000LL;
typedef pair<int,int> P;
int main(){
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<a[2]*10+a[1]+a[0]<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int h,w,a,b=0;
        while(1){
    scanf("%d%d",&h,&w);
        if(h==0&&w==0)break;
    while(h>b){
        while(w>a){
                printf("#");
                a ++;
                    }
        b ++;
        a =0;
        printf("\n");
                }
        b=0;
        printf("\n");
        }

    return 0;
}

Measured memory_bytes: 2584
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"
const ll mod = 1000000007;

typedef tree<pair<ll, int>, null_type, less<pair<ll, int>>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//Ordered set
//pbds s1
 
void testCase() {
    char ch;
    cin >> ch;
    if (ch >= 'A' && ch <= 'Z')
        cout << 'A' << endl;
    else
        cout << 'a' << endl;
}
 
int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}

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

using namespace std;

const long long mod = 1e9 + 7;
long long a[200020];

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)cin >> a[i];
    long long ans = 0;
    for (int i = 2; i <= n; i++) {
        ans = ans + (a[i] * a[i - 1] % mod);
        a[i] += a[i - 1];
        a[i] %= mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5156
a,b,x=gets.split.map(&:to_f)
if a*a*b/2>=x
  puts Math.atan2(b,2*x/b/a)*(180.0/Math::PI)
else
  puts Math.atan2((a*b-x/a)*2/a,a)*(180.0/Math::PI)
end


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

    ll cycA = a1*t1 + a2*t2, cycB = b1*t1 + b2*t2;
    if (cycA == cycB) { cout << "infinity"; return 0; }

    ll gain = cycA - cycB;
    if (gain < 0) {
        gain = -gain;
        swap(a1,b1);
        swap(a2,b2);
        swap(cycA,cycB);
    }

    //cout << a1 << " " << a2 << " " << gain << endl;
    ll ans = 0;
    if (a1 < b1) {
        ll maxX = t1 * (b1-a1);
        ans += maxX / gain;
    }
    if (a2 < b2) {
        ll maxX = t2 * (b2-a2) - (a1*t1 - b1*t1);
        if (maxX >= 0) ans += maxX / gain + 1;
    } else {
        ll maxX = -a1*t1 + b1*t1 - 1;
        if (maxX >= 0) ans += maxX / gain + 1;
    }
    cout << ans;
}



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

typedef long long ll;

const ll MOD = (ll) 1e9 + 7;

const int MAXN = (int) 1e5 + 5;
ll fact[MAXN];
void f() {
    fact[0] = 1;
    for (int i = 1; i < MAXN; ++i) {
        fact[i] = fact[i-1] * i;
        fact[i] %= MOD;
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int N, M; cin >> N >> M;
    if (abs(N - M) > 1) {
        cout << 0 << endl;
        return 0;
    }
    f();
    if (abs(N-M) == 1) {
        cout << (fact[N] * fact[M])%MOD << endl;
        return 0;
    }
    else {
        cout << 2* (fact[N] * fact[M])%MOD << endl;
        return 0;
    }
}


Measured memory_bytes: 4392
import java.io.*;
import java.math.BigInteger;
import java.util.*;


public class  Main{
    public static void main(String[] args) throws Exception{
    	MScanner sc = new MScanner(System.in);
        //MScanner sc = new MScanner("reduce.in");
        PrintWriter pw=new PrintWriter(System.out);
        int n=sc.nextInt();
        long[]in=new long[n];
        boolean pos=true;
        long sum=0;
        for(int i=0;i<n;i++) {
        	in[i]=2*sc.nextLong();
        	if(pos) {
        		sum+=in[i];
        	}
        	else {
        		sum-=in[i];
        	}
        	pos=!pos;
        }
        long[]ans=new long[n];
        ans[0]=sum/2;
        ans[n-1]=in[n-1]-ans[0];
        for(int i=1;i<n-1;i++) {
        	ans[i]=in[i-1]-ans[i-1];
        }
        pw.println(tosb(ans));
        pw.flush();
    }
    static StringBuilder tosb(int[]in) {
    	StringBuilder s=new StringBuilder();
    	for(int i=0;i<in.length;i++) {
    		s.append(in[i]+" ");
    	}
    	return s;
    }
    static StringBuilder tosb(long[]in) {
    	StringBuilder s=new StringBuilder();
    	for(int i=0;i<in.length;i++) {
    		s.append(in[i]+" ");
    	}
    	return s;
    }
    
    static class MScanner {
		StringTokenizer st;
		BufferedReader br;
 
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 48508
_gcd = function(m, n, t) {
	while (m % n !== 0) {
		t = n;
		n = m % n;
		m = t;
	}
	return n;
}

input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
N = lines.shift() * 1
line = lines.shift().split(' ')
gcd = line[0]
for (i=1; i<N; i++) {
    gcd = _gcd(gcd, line[i])
}
console.log(gcd)

Measured memory_bytes: 19532
#define _GOOD_LUCK_MCLAREN_MCL32_
#define _GOOD_LUCK_FERNANDO_ALONSO_

#include <cstdio>
#include <cstring>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
using namespace std;

const int MAX_N = (int)1e5 + 5;
struct edge {
    int u, v, w;
    edge() {}
    edge(const int &u, const int &v, const int &w) : u(u), v(v), w(w) {}
    bool operator < (const edge& e) const {
        return w < e.w;
    }
};

int xy[MAX_N][2], order[2][MAX_N], root[MAX_N];
vector<edge> g;

bool comp0(const int& i, const int& j) {
    return xy[i][0] < xy[j][0];
}

bool comp1(const int& i, const int& j) {
    return xy[i][1] < xy[j][1];
}

inline int dis(int i, int j) {
    return min(abs(xy[i][0] - xy[j][0]), abs(xy[i][1] - xy[j][1]));
}

inline int find(const int &x) {
    return (root[x] == x ? x : root[x] = find(root[x]));
}

inline bool Union(int i, int j) {
    i = find(i);
    j = find(j);
    if (i == j) return false;
    root[j] = i;
    return true;
}

int main() {
    int N, res = 0, cnt = 1;
    scanf("%d", &N);
    for (int i = 0; i < N; i++)
        for (int j = 0; j < 2; j++)
            scanf("%d", &xy[i][j]);
    
    for (int i = 0; i < N; i++) root[i] = order[0][i] = order[1][i] = i;
    sort(order[0], order[0] + N, comp0);
    sort(order[1], order[1] + N, comp1);
    for (int i = 0; i < 2; i++)
        for (int j = 0; j < N - 1; j++)
            g.push_back(edge(order[i][j], order[i][j + 1],
                         dis(order[i][j], order[i][j + 1])));
    sort(g.begin(), g.end());
    
    for (vector<edge>::iterator it = g.begin(); it != g.end() && cnt < N; it++)
        if (Union(it->u, it->v)) {
            cnt++;
            res += it->w;
        }
    
    return printf("%d", res), 0;;
}


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

enum Result {Left, Right, None};

struct Magic {
    char t, d;
};

Result move(string s, vector<Magic> magics, int index) {
    for (auto m: magics) {
        if (s[index] == m.t) {
            if (m.d == 'L') {
                index--;
                if (index == -1)
                    return Left;
            } else {
                index++;
                if (index == s.size())
                    return Right;
            }
        }
    }
    return None;
}

int main() {
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;

    vector<Magic> magics(q);
    for (int i = 0; i < q; i++) {
        char t, d;
        cin >> t >> d;
        magics[i] = Magic {t, d};
    }

    int l = -1, r = n;

    int lb = -1, ub = n;
    while (ub - lb > 1) {
        int mid = (lb + ub) / 2;
        if (move(s, magics, mid) == Left) {
            l = mid;
            lb = mid;
        } else {
            ub = mid;
        }
    }

    lb = -1, ub = n;
    while (ub - lb > 1) {
        int mid = (lb + ub) / 2;
        if (move(s, magics, mid) == Right) {
            r = mid;
            ub = mid;
        } else {
            lb = mid;
        }
    }
    cout << max(0, r - 1 - l) << endl;
    return 0;
}


Measured memory_bytes: 1540
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int INF = (1<<30);
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
    int H,W,N;
    cin >> H >> W;
    cin >> N;
    int a[N];
    rep(i, N) cin >> a[i];
    vector<int> b;
    rep(i, N){
        rep(j, a[i]) b.push_back(i+1);
    }
    rep(i, H){
        if (i%2==0){
            rep(j, W){
                cout << b[i*W+j] << " ";
            }
        } else {
            for(int j=W-1; j>=0; j--) cout << b[i*W+j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int x,a,b;
int main()
{
    scanf("%d%d%d",&x,&a,&b);
    if(abs(x-a) > abs(x-b))
        printf("B\n");
    else
        printf("A\n");
    return 0;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var S string
  fmt.Scan(&S)

  var w, b int
  for i, s := range S {
    if s == '0' {
      if i % 2 == 0 {
        w++
      } else {
        b++
      }
    } else {
      if i % 2 == 0 {
        b++
      } else {
        w++
      }
    }
  }
  if w > b {
    fmt.Println(b)
  } else {
    fmt.Println(w)
  }
}

Measured memory_bytes: 1280
#include <stdio.h>

int main() {
	long int N, A, B, C, D, ans;
	double c;

	scanf("%ld %ld %ld", &N, &A, &B);
	c = N / (A + B);
	C = c;//繰り返し回数
	D = N % (A + B);//余り
	
	if (D >= A) {
		ans = A * C + A;
	}
	else {
		ans = A * C + D;
	}

	printf("%ld", ans);

	return 0;
}

Measured memory_bytes: 128
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target ("avx")
#define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<setprecision(10)
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

// K*(K-1) = 2N

// K = 2, N = 1
// K = 3, N = 3
// K = 4, N = 6
// K = 5, N = 10

// 1 2
// 1   3
//   2 3

// 1 2 3
// 1     4 5
//   2   4   6
//     3   5 6

// 1 2 3 4
// 1       5 6 7
//   2     5     8 9
//     3     6   8   10
//       4     7   9 10

// 1 2 3 4 5
// 1         6 7 8 9
//   2       6       10 11 12
//     3       7     10       13 14
//       4       8      11    13    15
//         5       9       12    14 15

int main() {
	int N, K = -1;
	cin >> N;
	for (int i = 2; i < 1000; i++) {
		if (i * (i - 1) == N * 2) {
			K = i;
			break;
		}
	}
	if (K == -1) {
		cout << "No" << endl;
		return 0;
	}
	else {
		cout << "Yes" << endl << K << endl;
		vector<vector<int>> S(K);
		for (int i = K-1, j = 1; i >= 1; i--) {
			for (int k = 0; k < i; k++, j++) {
				S[K - i - 1].push_back(j);
				//cout << K - i - 1 << " " << j << endl;
			}
		}
		for (int i = K - 1, j = 1; i >= 1; i--) {
			for (int k = 0; k < i; k++, j++) {
				//cout << i << " " << j << " " << k << endl;
				//cout << K - i + k << " " << j << endl;
				S[K - i + k].push_back(j);
			}
		}
		for (int i = 0; i < K; i++) {
			cout << S[i].size() << " ";
			for (int j = 0; j < S[i].size(); j++) {
				cout << S[i][j] << " ";
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 4176
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() {
	int n,a,b;
    cin>>n>>a>>b;

    if(n*a>=b){
        cout<<b<<endl;
    }else{
        cout<<a*n<<endl;
    }

}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
long chmin(long A, long B){
	if(A>B)return B;
	else return A;
	return -1;
}
int main(){
	long i,j,k;
	double N,max,a,b,x,S,l_b,theta;
	scanf("%lf%lf%lf",&a,&b,&x);

	S = x/a;
	l_b = S/a;
	
	if(l_b >= b/2){ // 45deg�ȏ�
		
		theta = atan2((b-l_b)*2,a);
		
	}
	else { //45deg�ȉ�
		
		theta = M_PI/2 - atan2(2*S/b ,b);
	}
	
	printf("%lf\n",theta*180/M_PI);
	
  return 0;

}


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

int count[4][3][10] = {{{}}};

int main(){
  int b, f, r, v, n;
  cin >> n;
  for( int i =0; i < n; i++){
    cin >> b >> f >> r >> v;
    count[b-1][f-1][r-1] += v;
  }
  for( b=0; b < 4; b++){
    for( f=0; f < 3; f++){
      for( r=0; r < 10; r++){
        cout << " ";
        cout << count[b][f][r];
      }
      cout << endl;
    }
    if(b < 3){
      for(int i=0; i< 20; i++) cout <<"#";
      cout << endl;
    }
  }
}


Measured memory_bytes: 3092
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int n, k;
	cin >> n >> k;
	int ch[n+1] = {};
	REP(i, k){
		int a, b;
		cin >> a >> b;
		ch[a]++; 
		ch[b]++;
	}
	bool an = true;
	REP1(i,n) if(ch[i]%2 == 1) an = false;
	if (an) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	//cout << ans << endl;
}

Measured memory_bytes: 640
//GRL_4B
#include <iostream>
#include<algorithm>
#include <vector>
#include <queue>
#include <list>
using namespace std;
 
static const int MAX=100000;
static const int INF=(1<<29);
vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;
int indeg[MAX];

void bfs(int s){
 queue<int> q;
 q.push(s);
 V[s]=true;
 while(!q.empty()){
  int u=q.front(); q.pop();
  out.push_back(u);
  for(int i=0;i<G[u].size();i++){
   int v=G[u][i];
   indeg[v]--;
   if(indeg[v]==0 && !V[v]){
    V[v]=true;
    q.push(v);
   }
  }
 }
}

void tsort(){
 for(int i=0;i<N;i++) indeg[i]=0;
 for(int u=0;u<N;u++){
  for(int i=0;i<G[u].size();i++){
   int v=G[u][i];
   indeg[v]++;
  }
 }
 for(int u=0;u<N;u++)
  if(indeg[u]==0 && !V[u]) bfs(u);
 for(list<int>::iterator it=out.begin();it!=out.end();it++){
  cout<<*it<<endl;
 }
}

int main(){
 int s,t,M;
 cin>>N>>M;
 for(int i=0;i<N;i++) V[i]=false;
 for(int i=0;i<M;i++){
  cin>>s>>t;
  G[s].push_back(t);
 }
 tsort();
 return 0;
}

Measured memory_bytes: 4328
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#define int long long
using namespace std;

#define fin(i,n) for (int i = 0; i < n; i++)
#define fin2(i,a,b) for (int i = a; i < b; i++)
#define ford(i,n) for (int i = n-1; i >= 0; i--)
#define ford2(i,a,b) for (int i = a-1; i >= b; i--)
 
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define MOD 1000000007
#define PI 3.1415926535897932384626
#define EXP1 2.718281828459045
#define BIG 1000000000000000000

#define sl(n) scanf("%lld", &n)
#define sll(n,m) scanf("%lld %lld", &n, &m)
#define slll(n,m,k) scanf("%lld %lld %lld", &n, &m, &k)
#define sllll(n,m,k,o) scanf("%lld %lld %lld %lld", &n, &m, &k, &o)
#define sd(n) scanf("%lf", &n)
#define sdd(n,m) scanf("%lf %lf", &n, &m)
#define sddd(n,m,k) scanf("%lf %lf %lf", &n, &m, &k)
#define sc(c) scanf(" %c", &c)
#define ss(s) scanf("%s", s)
#define sal(t,n) fin(iz,n) { scanf("%lld", &t[iz]); }
#define sad(t,n) fin(iz,n) { scanf("%lf", &t[iz]); }
#define gl(t) scanf(" %[^\n]", t);

#define pc(n) printf("%c\n", n)
#define ps(s) printf("%s\n", s)
#define pss(s) printf("%s\n", s.c_str())
#define pl(n) printf("%lld\n", n)
#define pll(n,m) printf("%lld %lld\n", n, m)
#define plll(n,m,k) printf("%lld %lld %lld\n", n, m, k)
#define pd(n) printf("%lf\n", n)
#define pdd(n,m) printf("%lf %lf\n", n, m)
#define pal(t,n) fin(rz,n) { printf("%lld ", t[rz]); } printf("\n")
#define pad(t,n) fin(rz,n) { printf("%lf ", t[rz]); } printf("\n")

#define chmin(x, v) x = min(x, v)
#define chmax(x, v) x = max(x, v)
 
#define OK ps("OK")
#define OK1 ps("OK1")
#define OK2 ps("OK2")

#define ll int
#define vl vector<ll>
#define vvl vector<vl>
#define vvvl vector<vvl>

#define dll pair<ll, ll>
#define vdll vector<dll>
#define vvdll vector<vdll>

#define vb vector<bool>
#define vvb vector<vb>
#define vd vector<double>
#define vvd vector<vd>
#define vc vector<char>
#define vvc vector<vc>

#define all(v) v.begin(), v.end()
#define vlen(v) (int)(v.size())
#define pb push_back
#define fi first
#define se second

int dp[1005][1005];
bool bloque[1005][1005];
int a, b;

int gdp(int lig, int col)
{
    if (bloque[lig][col] || lig >= a || col >= b) return 0;
    if (dp[lig][col] == -1) dp[lig][col] = (gdp(lig+1, col) + gdp(lig, col+1)) % MOD;
    return dp[lig][col];
}

signed main()
{
    sll(a, b);
    fin(lig, a) fin(col, b) { char c; sc(c); bloque[lig][col] = (c == '#'); }
    fill_n(&dp[0][0], 1005*1005, -1);
    dp[a-1][b-1] = 1;
    pl(gdp(0, 0));
}

Measured memory_bytes: 9216
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>
//#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long int;
//// 任意長整数型
//namespace mp = boost::multiprecision;
//using Bint = mp::cpp_int;



int main(int argc, char *argv[])
{
	//input
	//int n, a, b;
	//cin >> n >> a >> b;
	int a[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int k;
	cin >> k;

	//calc


	//ans
	int ans = a[k - 1];
	cout << ans << endl;


	return 0;
}


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

int main(){
    int n;
    cin>>n;
    map<int,int> m;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        m[a]++;
    }

    int ans=0;
    for(auto p : m){
        if(p.first<=p.second) ans+=p.second-p.first;
        else ans+=p.second;
    }
    cout<<ans<<endl;
}

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

int main()
{
  
  int i,j;
  scanf("%d %d",&i,&j);
  
  if(i>9 || j>9){
    printf("-1\n");
  }
  else{
    printf("%d\n",i*j);
  }
  
  
  return 0; 
}

Measured memory_bytes: 256
#coding:utf-8
from collections import defaultdict

N, M = list(map(int, input().split()))


result = defaultdict(list)

for i in range(N):
    data = list(map(int, input().split()))
    K = data[0]
    data = data[1:]
    data = [d-1 for d in data]
    result[i]=data


count = 0
for food in range(M):
    break_flag = False
    for i in range(N):
        if not food in result[i]:
            break_flag = True
            break
    else:
        count+=1

print(count)
        


Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

template<typename T>
map<T, bool> div_count(T x) {
  map<T, bool> st;
  for (long long i = 1; i * i <= x; ++i) {
    if (x % i == 0) {
      st[i] = true;
      st[x/i] = true;
    }
  }
  return st;
}

// 最大公約数を求める(ユークリッドの互除法).
long long gcd (long long x, long long y) {
  if (y > x) swap(x,y);
  if (y == 0) return x;
  return gcd(x%y,y);
}
#include <math.h> 

bool IsPrime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}


int main() {
    ll a,b;
    cin >> a >> b;

    // vector<bool> primes = SievePrimes(max(a, b));

    auto sa = div_count(a);

    vector<ll> st;
    for (auto itr : sa) {
        if (b % itr.first == 0) {
            st.push_back(itr.first);
        }
    }

    ll ans = 0;

    for (ll i = 0; i < st.size(); ++i) {
        if (IsPrime(st[i])) ans += 1;
    }

    cout << ans + 1 << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
int main()
{
    int N;
    string S;
    cin >> N >> S;

    int ans = 0;
    
    repd(i, 1, N) {
        if (S[i] != S[i - 1]) ans++;
    }

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

Measured memory_bytes: 512
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] v = new int[n];
        for (int i = 0; i < n; i++) {
            v[i] = sc.nextInt();
        }
        Map<Integer, Integer> map1 = new HashMap<>();
        Map<Integer, Integer> map2 = new HashMap<>();
        for (int i = 0; i < n; i += 2) {
            int value1 = 1;
            int value2 = 1;
            if (map1.containsKey(v[i])) {
                value1 += map1.get(v[i]);
            }
            if (map2.containsKey(v[i + 1])) {
                value2 += map2.get(v[i + 1]);
            }
            map1.put(v[i], value1);
            map2.put(v[i + 1], value2);
        }
        int max1 = 0;
        int max_key1 = -1;
        for (int key : map1.keySet()) {
            max1 = Math.max(max1, map1.get(key));
            if (max1 == map1.get(key)) {
                max_key1 = key;
            }
        }
        int next_max1 = 0;
        int next_max_key1 = -1;
        for (int key : map1.keySet()) {
            if (key != max_key1) {
                next_max1 = Math.max(next_max1, map1.get(key));
                if (next_max1 == map1.get(key)) {
                    next_max_key1 = key;
                }
            }
        }

        int max2 = 0;
        int max_key2 = -1;
        for (int key : map2.keySet()) {
            max2 = Math.max(max2, map2.get(key));
            if (max2 == map2.get(key)) {
                max_key2 = key;
            }
        }
        int next_max2 = 0;
        int next_max_key2 = -1;
        for (int key : map2.keySet()) {
            if (key != max_key2) {
                next_max2 = Math.max(next_max2, map2.get(key));
                if (next_max2 == map2.get(key)) {
                    next_max_key2 = key;
                }
            }
        }

        int res = n - max1 - max2;
        if (max_key1 == max_key2) {
            res = Math.min(n - max1 - next_max2, n - max2 - next_max1);
        }
        System.out.println(res);
        sc.close();
    }
}

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

int dp[4001][4001];

int main(){
	char str1[4001],str2[4001];
	while(cin>>str1>>str2){
		int ans=0;
		memset(dp,0,sizeof(dp));
		for(int i=0;str1[i]!='\0';i++){
			for(int j=0;str2[j]!='\0';j++){
				if(str1[i]==str2[j]){
					dp[i+1][j+1]=dp[i][j]+1;
				}
				if(ans<dp[i+1][j+1]){
					ans=dp[i+1][j+1];
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 63672
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


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

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> from_to(N - 1 + M);
    vector<int> not_root(N);
    vector<set<int>> children(N);
    vector<set<int>> from(N); // 自分をさしてるノード
    REP(i, N - 1 + M) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        from_to[i] = mp(a, b);
        not_root[b] = 1;
        children[a].insert(b);
        from[b].insert(a);
    }
    int root = -1;
    REP(n, N) {
        if (!not_root[n]) {
            root = n;
            break;
        }
    }

    vector<int> parent(N);
    parent[root] = -1;
    set<int> seen;
    set<int> queue({ root });
    while (!queue.empty()) {
        set<int> next_queue;
        for (auto v : queue) {
            for (auto child : children[v]) {
                from[child].erase(v);
                if (SIZE(from[child]) == 0) {
                    parent[child] = v;
                    next_queue.insert(child);
                }
            }
        }
        queue = next_queue;
    }


    for (auto p : parent) {
        cout << (p + 1) << endl;
    }

    return 0;
}


Measured memory_bytes: 25856
#ifdef DEBUG
#include "../utils.cpp"
#endif
#include <bits/stdc++.h>
/*
Problem


Category
DP
 
URL:


考察:



Date: 2020/06/01
*/
 

using namespace std;
using ll = int64_t;
#define int int64_t
#define INF 10e9

 
/* ==== declarations ====== */
// functions
void solve();
void getInput();
 
// global variables
int N, M;
vector<int> C;
vector<int> X;
vector<vector<int>> dp;

//2254
/* ======================== */


void getInput() {
    cin>>N>>M;
    C=vector<int>(M, 0);
    X=vector<int>(N+1, 0);
    dp  =vector<vector<int>>(N+1, vector<int>(256, INF));
    for(int i=0; i<M; ++i) {
        cin>>C[i];
    }
    for(int i=0; i<N; ++i) {
        cin>>X[i];
    }
}
 

void solve() {
    // print(C, X);
    // print(dp);
    dp[0][128]=0;

    for(int i=0; i<N; ++i) {
        for(int j=0; j<256; ++j) {
            if (dp[i][j] == INF) continue;

            for(int k=0; k<M; ++k) {
                int nextValue = j + C[k];
                nextValue = nextValue < 0 ? 0 : nextValue;
                nextValue = nextValue > 255 ? 255 : nextValue;
                int loss = pow(X[i] - nextValue, 2);
                // print("loss of ", nextValue, "is", loss, X[i]);
                dp[i+1][nextValue] = min(dp[i+1][nextValue], dp[i][j] + loss);
            }
        }
    }
    // print(dp);
    int ans = INF;
    for(auto a: dp[N]) {
        ans = min(ans, a);
    }
    // print(dp);
    cout<<ans<<endl;
}
 
 
signed main(){
    while(true){
        getInput();
        if (N==0 and M==0) break;
        solve();
    }
    return 0;
}




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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	
	sort(a.begin(), a.end());
	cout << a[0] << " " << a[n-1] << " " << sum << endl;
	return 0;
}


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

int main()
{
 
  ll n,i;
  string s1,s2;
  cin>>s1;
  cin>>s2;
  ll ans=0;
  for(i=0; i<s1.length(); i++)
  {
    if(s1[i]!=s2[i])
      ans++;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3916
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        ArrayList<ArrayList<Integer>> edge = new ArrayList<ArrayList<Integer>>();
        for (int i=0;i<N;i++) {
            ArrayList<Integer> add = new ArrayList<Integer>();
            edge.add(add);
        }
        for (int i=0;i<M;i++) {
            int A = sc.nextInt()-1;
            int B = sc.nextInt()-1;
            edge.get(A).add(B);
            edge.get(B).add(A);
        }

        int[] nums = new int[N];
        boolean[] visited = new boolean[N];
        ArrayDeque<int[]> q = new ArrayDeque<int[]>();
        int[] first = {0, -1};
        q.add(first);
        while (!q.isEmpty()) {
            int[] rem = q.poll();
            if (visited[rem[0]]) continue;
            visited[rem[0]] = true;
            nums[rem[0]] = rem[1];

            for (int i : edge.get(rem[0])) {
                if (!visited[i]) {
                    int[] add = {i, rem[0]};
                    q.add(add);
                }
            }
        }
        System.out.println("Yes");
        for (int i=1;i<N;i++) {
            System.out.println(nums[i]+1);
        }
    }
}

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

using namespace std;

#define ll long long
#define fix cout << fixed; cout << setprecision(10)




	
void solve() {

	int n;
	cin >> n;
	string a, b, c;
	cin >> a >> b >> c;
	int cnt = 0;
	for(int i = 0; i < n; i++) {
		if(a[i] == b[i] && b[i] == c[i]) {
		}
		else {
			if(a[i] == b[i] || b[i] == c[i] || a[i] == c[i]) {
				cnt++;
			}
			else {
				cnt += 2;
			}
		}
	}
	cout << cnt << "\n";
	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	
	solve();

	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int d = scanner.nextInt(), g = scanner.nextInt();
			Score[] s = new Score[d];
			IntStream.range(0, d).forEach(i -> s[i] = new Score((i + 1) * 100, scanner.nextInt(), scanner.nextInt()));
			Arrays.sort(s);
			System.out.println(IntStream.range(1, 1 << d).map(i -> getProblemNo(i, s, g)).min().getAsInt());
		}
	}

	/**
	 * 目標スコアが達成させるための解く問題数を計算する
	 * 
	 * @param mask 使用する問題の2進数表現
	 * @param s    問題数とスコア数の配列
	 * @param g    目標スコア
	 * @return 目標スコアが達成させるための解く問題数
	 */
	private static int getProblemNo(int mask, Score[] s, int g) {
		int result = 0;
		for (int i = 0; i < s.length; i++) {
			if ((mask & (1 << i)) > 0) {
				if (g > s[i].max) {
					result += s[i].count;
					g -= s[i].max;
				} else {
					int index = Arrays.binarySearch(s[i].scores, g);
					if (index < 0) {
						index = ~index;
					}
					result += index + 1;
					return result;
				}
			}
		}
		// 達成できない場合
		return Integer.MAX_VALUE;
	}

	/**
	 * 問題数とスコアを表すクラス
	 */
	private static class Score implements Comparable<Score> {
		/** 問題数 */
		int count;
		/** スコアの配列 */
		int[] scores;
		/** 完成したときのスコア数 */
		int max;

		/**
		 * コンストラクタ
		 * 
		 * @param n 1問あたりのスコア
		 * @param p 問題数
		 * @param c ボーナススコア
		 */
		Score(int n, int p, int c) {
			scores = new int[count = p];
			IntStream.range(0, p - 1).forEach(i -> scores[i] = (i + 1) * n);
			scores[p - 1] = max = p * n + c;
		}

		@Override
		public int compareTo(Score score) {
			// 問題を完了させたときのスコア数/問題数 で降順でソート
			return Double.compare(((double) score.max) / score.count, ((double) this.max) / this.count);
		}
	}
}


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

typedef long long LL;

const int N = 101;

int a[N][N];

int main()
{
    unordered_map<string,int> m;
    int n;
    cin >> n;
    while(n--)
    {
        string s;
        cin >> s;
        m[s] ++;
    }
    cout << "AC x "<<m["AC"]<<endl;
    cout << "WA x "<<m["WA"]<<endl;
    cout << "TLE x "<<m["TLE"]<<endl;
    cout << "RE x "<<m["RE"]<<endl;

}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define int           long long
#define pb            push_back
#define ppb           pop_back
#define si            set <int>
#define endl          '\n'
#define fr            first
#define sc            second     
#define rep(i,a,b)    for(int  i=a;i<b;i++)
#define repr(i,a,b)      for(int i=b-1;i>=a;i--)
#define trav(it,v)      for(auto it=v.begin();it!=v.end();it++)
#define all(v)        v.begin(),v.end()
#define srt(v)        sort(all(v))
#define vs            vector<string>
#define sz(x)         (int )x.size()
#define M             1000000007
#define bs            binary_search
#define sp(n)         setprecision(n)
#define spl           " "
#define arr(a,n)      rep(i,0,n) cin>>a[i]
#define mod           998244353
#define MAXN          1000000000000000000

using namespace std;

bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 


//int dx[4]={0,0,1,-1};
//int dy[4]={1,-1,0,0};
// vector<int>adj[100001];
// int vis[100001]={0};
// vector<int>v1;

void solve()
{
    int n;
    cin>>n;
    int ans=0;
    rep(i,1,n+1)
    {
        rep(j,1,n+1)
        {
            rep(k,1,n+1)
            {
                int gcd=__gcd(i,j);
                int gcd1=__gcd(gcd,k);
                ans+=gcd1;
            }
        }
    }
    cout<<ans;

}   
    


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 3652
#include<cstdio>
#include<algorithm>
#define N 100000
#define MAX (1<<31)-1
using namespace std;
int A[N], T[4*N], lazy[4*N];

void build(int l, int r, int k) {
    if (l == r) {
        T[k] = A[l];
        return;
    }
    int mid = (l + r) / 2;
    build(l, mid, k * 2);
    build(mid + 1, r, k * 2 + 1);
    T[k] = min(T[2 * k], T[2 * k + 1]);
}
void pushdown(int k) {
    if (lazy[k] != -1) {
        lazy[2*k] = lazy[k];
        lazy[2*k+1] = lazy[k];
        T[2*k] =  lazy[k];
        T[2*k+1] = lazy[k];
        lazy[k] = -1;
    }
}
void updata(int L, int R, int data ,int l, int r ,int k) {
    if (L <= l && r <= R) {
        T[k] = data;
        lazy[k] = data;
        return;
    }
    pushdown(k);
    int mid = (l + r) / 2;
    if (mid >= L) updata(L, R, data, l, mid, 2*k);
    if (mid < R) updata(L, R, data, mid+1, r, 2*k+1);
    T[k] = min(T[2 * k], T[2 * k + 1]);
}
int find(int L, int R, int l, int r, int k) {
    if (L <= l && r <= R) return T[k];
    pushdown(k);
    int mid = (l + r) / 2;
    int ans = MAX;
    if (mid >= L) ans = min(ans, find(L, R, l, mid, k * 2));
    if (mid < R) ans = min(ans, find(L, R, mid + 1, r, k * 2 + 1));
    return ans;
}
int main() {
    int n, q;
    scanf("%d%d", &n, &q);
    for (int i = 0; i < n; i++)
        A[i] = MAX;
    for (int i = 0; i < 4*n; i++)
        lazy[i] = -1;
    build(0, n - 1, 1);
    int com, s, t, x, y;
    while (q--) {
        scanf("%d", &com);
        if (com == 0) {
            scanf("%d%d%d", &s, &t, &x);
            updata(s, t, x, 0, n - 1, 1);
        }
        else {
            scanf("%d", &x);
            printf("%d\n", find(x, x, 0, n - 1, 1));
        }
    }
    return 0;
}


Measured memory_bytes: 5728
stdin = input()

days = {
	"SUN": 0,
	"MON": 1,
	"TUE": 2,
	"WED": 3,
	"THU": 4,
	"FRI": 5,
	"SAT": 6,
}

num_of_today = days[stdin]
days_until_next_sun = 7 - num_of_today

print(str(days_until_next_sun))

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    int a[n], b[m];
    int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(i)
            a[i] += a[i-1];
        if(a[i] <= k){
            ans = i + 1;
        }
        // cout << a[i] << ' ';
    }

    for(int i = 0; i < m; i++){
        cin >> b[i];
        if(i)
            b[i] += b[i-1];
        // cout << k - b[i] << ' ';
        // cout << (upper_bound(a, a + n, k - b[i]) - a) << '\n';
        if(b[i] <= k){
            ans = max(ans, i + 1 + (upper_bound(a, a + n, k - b[i]) - a));
        }
    }
    cout << ans << '\n';
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N, T;
    cin >> N >> T;
    vec t(N);
    REP(i,0,N) cin >> t[i];

    ll sum = t[N-1] + T;
    REP(i,0,N-1) {
        if(t[i+1] >= t[i] + T) sum -= t[i+1] - t[i] - T;
    }
    PR(sum);

    return 0;
}

/*



*/

Measured memory_bytes: 4756
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		sc.close();
		char res=s.charAt(0);
		switch(res){
			case 'A':
				System.out.println("T");
				break;
			case 'T':
				System.out.println("A");
				break;
			case 'C':
				System.out.println("G");
				break;
			case 'G':
				System.out.println("C");
				break;
		}
	}
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N;cin>>N;
    vint A(3*N);
    rep(i,3*N)cin>>A[i];
sort(all(A));
    int sum=0;
    for(int i=0;i<N;i++)sum+=A[3*N-2*(i+1)];
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 2560