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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define ll long long
#define REP(i,a,b) for (int i=a; i<b; i++)

using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pi;

signed main() {
  IOS;
  int N,K;
  string S;
  cin >> N >> K >> S;
  REP(i, 0, N) {
    cout << (i == K-1 ? (char)('a'+S[i]-'A') : S[i]);
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	ll n, a, b;
	cin >> n >> a >> b;
	
	if( a > b ) {
		cout << 0 << endl;
	} else {
		if( n == 1 ) {
			if( a != b ) cout << 0 << endl;
			else cout << 1 << endl;
		}
		
		else cout << (b - a) * (n - 2LL) + 1LL << endl;
	}
	
	return 0;
}


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

int main(){
    int N; cin >> N;
    int A[100];
    for(int i=0; i<N; i++ ){
        cin >> A[i];
    }
    int mmin=2002002002;
    int mmax=0;
    for(int i=0; i<N; i++){
        mmax = max( mmax, A[i]);
        mmin = min( mmin, A[i]);
    }
    cout << mmax -mmin << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int n,ans;char lst,ths;
main()
{
	scanf("%d",&n);
	for(;n--;lst=ths)
	{
		for(;ths=getchar(),ths<'a'||'z'<ths;);
		if(lst!=ths)++ans;
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
string a,b;
int main(){
	cin>>a>>b;
	bool f = 1;
	for(int i = 0;i < a.size();i++){
		if(a[i] != b[i]) {f = 0;break;}
	}
	if(f) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,n,v[50],c[50],sum=0,d;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&v[i]);
    }
        for(i=0;i<n;i++)
    {
        scanf("%d",&c[i]);
    }
        for(i=0;i<n;i++)
    {
        if(v[i]>c[i])
          {
        d=v[i]-c[i];
        sum=sum+d;
          }
    }
    printf("%d",sum);
    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //
void solve(){
	
	int n = read.to!int;
	
	bool[int] xset, yset;
	S[] ps;
	foreach(i; 0 .. n){
		int x = read.to!int - 1;
		if(x !in xset) xset[x] = 1;
		
		int y = read.to!int - 1;
		if(y !in yset) yset[y] = 1;
		
		ps ~= S(x, y);
	}
	
	int[] xs = xset.keys, ys = yset.keys;
	Node[int] xnodes, ynodes;
	
	Node[] nodes;
	foreach(x; xs){
		Node nd = new Node(nodes.length, 1);
		nodes ~= nd;
		xnodes[x] = nd;
	}
	foreach(y; ys){
		Node nd = new Node(nodes.length, 2);
		nodes ~= nd;
		ynodes[y] = nd;
	}
	
	
	Edge[] edges;
	foreach(p; ps){
		edges ~= new Edge(xnodes[p.x], ynodes[p.y], 0);
	}
	
	foreach(ed; edges){
		if(ed.node1.group.id != ed.node2.group.id){
			ed.node1.group.eat(ed.node2.group);
		}
	}
	log("edges:", edges);
	
	long ans;
	foreach(nd; nodes){
		if(nd.group.id != nd.id) continue;
		long xc, yc;
		foreach(k; nd.group.nodes){
			if(k.value == 1) xc += 1; else yc += 1;
		}
		ans += xc * yc;
	}
	
	ans -= n;
	
	ans.writeln;
	
}
/*
縦座標の集合と、横座標の集合で２部グラフとみる
連結成分分解みたいなことをする

元カノの元カレから性病がうつるっていうやつ
連結成分が完全２部グラフになる

元々つながっていた数をひいたら答え
*/

struct S{
	int x, y;
}

// Union-find ※多分使いやすいやつ
class Edge{
	Node node1;
	Node node2;
	long value;
	this(Node node1, Node node2, long value){
		this.node1 = node1, this.node2 = node2;
		this.value = value;
	}
	override string toString(){
		return [node1.id, node2.id, value].to!string;
	}
}

class Node{
	long id;
	long value;
	Group group;
	this(long id, long value){
		this.id = id;
		this.value = value;
		this.group = new Group(this);
	}
	override string toString(){
		return [id, group.id, value].to!string;
	}
}

class Group{
	long value;
	long pendingEdgeCount;
	long id;
	long edgecount;
	Node[] nodes;
	this(Node node){
		this.id = node.id;
		this.nodes = [node];
		this.value = node.value;
	}
	void eat(Group gp){
		if(gp.nodes.length > this.nodes.length) gp.eat(this);
		else{
			foreach(nd; gp.nodes){
				this.nodes ~= nd;
				nd.group = this;
				this.value += nd.value;
			}
			this.edgecount += gp.edgecount;
			this.pendingEdgeCount += gp.pendingEdgeCount;
		}
	}
}


Measured memory_bytes: 51452
n = gets.to_i
p, q = n.times.map{gets.split.map(&:to_i)}.transpose
p.push(q[-1])

m = []

(1..n).each do |i|
  m[i] = []
  m[i][i] = 0
end

(2..n).each do |l|
  (1..(n - l + 1)).each do |i|
    j = i + l - 1
    m[i][j] = (1 << 21)

    (i..(j - 1)).each do |k|
      m[i][j] = [m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]].min
    end
  end
end
puts m[1][n]


Measured memory_bytes: 6936
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if (n % 2 == 0) System.out.println(1.0 / 2.0);
		else System.out.println((double) (n / 2 + 1) / (double) n);
	}
}


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

int map[16][16];

void del(int x, int y)
{
	if (map[y][x]){
		map[y][x] = 0;
		del(x - 1, y);
		del(x, y - 1);
		del(x + 1, y);
		del(x, y + 1);
	}
}

int main(int argc, char const *argv[])
{
	int count;
	int i, j;
	char line[16];

	while (1){
		count = 0;
		memset(map, 0, sizeof(map));
		for (i = 1; i < 13; i++){
			if (scanf("%s", line) == EOF) return (0);

			for (j = 1; j < 13; j++){
				map[i][j] = line[j - 1] - '0';
			}
		}

		for (i = 1; i < 13; i++){
			for (j = 1; j < 13; j++){
				if (map[i][j]){
					count++;
					del(j, i);
				}
			}
		}
		printf("%d\n", count);
	}
}

Measured memory_bytes: 544
//
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define MOD 1000000007
#define PI 3.14159265
#define EPS 1e-9
#define Pi acos(-1.0)
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;

/*CODE START HERE*/

int n, ans;
int arr[105];

int main(){
    ios::sync_with_stdio(0);
    cin >> n;
    forn(i,n) cin >> arr[i];
    sort(arr,arr+n);
    ans = 1;
    forn(i,n-1){
        if(arr[i] != arr[i+1]){
            ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<time.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h> 
int main()
{
	int n,m,a[110][110],b[110],c,i,j;
	scanf("%d %d",&n,&m);
	for(j=1;j<=n;j++)
		for(i=1;i<=m;i++)
			scanf("%d",&a[j][i]);
	for(i=1;i<=m;i++)
		scanf("%d",&b[i]);
	for(i=1;i<=n;i++)
	{
		c=0;
		for(j=1;j<=m;j++)
			c+=a[i][j]*b[j];
		printf("%d\n",c);
	}
	return 0;
}


Measured memory_bytes: 2120
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

const ll mod = 1e9+7;

int main()
{
    ll N,K;
    cin >> N >> K;
    vint A(N);
    cin >> A;
    vint cnt(N);
    vint bias(N);
    REP(i,N){
        REP(j,N){
            if(A[i] > A[j])cnt[i]++;
            if(i < j && A[i] > A[j])bias[i]++;
        }
    }
    ll ans = 0;
    REP(i,N){
        ll mul = (K*(K-1)/2)%mod;
        ans += cnt[i]*mul;
        ans %= mod;
        ans += bias[i]*K;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    static int[] w = new int[100010];
    static int[] v = new int[100010];
    static int[][] dp = new int[110][100010];
    static int k;

    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return a;
        }
        return a;
    }

    static int chmax(int a, int b) {
        if (a < b) {
            a = b;
            return a;
        }
        return a;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println(sc.nextInt() / 3);
    }
}


Measured memory_bytes: 81492
n, k = gets.chomp.split.map(&:to_i)
arr2 = (1 .. n).to_a
arr, display = [], []
n.times{|i|
    x = gets.to_i
    arr << x
    if x == 0
        display << (i + 1) 
    else
        arr2[x - 1] = nil
    end
}
arr2.compact!
display += arr2

if k > 1
    temp = []
    arr2.each{|x|
        if arr[x - 1] != 0
            temp << [arr[x - 1], 1]
        end
    }
    temp.uniq!
    temp.each{|x, c| display << x}
    while xc = temp.pop
        x, c = xc
        if arr[x - 1] != 0 && c < k - 1
            temp << [arr[x - 1], c + 1]
            display << arr[x - 1]
        end
end
end
display.uniq!
puts display.length


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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int A, B, C;
	cin >>A >>B >>C;
	int I=0;
	while(true) {
		if (1==A%2)
			break;
		if (1==B%2)
			break;
		if (1==C%2)
			break;
		int A1=(B+C)/2;
		int B1=(A+C)/2;
		int C1=(A+B)/2;
		if ((A==A1)&&(B==B1)&&(C=C1)) {
			cout <<-1 <<endl;
			return 0;
		}
		A=A1;
		B=B1;
		C=C1;
		I++;
	}
	cout <<I <<endl;
	return 0;
}



Measured memory_bytes: 256
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
  for j in range(1,105):
    for k in range(1,105):
      v = i*i+j*j+k*k+i*j+j*k+k*i;
      if v < 10050:
        ans[v] += 1
        
for i in range(n):
  print(ans[i+1])

Measured memory_bytes: 9124
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;

vector<vector<i32>> root;

void dfs(vector<i32>& d, i32 v, i32 dist = 0, i32 prev = -1) {
  d[v] = dist;
  for(auto n : root[v]) {
    if(n == prev) {continue;}
    dfs(d, n, dist+1, v);
  }
}


int main(int argc, char* argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  i32 N, u, v;
  cin >> N >> u >> v;
  u--;
  v--;
  root.resize(N);
  for(i32 i = 0; i < N-1; ++i) {
    i32 a, b;
    cin >> a >> b;
    a--;
    b--;
    root[a].push_back(b);
    root[b].push_back(a);
  }
  
  vector<i32> U(N), V(N);
  dfs(U, u);
  dfs(V, v);
  
  i32 ans=-1;
  for(i32 i=0; i < N; ++i) {
    if(U[i] < V[i]) {
      ans = max(ans, V[i]);
    }
  }
  cout << ans-1 << endl;
  
  return 0;
}

Measured memory_bytes: 11648
import java.util.Arrays;
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();
		long d = sc.nextInt();
		long a = sc.nextInt();

		Fox foxes[] = new Fox[n];
		for(int i = 0; i < n; i++){
			foxes[i] = new Fox(sc.nextInt(), sc.nextInt());
		}

		Arrays.sort(foxes);

		SqrtDecomposition sq = new SqrtDecomposition(n);

		for(int i = 0; i < n; i++){
			sq.add(i + 1, i + 2, foxes[i].hp);
		}

		long count = 0;
		int j = 1;
		for(int i = 0; i < n; i++){
			if(sq.get(i + 1) <= 0){
//				System.out.println(sq.get(i + 1));
//				j = Math.max(j, i + 2);
				continue;
			}
			while(j < n && foxes[j].pos <= foxes[i].pos + 2*d){
				j++;
			}

			long tmpNum = (sq.get(i + 1) + a - 1)/a;
			count += tmpNum;
//			System.out.println("bomb : "+i+" (pos "+foxes[i].pos + ") "+(j - 1)+" (pos "+foxes[j - 1].pos+") " + tmpNum +" times");
			sq.add(i + 1, j + 1, -a*tmpNum);
		}

		System.out.println(count);
	}

}


class SqrtDecomposition {
	int N, K;
	long[] data;
	long[] bucketAdd;
	static final int sqrtN = 512;

	public SqrtDecomposition(int n) {
		N = n;
		K = (N + sqrtN - 1) / sqrtN;
		data = new long[K * sqrtN];
		bucketAdd = new long[K];
	}

	void add(int s, int t, long x) {
		for (int k = 0; k < K; ++k) {
			int l = k * sqrtN, r = (k + 1) * sqrtN;
			if (r <= s || t <= l)
				continue;
			if (s <= l && r <= t) {
				bucketAdd[k] += x;
			} else {
				for (int i = Math.max(s, l); i < Math.min(t, r); ++i) {
					data[i] += x;
				}
			}
		}
	}

	long get(int s) {
		int k = s / sqrtN;
		return data[s] + bucketAdd[k];
	}
}

class Fox implements Comparable<Fox> {
	long pos;
	long hp;

	Fox(int pos, int hp){
		this.pos = pos;
		this.hp = hp;
	}

	@Override
	public int compareTo(Fox f) {
		// TODO 自動生成されたメソッド・スタブ
		return (int)(this.pos - f.pos);
	}
}

Measured memory_bytes: 57276
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    ll x;
    cin >> x;
    cout << x / 500 * 1000 + (x%500)/5*5 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    cout << (a-1)*(b-1)<<endl;
    return 0;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)

int main() {
	int A = 0, B = 0;
	for_(i,0,4) {
		int a; scanf("%d", &a); A += a;
	}
	for_(i,0,4) {
		int b; scanf("%d", &b); B += b;
	}
	cout << max(A, B) << endl;
	return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;

int main()
{
    int n,y;
    cin >> n >>y;
    for(int i = 0; i <= 2000; i++){
        for(int j = 0; j <= 2000-i; j++){
            if(i*10000+j*5000 > y){
                break;
            }else if(i*10000+j*5000+(n-i-j)*1000==y){
                printf("%d %d %d\n",i,j,n-i-j);
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

 class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Integer[] x = new Integer[N];
        for(int i = 0; i<N; i++) {
        	x[i] = sc.nextInt();
        }
        Arrays.sort(x, Comparator.reverseOrder());
//        for(int i = 0; i<N; i++) {
//        	System.out.println(x[i]);
//        }
        int M = 0;
        int pul = x[0];
        int mai = x[N-1];
        
        for(int i=1;i<N-1;i++) {
        	if(x[i]<0) {
        		pul = pul - x[i];
        	} else {
        		mai = mai - x[i];
        	}
         }
        M = pul - mai;
        System.out.println(M);
        
        int max=x[0];
        int min=x[N-1];
        for(int i=1;i<N-1;i++) {
        	if(x[i]<0) {
        		System.out.println(max + " " + x[i]);
        		max = max - x[i];
        	} else {
        		System.out.println(min + " " + x[i]);
        		min = min - x[i];
        	}        	
        }
        System.out.println(max + " " + min);
//        System.out.println(ans);
    }
}


Measured memory_bytes: 77896
#include<bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define mod 1000000007
#define bitcount __builtin_popcountll
#define ll long long
#define pb push_back
#define pi pair<int,int>
#define pii pair<pi,int>
#define mp make_pair
char arr[2005][2005];
int vertices[2005][2005],hedges[2005][2005],vedges[2005][2005];
int main()
{
	int i,j,k;
	int n,m,q;
	sd(n);
	sd(m);
	sd(q);
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=m;j++)
			arr[i][j]='0';
	}
	for(i=1;i<=n;i++)
		ss(arr[i]+1);
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			vertices[i][j]=vertices[i][j-1]+vertices[i-1][j]-vertices[i-1][j-1];
			hedges[i][j]=hedges[i][j-1]+hedges[i-1][j]-hedges[i-1][j-1];
			vedges[i][j]=vedges[i][j-1]+vedges[i-1][j]-vedges[i-1][j-1];
			if(arr[i][j]=='1')
				vertices[i][j]++;
			if(arr[i][j]=='1'&&arr[i-1][j]=='1')
				vedges[i][j]++;
			if(arr[i][j]=='1'&&arr[i][j-1]=='1')
				hedges[i][j]++;
		}
	}
	while(q--)
	{
		int x1,y1,x2,y2;
		sd(x1);
		sd(y1);
		sd(x2);
		sd(y2);
		int v = vertices[max(x1,x2)][max(y1,y2)]-vertices[max(x1,x2)][min(y1,y2)-1]-vertices[min(x1,x2)-1][max(y1,y2)]+vertices[min(x1,x2)-1][min(y1,y2)-1];
		int he = hedges[max(x1,x2)][max(y1,y2)]-hedges[max(x1,x2)][min(y1,y2)]-hedges[min(x1,x2)-1][max(y1,y2)]+hedges[min(x1,x2)-1][min(y1,y2)];
		int ve = vedges[max(x1,x2)][max(y1,y2)]-vedges[max(x1,x2)][min(y1,y2)-1]-vedges[min(x1,x2)][max(y1,y2)]+vedges[min(x1,x2)][min(y1,y2)-1];
		// printf("%d %d %d\n",v,he,ve );
		printf("%d\n",v-he-ve );
	}

	return 0;
}

Measured memory_bytes: 52864
def Graph():
    G=[[] for i in range(n)]
    #up_G=[0]*n#up_G[i]=頂点iの親
    for _ in range(n-1):
        a,b=map(int,input().split())
        G[a-1].append(b-1)
        G[b-1].append(a-1)
    return G

from collections import deque
def bfs(G,v,p):
    #(G,v,p)=(グラフ(木の情報),探索中の頂点,vの親)
    #vの子の頂点を決めて、vをpに移す
    q=deque()
    q.append((v,p))
    while q:
        V,P=q.popleft()
        for new_v in G[V]:
            #new_vが頂点の時はアウト
            if new_v==P:continue
            ans[new_v]+=ans[V]
            q.append((new_v,V))
n,q=map(int,input().split())
G=Graph()
ans=[0]*n
for _ in range(q):
    p,x=map(int,input().split())
    ans[p-1]+=x
bfs(G,0,-1)
print(*ans)


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

using namespace std;

int main(void){
    int x, y;
    while(cin >> x >> y){
        if((x==0) && (y==0))
            break;
        if(x<=y)
            cout << x << " " << y << endl;
        else
            cout << y << " " << x << endl;
    }
}


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

int main()
{
	string a,b="A";
	int pos=0;
	cin>>a;
	a=a+"D";
	while(1)
	{
		pos=a.find(b,pos);
		if(pos<0)
		{
			cout<<"No"<<endl;
			break;
		}
		if(a[pos+1]=='C')
		{
			cout<<"Yes"<<endl;
			break;
		}
		pos++;
	}
	return 0;
}

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 a = sc.nextInt(),b = sc.nextInt(), c = sc.nextInt();
		int result = 0;
		for(int i = 1; i <= b; i++) {
			if(a*i%b==c)result = 1;
		}
		if(result == 1)System.out.print("YES");
		else System.out.print("NO");
	}

}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll K;
    cin >> K;

    vector<ll> T(K*K+1, 0);

    for(ll i=0; i<K; i++){
        for(ll j=1; j<=K; j++){
            T[K*i+j] = gcd(i+1, j);
        }
    }

    ll ans = 0;
    for(ll i = 1; i<=K*K; i++){
        for(ll j=1; j<=K; j++){
            ans += gcd(T[i], j);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
A = int(input())
B = int(input())
C = int(input())
X = int(input())
 
count = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i*500 + j*100 + k*50 == X:
                count += 1
 
print(count)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    int n;  cin >> n;
    vector<vector<ll>> original(n, vector<ll>(n, LINF));
    REP(i, n) REP(j, n) cin >> original[i][j];
    vector<vector<ll>> copy = original;
    REP(k, n){
        REP(i, n){
            REP(j, n){
                copy[i][j] = min(copy[i][j], copy[i][k]+copy[k][j]);
            }
        }
    }
    if(copy!=original){
        cout << -1 << endl;
        return 0;
    }
    ll res=0;
    
    REP(i, n){
        REP(j, i){
            bool flag=false;
            REP(k, n)
                if(k!=i && k!=j &&copy[i][j]==copy[i][k]+copy[k][j]) flag =true; 
            if(!flag) res += copy[i][j];
        }
        
    }
    
    cout << res << endl;
}

Measured memory_bytes: 1664
def bsearch_desc(a, b, &proc)
  inverse_proc = -> (n) { proc.call(-n) }
  value *= -1 if value = (-a..-b).bsearch(&inverse_proc)
end

INF = 10 ** 9
n, k = gets.split.map(&:to_i)
nums = gets.split.map(&:to_i)

ans = bsearch_desc(INF, 1) { |length|
  count = 0
  nums.each do |num|
    div, mod = num.divmod(length)
    div += 1 if mod > 0
    count += div - 1
  end
  count > k
}

ans ||= 0
ans += 1

puts ans


Measured memory_bytes: 33596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll d;
    cin >> d;
    vector<ll> c(26);
    rep(i, 26) cin >> c[i];
    vector<vector<ll>> s(d, vector<ll>(26));
    rep(i, d) rep(j, 26) cin >> s[i][j];
    srand(1e9 + 7);
    rep(i, d) cout << (rand() % 26 + 1) << endl;
    return 0;
}


Measured memory_bytes: 3772
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int cnt[4000];
int vis[4000];
long long dis[4000];
struct edge{
	int a;
	long long b;
	operator int(){
		return a;
	}
};
vector<edge> v[4000];
queue<int> q;
void spfa(int n){
	while(q.size()){
		int N=q.front();
		q.pop();
		if(cnt[N]>n){
			if(vis[N]!=2){
				for(int i=0;i<v[N].size();i++){
					cnt[v[N][i]]=n+1;
					if(vis[v[N][i]]==0){
						vis[v[N][i]]=1;
						q.push(v[N][i]);
					}
				}
			}
			vis[N]=2;
			continue;
		}
		cnt[N]++;
		vis[N]=0;
		for(int i=0;i<v[N].size();i++){
			if(dis[v[N][i]]>dis[N]+v[N][i].b){
				dis[v[N][i]]=dis[N]+v[N][i].b;
				if(vis[v[N][i]]==0){
					vis[v[N][i]]=1;
					q.push(v[N][i]);
				}
			}
		}
	}
}
int main(){
	int n,m;long long t;
	cin>>n>>m>>t;
	for(int i=2;i<=n;i++){
		dis[i]=0x3f3f3f3f3f3f3f;
	}
	for(int i=0;i<m;i++){
		int g,h;long long k;
		cin>>g>>h>>k;
		v[g].push_back({h,t-k});
	}
	q.push(1);
	spfa(n);
	if(cnt[n]>n){
		cout<<-1<<endl;
		return 0;
	}
	//cout<<"SP: "<<dis[n]<<endl;
	cout<<max(-dis[n],0ll)<<endl;
	return 0;
}

Measured memory_bytes: 640
# coding: utf-8
def check(p):
    global ans
    global field
    ans+=1
    if(field[p[1]][p[0]]=='.'):
        field[p[1]][p[0]]='#'
    if(0<=p[0]+1<w and field[p[1]][p[0]+1]=='.'):
        check((p[0]+1,p[1]))
    if(0<=p[0]-1<w and field[p[1]][p[0]-1]=='.'):
        check((p[0]-1,p[1]))
    if(0<=p[1]+1<h and field[p[1]+1][p[0]]=='.'):
        check((p[0],p[1]+1))
    if(0<=p[1]-1<h and field[p[1]-1][p[0]]=='.'):
        check((p[0],p[1]-1))
    
    
while 1:
    ans=0
    w,h=map(int,input().split())
    if w==0:
        break
    field=[]
    for i in range(h):
        s=input()
        t=s.find('@')
        if(t!=-1):
            st=(t,i)
        field.append(list(s))
    check(st)
    print(ans)
    


Measured memory_bytes: 5792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ld long double
#define mem(a,b) memset(a,b,sizeof(a) )
#define M 4000010
#define md 1000000007

ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}
/*inline ll add(ll a,ll b){return (a+b)%md;}
inline ll mul(ll a,ll b){return (a*b)%md;}
ll f[M],iv[M];
ll C(ll n,ll r){return mul(f[n],mul(iv[r],iv[n-r]));}
void prep_fac(){
    f[0]=1;
    rep(i,1,M)f[i]=mul(i,f[i-1]);
    iv[M-1]=power(f[M-1],md-2,md);
    for(ll i=M-2;i>=0;--i)iv[i]=mul(i+1,iv[i+1]);
}*/



int main()
{
	IOS;
	ll a;
	cin>>a;
	a=!a;
	cout<<a;
}



Measured memory_bytes: 3564
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
typedef long long ll;
using namespace std;
const int maxn = 2009,MOD = 1e9+7;
const double pi = acos(-1.0);
ll n,a[maxn],f[maxn][maxn],id[maxn],ans;
bool cmp(ll x,ll y){
    return a[x] > a[y];
}
int main(){
    scanf("%lld",&n);
    for(int i = 1; i <= n; i++) scanf("%lld",&a[id[i] = i]);
    sort(id+1,id+n+1,cmp);
    for(int i = 1; i <= n; i++){
        f[i][0] = f[i-1][0] + a[id[i]] * abs(id[i] - (n-i+1));
        for(int j = 1; j <= i-1; j++){
            f[i][j] = max(f[i-1][j] + a[id[i]] * abs(id[i] - (n-i+1+j)),f[i-1][j-1] + a[id[i]] * abs(id[i] - j));
        }
        f[i][i] = f[i-1][i-1] + a[id[i]] * abs(id[i] - i);
    }
    for(int i = 0; i <= n; i++){
        ans = max(ans,f[n][i]);
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 26448
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

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() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(Q);
    REP(i, Q) {
        cin >> A.at(i);
        A[i]--;
    }

    vector<int> point(N, K - Q);
    REP(i, Q) { point[A[i]]++; }

    REP(i, N) {
        if (point[i] > 0) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }

    return 0;
}


Measured memory_bytes: 1408
#n=int(input())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

s=list(input())
n=len(s)
flag=True
stest=s[::-1]
if s!=stest:
    flag=False
stest=s[0:(n-1)//2]
if stest!=stest[::-1]:
    flag=False
stest=s[(n+3)//2-1:n]
if stest!=stest[::-1]:
    flag=False
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
  int N,M;
  scanf("%d",&N);
  scanf("%d",&M);
  int v[N];
  int count = 0;
  int all = 0;
  int r = 0;
  for(int i = 0;i < N;i++){
    scanf("%d",&v[i]);
    all += v[i];
  }
  for(int i = 0;i < N;i++){
    r = 0;
    r = v[i]*4*M;
    if(r >= all){
      count++;
    }
  }
  if(count >= M){
    printf("Yes");
  }
  else{
    printf("No");
  }
return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	string s;
	cin >> s;

	cout << s.substr(0, s.size() - 8) << endl;
	return 0;
}


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

int main()
{
  double n, m;
  cin >> n >> m;

  vector<double> vec(n);
  for (int i = 0; i < n; i++)
  {
    cin >> vec.at(i);
  }

  double sum = 0;
  for (int i = 0; i < n; i++)
  {
    sum += vec.at(i);
  }
  // cout << "sum: " << sum << endl;
  double x = sum / (4 * m);
  // cout << "x: " << x << endl;
  double count = 0;
  for (int i = 0; i < n; i++)

  {
    if (vec.at(i) >= x)
    {
      count += 1;
    }
  }
  // cout << "count: " << count << endl;
  if (count >= m)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream> 
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c;
	d=a;
	a=b;
	b=d;
	d=a;
	a=c;
	c=d;
	cout<<a<<" "<<b<<" "<<c;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <climits>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

double bin_pow(double a, LL b){
    double res = 1;
    while(b > 0){
        if(b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int main() {
    //cout << fixed << setprecision(20);
    int N, K; cin >> N >> K;

    cout << N-K+1 << endl;

    return 0;
}

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

const i64 MOD = 1e9 + 7;

int main()
{
  i64 n;
  cin >> n;
  vector<i64> a(n);
  for (i64 i = 0; i < n; i++)
    cin >> a[i];
  i64 ans = 1, c[3] = {};
  for (i64 i = 0; i < n; i++)
  {
    i64 cnt = 0, t = -1;
    if (a[i] == c[0])
    {
      cnt++;
      t = 0;
    }
    if (a[i] == c[1])
    {
      cnt++;
      t = 1;
    }
    if (a[i] == c[2])
    {
      cnt++;
      t = 2;
    }
    if (t == -1)
    {
      cout << 0 << endl;
      return 0;
    }
    (ans *= cnt) %= MOD;
    c[t]++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
# 3つの数字を1行で空白を挟んで入力
# 2つの数字が同じならかわいそうなのでyes、3つが同じまたは全て異なる場合はno

def check(input_list):
    if(input_list.count(input_list[0]) == 2 or input_list.count(input_list[1]) == 2):
        return True
    else:
        return False

if __name__ == '__main__':
    input_list = input().split()
            
    if check(input_list):
        print("Yes")
    else:
        print("No")
		

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

struct Union_Find_Tree{
    vector<int> par, rank, num;
    //要素数n(0〜n-1)の初期化されたUnion-Find木を構築
    Union_Find_Tree(int N){
        par.assign(N, -1);
        rank.assign(N, 0);
        num.assign(N, 1);
    }
    //ノードxの根を取得
    int root(int x){
        if(par[x] < 0 || par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    //xとyの属する集合を併合
    void unite(int x, int y){
        x = root(x), y = root(y);
        if(x == y) return;
        elif(rank[x] < rank[y]) par[x] = y, num[y] += num[x];
        else{
            par[y] = x, num[x] += num[y];
            if(rank[x] == rank[y]) rank[x]++;
        }
    }
    //xの属する集合の要素数を取得
    int size(int x){
        return num[root(x)];
    }
    //xとyが同じ集合に属するか判定
    bool same(int x, int y){
        return root(x) == root(y);
    }
    //初期化する
    void clear(){
        fill(par.begin(), par.end(), -1);
        fill(rank.begin(), rank.end(), 0);
        fill(num.begin(), num.end(), 1);
    }
};

int main(){
    int N, M;
    cin >> N >> M;
    Union_Find_Tree uft(N);
    int cnt = 0;
    rep(i, M){
        int x, y, z;
        cin >> x >> y >> z;
        x--, y--;
        if(uft.same(x, y)) continue;
        uft.unite(x, y);
        cnt++;
    }
    cout << N-cnt << endl;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

int INF = 1000000005;
using namespace std;

int main() {
    int n;
    cin >> n;
    int f[105][10], p[105][11];
    REP(i, n) {
        REP(j, 10) {
            cin >> f[i][j];
        }
    }
    REP(i, n) {
        REP(j, 11) {
            cin >> p[i][j];
        }
    }
    int maxx = -INF;
    FOR(i, 1, 1 << 10) {
        int profit=0;
        REP(j, n) {
            int r = 0;
            REP(k, 10) {
                if (i & (f[j][k] << k))r++;
            }
            profit += p[j][r];
        }
        maxx = max(maxx, profit);
    }
    cout << maxx << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF 1e9
#define MOD 1e9+7
#define sMOD 1e5
#define fs first
#define sc second


signed main(){
	
	ll a,b,c,n,m;
	string s,t;
	bool flag = false,flag2 = false;
	ll A[10000] = {},B[10000] = {},C[10000] = {};
	double e,f;
	
	cin >> e >> f;
	cout << e/f << endl;
	
	return 0;

}

Measured memory_bytes: 764
def main():
    NK = list(map(int,input().split()))


    count = [0] * NK[0]

    for i in range(NK[1]):
        d = int(input())
        di = list(map(int,input().split()))
        for g in range(d):
            count[di[g]-1] += 1


    print(count.count(0))







if __name__ == '__main__':
    main()



Measured memory_bytes: 9196
from sys import stdout, stdin, maxsize

n, k = map(int, stdin.readline().split())
ls = list(map(int, stdin.readline().split()))
dp = [maxsize] * (n + 1)
dp[1] = 0
if n == 1:
	print(0)
else:
	dp[2] = abs(ls[1] - ls[0])
	for i in range(3, n + 1):
		j = 1
		while j <= k and i - j >= 0:
			dp[i] = min(dp[i - j] + abs(ls[i - 1] - ls[i - 1 - j]), dp[i])
			j += 1
	print(dp[n])


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

int main(){
	int n;
	bool no[10001] = {true,true};
	for(int i = 4;i <= 10000;i += 2) no[i] = true;
	for(int i = 3;i * i <= 10000;i += 2){
		for(int j = i * 2;j <= 10000;j += i) no[j] = true;
	}
	vector<int> twin;
	for(int i = 2;i <= 10000;i++){
		if(!no[i] && !no[i - 2]) twin.push_back(i);
	}
	while(cin >> n,n){
		int pos = upper_bound(twin.begin(),twin.end(),n) - twin.begin() - 1;
		cout << twin[pos] - 2 << " " << twin[pos] << endl; 
	}
	return 0;
}

Measured memory_bytes: 3088
n = int(input())

primes = [0]*(n+1)

def factorize(n):
  
  global primes
  arr = []
  temp = n

  for i in range(2, int(n**(1/2))+1):
    if temp % i == 0:
      while temp % i == 0:
        temp //= i
        primes[i] += 1

  if temp != 1:
    primes[temp] += 1

for i in range(2, n+1):
  factorize(i)
  
MOD = 1000000007

def mod(n):         
  return n % MOD

def multiply(a, b): #mod(a*b)を求める
  return mod(mod(a)*mod(b))

ans = 1
for i in range(n+1):
  if primes[i] > 0:
    ans = multiply(ans, primes[i]+1)
    
print(mod(ans))

Measured memory_bytes: 67928
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inS = Console.ReadLine().Split(' ');
            int in0 = int.Parse(inS[0]);
            int in1 = int.Parse(inS[1]);

            Console.WriteLine("{0}", in0 - in1 + 1);
        }
    }
}


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

int main(){
  int N,M;cin >> N >> M;
  vector<int> A(M);
  vector<int> C(M,0);
  int INF = 0;
  for(int i=0;i<M;i++){
    int B;
    cin >> A[i] >> B;
    INF += A[i];
    for(int b=0;b<B;b++){
      int c;cin >> c;
      C[i] |= (1<<(c-1));
    }
    //cout << i << " " << A[i] << " " << C[i] << endl;
  }
  INF ++;
  vector<vector<int>> DP(M+1,vector<int>((1<<N),INF));
  DP[0][0]=0;
  for(int i=0;i<M;i++){
    for(int bit=0;bit<(1<<N);bit++){
      DP[i+1][bit] = DP[i][bit];
    }
    for(int bit=0;bit<(1<<N);bit++){
      DP[i+1][bit|C[i]] = min(DP[i+1][bit|C[i]],DP[i][bit]+A[i]);
    }
  }
  //for(int i=0;i<=M;i++){
  //  for(int bit=0;bit<(1<<N);bit++){
  //    if(DP[i][bit]==INF){
  //      cout << "INF";
  //    }else{
  //      cout << DP[i][bit];
  //    }
  //    cout << " ";
  //  }
  //  cout << endl;
  //}
  int ans = DP[M][(1<<N)-1];
  if(ans>=INF){
    cout << -1 << endl;
  }else{
    cout << ans << endl;
  }
}

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

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

    int A[N];
    for(int i=0;i<N;i++) cin >> A[i];

    for(int i=0;i<N;i++){
        H -= A[i];
    }

    if(H<=0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

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

	int64_t a; cin >> a;
	double b; cin >> b;
	int64_t bx = 100.0 * b + std::numeric_limits<float>::epsilon();
	cout << (a * bx / 100) << endl;

	return 0;
}

Measured memory_bytes: 3736
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;


int main()
{
	string str;
	cin >> str;
	
	int ans = 0;
	for(int i = 1;2*i < str.size();i++)
	{
		if(str.substr(0,i) == str.substr(i,i))
			ans = 2*i;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>a;
	cout<<a*a*a<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    int m1 = 0;
    for (int i = 0; i < N; i++) {
        if (i%2 == 0) m1 += A[i];
        else m1 -= A[i];        
    }
    for (int i = 0; i < N; i++) {
        cout << m1 << ' ';
        m1 = (A[i] - m1 / 2) * 2;
    }
    return 0;
}

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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

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

  RREP(i, n + 1) {
    if (sqrt(i) == int(sqrt(i))) {
      printf("%d\n", i);
      break;
    }
  }
}


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

int main(){
	int i,A,B,K;
  	cin >> A >> B >> K;
  	for(i = min(A,B) ; ; i --){
    	if(A % i == 0 && B % i == 0){
         	K --;
          	if(K == 0){
              	K = i;
              	break;
            }
        }
    }
  	cout << K << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };

int main() {
    int n, k;
    cin >> n >> k;
    ll x[n];
    rep (i, n) cin >> x[i];
    ll ans = INF;
    rep (i, n - k + 1) {
        ll sum = x[k + i - 1] - x[i];
        if (x[i] < 0) sum += min (abs (x[i]), abs (x[i + k - 1]));
        else
            sum += x[i];
        //cout << sum << "\n";
        ans = min (sum, ans);
    }

    cout << ans << "\n";
}

Measured memory_bytes: 1024
n = int(input())
s = []
for i in range(n):
    s1 = list(input())
    s1.sort()
    m1 = len(s1)
    s1.append(0)
    if i == 0:
        m = m1
        mi = 0
    else:
        if m > m1:
            m = m1
            mi = i
    s.append(s1)
l = []
for i in range(m):
    p = s[mi][i]
    key = 0
    for j in range(n):
        n1 = len(s[j])-1
        j1 = s[j][n1]
        #print(s,n1,p)
        if j1 < n1:
            for k in range(j1,n1):
                if p == s[j][k]:
                    s[j][n1] = k+1
                    break
                if k == n1-1:
                    #print(s[j])
                    key = 1
        else:
            key = 1
            break
    if key == 0:
        l.append(p)
if len(l) > 0:
    for x in l:
        print(x,end="")

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

int main(){
    int A,B,C; cin >> A >> B >> C;
    if(A==B && B!=C) cout << C;
    if(A==C && A!=B) cout << B;
    if(B==C && A!=B) cout << A;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int q=sc.nextInt();
    int a[]=new int[q];
    int point[]=new int[n];
    for(int i=0;i<q;i++){
      a[i]=sc.nextInt();
    }
    sc.close();

    for(int i=0;i<q;i++){
      point[a[i]-1]++;
    }
    for(int i=0;i<n;i++){
      if((point[i]+k-q)>0){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
  }
}

Measured memory_bytes: 78776