akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 2 * 1000 + 47;
const int MOD = 1000 * 1000 * 1000 + 7;

string A[MAX];
int P1[MAX][MAX];
int P2[MAX][MAX];
int P3[MAX][MAX];

void recalc(int i, int j, int P1[MAX][MAX])
{
	if (i) P1[i][j] += P1[i - 1][j];
	if (j) P1[i][j] += P1[i][j - 1];
	if (i && j) P1[i][j] -= P1[i - 1][j - 1];
}

int get1(int x1, int y1, int x2, int y2)
{
	int res = P1[x2][y2];
	if (x1) res -= P1[x1 - 1][y2];
	if (y1) res -= P1[x2][y1 - 1];

	if (x1 && y1) res += P1[x1 - 1][y1 - 1];
	return res;
}

int get2(int x1, int y1, int x2, int y2)
{
	int res = P2[x2][y2];
	if (x1) res -= P2[x1 - 1][y2];
	res -= P2[x2][y1];

	if (x1) res += P2[x1 - 1][y1];
	return res;
}

int get3(int x1, int y1, int x2, int y2)
{
	int res = P3[x2][y2];
	res -= P3[x1][y2];
	if (y1) res -= P3[x2][y1 - 1];

	if (y1) res += P3[x1][y1 - 1];
	return res;
}

void print(int n, int m, int P[MAX][MAX])
{
	FOR(i, 0, n)
	{
		FOR(j, 0, m) cout << P[i][j] << " ";
		cout << endl;
	}
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n, m, q;
	cin >> n >> m >> q;
	FOR(i, 0, n)
	{
		cin >> A[i];
	}

	FOR(i, 0, n)
	{
		FOR(j, 0, m)
		{
			P1[i][j] = A[i][j] == '1';
			recalc(i, j, P1);
		}
	}

	FOR(i, 0, n)
	{
		FOR(j, 0, m)
		{
			if (j && A[i][j] == A[i][j - 1] && A[i][j] == '1')
			{
				P2[i][j] = 1;
			}
			
			recalc(i, j, P2);
		}
	}

	FOR(i, 0, n)
	{
		FOR(j, 0, m)
		{
			if (i && A[i][j] == A[i - 1][j] && A[i][j] == '1')
			{
				P3[i][j] = 1;
			}

			recalc(i, j, P3);
		}
	}

	//print(n,m,P1);
	//cout << endl;
	//print(n, m, P2);
	//cout << endl;
	//print(n, m, P3);

	FOR(i, 0, q)
	{
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;

		x1--;
		y1--;
		x2--;
		y2--;

		int p1 = get1(x1, y1, x2, y2);
		int p2 = get2(x1, y1, x2, y2);
		int p3 = get3(x1, y1, x2, y2);
		
		//cout <<"!!" << p1 << " " << p2 << " " << p3 << endl;
		cout << p1 - (p2 + p3) << endl;
	}
}


Measured memory_bytes: 56960
import sys
sys.setrecursionlimit(200000)
n,l=map(int,input().split())
r=list(map(int,input().split()))
last=0;tiepoint=0
for i in range(n-1):
  if r[i]+r[i+1]>last:
    last=r[i]+r[i+1]
    tiepoint=i
if last>=l:
  print("Possible")
  for i in range(tiepoint):
    print(i+1)
  for i in range(tiepoint+1,n-1)[::-1]:
      print(i+1)
  print(tiepoint+1)
else:print("Impossible")


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

int main() {
  int a,b;
  cin >> a >> b;
  int s = 1;
  int ans = 0;
  while (s < b) {
    s--;
    s += a;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3580
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int a = stdIn.nextInt();
			int b = stdIn.nextInt();
			int c = stdIn.nextInt();
			int d = stdIn.nextInt();
			int e = stdIn.nextInt();
			int f = stdIn.nextInt();
			double x = (c * e - b * f) / (double)(a * e - b * d);
			double y = (c * d - a * f) / (double)(b * d - a * e);
			if(x == -0)
			{
				x = 0;
			}
			if(y == -0)
			{
				y = 0;
			}
			System.out.printf("%.3f %.3f\n", x, y);
		}
	}
}

Measured memory_bytes: 18204
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		
		int []p = new int [n];
		
		for(int i = 0 ;i < n ;i++) {
			p[i] = Integer.parseInt(sc.next())-1;
		}
		Unionfind uf = new Unionfind(n);
		
		for(int i = 0 ;i < m ;i++) {
			int x = Integer.parseInt(sc.next())-1;
			int y = Integer.parseInt(sc.next())-1;
			
			uf.union(x, y);
		}
		
		int ans = 0;
		
		for(int i = 0 ;i < n ;i++) {
			if(uf.root(i) == uf.root(p[i])) {
				ans++;
			}
		}
		
		System.out.println(ans);
		
		
	}

}

class Unionfind {

	private int[] data;
	
	public Unionfind(int size) {
		this.data = new int [size];
		clear();
	}
	
	public void clear() {
		Arrays.fill(data, -1);
	}
	
	public void union(int x , int y ) {
		if((x = root(x)) != (y = root(y))) {
			if(data[y] < data[x]) {
				final int t = x;
				x = y;
				y = t;
			}
			data[x] += data[y];
			data[y] = x;
		}
	}
	
	public int root(int x) {
		if(data[x] < 0) {
			return x;
		}
		else {
			return data[x] = root(data[x]);
		}
	}
	
	public boolean same(int x, int y) {
		return root(x) == root(y);
	}
	

}



Measured memory_bytes: 65356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int n,k,q;
  cin >> n >> k >> q;

  int a[n+1]={0};
  int i,num;
  for(i=1;i<q+1;i++){
    cin>>num;
    a[num]++;
  }

  for(i=1;i<n+1;i++){
    if(q-a[i]>=k) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
  }

  return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        String c = in.next();
        System.out.println((char)(c.charAt(0) + 1));
    }

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

class In {
    private BufferedInputStream reader = new BufferedInputStream(System.in);
    private byte[] buffer = new byte[0x10000];
    private int i = 0;
    private int length = 0;

    private int read() {
        if (i == length) {
            i = 0;
            try {
                length = reader.read(buffer);
            } catch (IOException ignored) {
            }
            if (length == -1) {
                return -1;
            }
        }
        return buffer[i++];
    }

    String next() {
        StringBuilder builder = new StringBuilder();
        int b = read();
        while (b < '!' || '~' < b) {
            b = read();
        }
        while ('!' <= b && b <= '~') {
            builder.appendCodePoint(b);
            b = read();
        }
        return builder.toString();
    }

    int nextInt() {
        return (int)nextLong();
    }

    long nextLong() {
        int b = read();
        while (b < '!' || '~' < b) {
            b = read();
        }
        int i = 0;
        if (b == '-') {
            i = 1;
            b = read();
        }
        long n = 0;
        while ('0' <= b && b <= '9') {
            n = n * 10 + b - '0';
            b = read();
        }
        return i == 0 ? n : -n;
    }

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private static PrintWriter out = new PrintWriter(System.out);

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    }

    void flush() {
        out.flush();
    }
}


Measured memory_bytes: 21332
#include <iostream>
#include <queue>
#include <cmath>
#include <cstring>
using namespace std;

const int inf  = (1<<24);
const int dx[] = {+1, 0,-1, 0};
const int dy[] = { 0,+1, 0,-1};

int  H,W;
int  dist [30][30];
int  cost[30][30][4];
bool graph[30][30][4];

class Data
{
public:
	int x,y,dist,cost;
	Data(int x, int y, int d, int c)
	: x(x), y(y), dist(d), cost(c) {}
	bool operator<(const Data &d) const
	{
		if(cost!=d.cost) return cost>d.cost;
		if(dist!=d.dist) return dist>d.dist;
		return (x!=x ? x<d.x : y<d.y);
	}
};

void bfs(int sx, int sy)
{
	queue<Data> q;
	bool visited[30][30]={0};

	q.push( Data(sx, sy, 0, 0) );
	visited[sx][sy] = 1;

	for(int y=0; y<H; y++)
	for(int x=0; x<W; x++)
	{
		dist[x][y]=inf;
	}

	while(!q.empty())
	{
		Data t=q.front(); q.pop();
		dist[t.x][t.y] = t.cost;

		for(int i=0; i<4; i++)
		{
			if(!graph[t.x][t.y][i]) continue;
			int nx = t.x + dx[i];
			int ny = t.y + dy[i];

			if(visited[nx][ny]) continue;
			q.push( Data(nx, ny, 0, t.cost+1) );
			visited[nx][ny] = 1;
		}
	}
}

int main()
{
	while(cin>>H>>W, H||W)
	{
		memset(graph, 0, sizeof(graph));

		for(int y=0; y<H; y++)
		{
			int t;
			for(int x=0; x<W-1; x++)
			{
				if(cin >> t, t==0)
				{
					graph[x  ][y][0] = 1;
					graph[x+1][y][2] = 1;
				}
			}

			if(y==H-1) break;
			for(int x=0; x<W; x++)
			{
				if(cin >> t, t==0)
				{
					graph[x][y  ][1] = 1;
					graph[x][y+1][3] = 1;
				}
			}
		}

		memset(cost, 0, sizeof(cost));

		for(int x1=0; x1<W; x1++)
		for(int y1=0; y1<H; y1++)
		for(int  d=0;  d<2;  d++)
		{
			int x2 = x1 + dx[d];
			int y2 = y1 + dy[d];

			if(W<=x2) continue;
			if(H<=y2) continue;

			bool g = graph[x1][y1][d];

			graph[x1][y1][d  ]=0;
			graph[x2][y2][d+2]=0;

			bfs(W-1, H-1);
			cost[x1][y1][d  ]=dist[x1][y1];
			cost[x2][y2][d+2]=dist[x2][y2];

			graph[x1][y1][d  ]=g;
			graph[x2][y2][d+2]=g;
		}

		int  ans=inf;
		bool visited[30][30][900]={0};
		priority_queue<Data> q;
		q.push( Data(0, 0, 0, 0) );
		
		while(!q.empty())
		{
			Data t=q.top(); q.pop();
			if(t.x==W-1 && t.y==H-1)
			{
				ans=t.cost; break;
			}

			if(visited[t.x][t.y][t.dist]) continue;
			visited[t.x][t.y][t.dist]=1;

			for(int i=0; i<4; i++)
			{
				if(!graph[t.x][t.y][i]) continue;
				int nx = t.x+dx[i];
				int ny = t.y+dy[i];
				if(visited[nx][ny][t.dist+1]) continue;
				q.push( Data(nx, ny, t.dist+1, max(t.cost, t.dist+cost[t.x][t.y][i])) );
			}
		}

		if(inf<=ans) ans=-1;
		cout << ans << endl;
	}
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (c - (a - b) > 0) {
		cout << c - (a - b) << endl;
	}
	else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n, m, q, dp[600][600];
int main(void){
    // Your code here!
    cin >> n >> m >> q;
    for (ll i = 0; i < m; i++){
        ll l, r;
        cin >> l >> r;
        dp[1][r]++;
        dp[l + 1][r]--;
    }
    for (ll i = 1; i <= n; i++){
        for (ll j = 1; j < n; j++){
            dp[j + 1][i] += dp[j][i];
        }
    }
    for (ll i = 1; i <= n; i++){
        for (ll j = 1; j < n; j++){
            dp[i][j + 1] += dp[i][j];
        }
    }
    for (ll i = 0; i < q; i++){
        ll e, f;
        cin >> e >> f;
        cout << dp[e][f] << endl;
    }
}


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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 60, M = 1010;

int n;
LL m, cnt[M];

int main()
{
	scanf("%d%lld", &n, &m);
	for (int i = 0; i < n; i ++ )
	{
		LL t;
		scanf("%lld", &t);
		for (int j = 0; j < N; j ++ ) cnt[j] += (t >> j) & 1;
	}
	
	int u = -1;
	for (int i = N - 1; i >= 0; i -- )
		if (((m >> i) & 1))
		{
			if (cnt[i] >= n - cnt[i])
			{
				u = i;
				break;
			}
			else cnt[i] = n - cnt[i];
		}
	
	for (int i = u - 1; i >= 0; i -- )
		if (cnt[i] < n - cnt[i])
			cnt[i] = n - cnt[i];
	
	LL res = 0;
	for (int i = 0; i < N; i ++ ) res += cnt[i] * (1LL << i);
	printf("%lld\n", res);
    return 0;
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  if (n == 7 || n == 5 || n == 3) cout << "YES\n";
  else cout << "NO\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
const int MOD = 998244353;
const int N = 2e5 + 7;
int n, m, k;
int fact[N];
int mul(int x, int y)
{
	int res = ((x % MOD) * (y % MOD)) % MOD;
	return res;
}
int binpow(int a, int b)
{
	a %= MOD;
	int res = 1;
	while (b)
	{
		if (b & 1) res = (res * a) % MOD;
		a = (a * a) % MOD;
		b >>= 1;
	}
	return res;
}
int add(int x, int y)
{
	int res = ((x % MOD) + (y % MOD)) % MOD;
	return res;
}
int comb(int n, int r)
{
	int ans = fact[n];
	ans = mul(ans, binpow(fact[r], MOD - 2));
	ans = mul(ans, binpow(fact[n - r], MOD - 2));
	return ans;
}
int32_t main() {
	fast_io();
	cin >> n >> m >> k;
	fact[0] = 1;
	for (int i = 1; i <= n; i++)
		fact[i] = mul(fact[i - 1], i);
	int res = 0;
	for (int i = 0; i <= k; i++)
	{
		int x = binpow(m - 1, n - i - 1);
		int y = mul(x, m);
		int z = comb(n - 1, i);
		res = add(res, mul(y, z));
	}
	cout << res % MOD << "\n";
	return 0;
}

// formula - M*(M-1)^(N-k-1)*C(N-1,k)

Measured memory_bytes: 5148
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int x; cin>>x;
	if (x <= 599) puts("8");
	else if (x <= 799) puts("7");
	else if (x <= 999) puts("6");
	else if (x <= 1199) puts("5");
	else if (x <= 1399) puts("4");
	else if (x <= 1599) puts("3");
	else if (x <= 1799) puts("2");
	else puts("1");
	return 0;
}

Measured memory_bytes: 3600
import math

N = int(input())
root = math.sqrt(N)
pair = []

for i in range(math.floor(root)):
    I = i + 1
    if N % I == 0:
        pair.append([I, N/I])
        
wa = []
        
for i in range(len(pair)):
    wa.append((pair[i][0] - 1) + (pair[i][1] - 1))
else:
    print(int(min(wa)))


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

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

	int[] ini = new int[10];
	int[] itu = new int[10];
	int a=0;
	for(int i=0; i<10; i++)
	    ini[i] = sc.nextInt();
	for(int i=0; i<10; i++)
	    itu[i] = sc.nextInt();
	
	for(int i=9; i>=1; i--)
	    for(int j=0; j<i; j++)
		if(ini[j] < ini[j+1]){
		    a = ini[j];
		    ini[j]=ini[j+1];
		    ini[j+1]=a;
		}
	System.out.print(ini[0]+ini[1]+ini[2]+" ");
	a=0;
	for(int i=9; i>=1; i--)
	    for(int j=0; j<i; j++)
		if(itu[j] < itu[j+1]){
		    a = itu[j];
		    itu[j]=itu[j+1];
		    itu[j+1]=a;
		}
	System.out.println(itu[0]+itu[1]+itu[2]);
    }
}

Measured memory_bytes: 12000
#include <stdio.h>

typedef struct{
	double x;
	double y;
} POINT;

int main(void)
{
	POINT A, B, C, D;
	
	while (scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &A.x, &A.y, &B.x, &B.y, &C.x, &C.y, &D.x, &D.y) != EOF){
		if ((A.x == B.x && C.y == D.y) || (A.y == B.y && C.x == D.x)){
			printf("YES\n");
		}
		else if (A.x == B.x || C.x == D.x){
			printf("NO\n");
		}
		else if ((A.y - B.y)/(A.x - B.x) * (C.y - D.y)/(C.x - D.x) == -1){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
	
	return (0);
}

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

using namespace std ;

const int MAX = 2e5 + 10 ;

int a[MAX] , b[MAX] ;

int n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	for(int i = 0 ; i < n ; ++i)
		cin>>a[i]>>b[i] ;
	long long ans = 0 , x = 2e9 ;
	bool flag = false ;
	for(int i = 0 ; i < n ; ++i)
	{
		ans += a[i] ;
		if(a[i] != b[i])
			flag = true ;
		if(a[i] > b[i])
			x = min(x , b[i]*1ll) ;
	}
	if(!flag)
		ans = 0 , x = 0 ;
	return cout<<ans - x<<"\n" , 0 ;
}

Measured memory_bytes: 3804
#include<cstdio>
#include<vector>
#include<algorithm>
const int N=2e5+3,M=1e9+7;
int n,x,y,a,b,ans,sum,t[N],invf[N],c[N],d,f[N];
std::vector<int>h[N];
bool Cmp(const int&i,const int&j){
	if(!h[i].size())return 0;
	if(!h[j].size())return 1;
	return h[i][0]<h[j][0];
}
inline int Pow(int a,int m){int s=1;for(;m;m>>=1)m&1?s=1ll*s*a%M:0,a=1ll*a*a%M;return s;}
void InC(){
	f[0]=1;
	for(int i=1;i<=n;i++)f[i]=1ll*f[i-1]*i%M;
	invf[n]=Pow(f[n],M-2);
	for(int i=n;i;i--)invf[i-1]=1ll*invf[i]*i%M;
}
inline int C(int n,int m){return 1ll*f[n]*invf[m]%M*invf[n-m]%M;}
int main(){
	scanf("%d%d%d",&n,&x,&y);
	InC();
	for(int i=1;i<=n;i++)
	  scanf("%d%d",&a,&b),h[a].push_back(b),
	  t[i]=i;
	for(int i=1;i<=n;i++){
	  std::sort(h[i].begin(),h[i].end());
	  for(int j=1;j<h[i].size();j++)
		if(h[i][0]+h[i][j]<=x)c[i]=j;
	}
	std::sort(t+1,t+1+n,Cmp);
	if(!h[t[2]].size())return 0*puts("1");
	for(int i=1,k;h[t[i]].size();i++){
	  k=i==1?2:1;
	  for(int j=0;j<h[t[i]].size();j++)
		if(h[t[k]][0]+h[t[i]][j]<=y&&j>c[t[i]])c[t[i]]=j;
	  if(h[t[i]][0]+h[t[k]][0]<=y)d=i;
	}
	ans=1;sum=0;
	for(int i=1;i<=d;i++)sum+=c[t[i]]+1;
	for(int i=1;i<=d;i++)
	  ans=1ll*ans*C(sum,c[t[i]]+1)%M,
	  sum-=c[t[i]]+1;
	printf("%d",ans);
	return 0; 
}

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

int main(){
     int a,b,c,k;
     cin>>a>>b>>c>>k;
     while(k--){
          if(c>b&&b>a) break;
          if(b<=a) b*=2;
          else if(c<=b) c*=2;
     }
     if(c>b&&b>a) printf("Yes\n");
     else printf("No\n");
     return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)

int main(){
    int n;
    cin>>n;
    vector<double>a(n);
    vector<double>b(n);
    rep(i,n) cin>>a[i];

    //要素それぞれの逆数にする
    for(int j=0; j<n; ++j){
        b[j]=1/a[j];
    }
    //分母の和
    //rep(i,n) cout<<b[i]<<endl;
    double rsum=0;
    rep(i,n) rsum += b[i];
    //cout<<rsum<<endl;
    //さらに逆数
    double rrsum=1/rsum;
    cout<<rrsum<<endl;

    return 0;
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}



fn main() {
    let x: u64 = input();
    let mut prime_numbers: Vec<u64> = Vec::new();
    for i in 2..((x+1) as f64).sqrt().ceil() as u64 {
        let mut flag = true;
        for n in &prime_numbers {
            if i % n == 0 {
                flag = false;
            }
        }
        if flag {
            prime_numbers.push(i);
        }
    }
    // println!("{:?}", prime_numbers);
    let mut res = x;
    loop {
        let mut flag = true;
        for n in &prime_numbers {            
            if res % n == 0 {
                flag = false;
            }
        }
        if flag {
            println!("{}", res);
            return;
        }
        res += 1;
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) begin(x), end(x)
using namespace std;
typedef long long ll;
typedef pair <int,int> P;

int main(){
  int n;  
  cin>>n;
  int a[100005];
  rep(i,n) cin>>a[i];
  int q;
  cin>>q;
  vector<int> cnt(100005,0);
  ll sum=0;
  rep(i,n){
    cnt[a[i]]++;
    sum+=a[i];
  }
  rep(i,q){
    int b,c;
    cin>>b>>c;
    sum+=cnt[b]*(c-b);
    cnt[c]+=cnt[b];
    cnt[b]=0;
    cout<<sum<<endl;
  }
  return 0;
}


Measured memory_bytes: 4004
def dfs (i,sum,count,rem):
    global ans
    if i == D:
        if sum < G:
            k = max(rem)
            n = min(pc[k-1][0],-(-(G-sum)//(k*100)))
            count += n
            sum += n*100*k
        if sum >= G:
            ans = min(ans,count)
    else:
        dfs(i+1,sum,count,rem)
        dfs(i+1,sum+pc[i][0]*100*(i+1)+pc[i][1],count+pc[i][0],rem-{i+1})

D,G = map(int,input().split())
pc = [list(map(int,input().split())) for i in range(D)]

ans = float("inf")

dfs(0,0,0,set(range(1,D+1)))
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = (1ll << 30) - 1ll;

int main() {
    int n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;
    int res = 0;
    for (int i = 0; i < k; ++i) {
        vector<vector<int>> dp(n / k + 5, vector<int>(3, -INF));
        dp[0][0] = 0, dp[0][1] = 0, dp[0][2] = 0;
        int id = 1;
        for (int j = i; j < n; j += k) {
            for (int l = 0; l < 3; ++l) {
                for (int m = 0; m < 3; ++m) {
                    if (l != m) {
                        dp[id][l] = max(dp[id][l], dp[id - 1][m]);
                    }
                }
            }
            if (t[j] == 'r') {
                dp[id][2] = max(dp[id][2], max(dp[id - 1][0], dp[id - 1][1]) + p);
                // cout << dp[id][2] << endl;
            }else if (t[j] == 's') {
                dp[id][0] = max(dp[id][0], max(dp[id - 1][1], dp[id - 1][2]) + r);
                // cout << dp[id][0] << endl;
            }else {
                dp[id][1] = max(dp[id][1], max(dp[id - 1][2], dp[id - 1][0]) + s);
                // cout << dp[id][1] << endl;
            }
            id++;
        }
        res += max({dp[id - 1][0], dp[id - 1][1], dp[id - 1][2]});
    }
    cout << res << endl;
    return 0;
}

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

// Debug
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

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

#define SZ(x) ((int)(x).size())

#define all(x) begin(x),end(x)


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

// std::vector debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    for (auto& e : v) os << e << ", ";
    return os << "]";
}

// std::pair debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "(" << p.first << " " << p.second << ")";
}

// infty
template<typename T>
T inf() { return numeric_limits<T>::max(); }

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

const ll MOD = 1e9+7;
const ld EPS = 1e-9;


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

    map<char,int> dx, dy;
    dx['E'] = 1, dx['W'] = -1, dx['N'] = dx['S'] = 0;
    dy['N'] = 1, dy['S'] = -1, dy['E'] = dy['W'] = 0;

    for (;;) {
        int n; cin >> n;
        if (n == 0) break;
        map<P,bool> point;
        rep (i, n) {
            int x, y; cin >> x >> y;
            point[make_pair(x, y)] = true;
        }
        int m; cin >> m;
        int x = 10, y = 10;
        point.erase({ x, y });
        rep (i, m) {
            char dir; int l; cin >> dir >> l;
            while (l--) {
                x += dx[dir];
                y += dy[dir];
                point.erase({ x, y });
            }
        }
        cout << (SZ(point) ? "No" : "Yes") << endl;
    }

    return 0;
}



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

using namespace std;

typedef vector<int> vi;

void dfs(vi e[], int c[], int x, int p, int d[], int &q) {
    d[x] = c[q++];
    for (int y : e[x]) {
        if (y != p) {
            dfs(e, c, y, x, d, q);
        }
    }
}

int main() {
    int n;
    cin >> n;
    vi e[n];
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    int c[n];
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    sort(c, c+n);
    reverse(c, c+n);

    int ans = 0;
    for (int i = 1; i < n; i++) {
        ans += c[i];
    }

    int d[n];
    for (int i = 0; i < n; i++) {
        if (e[i].size() == 1) {
            int q = 0;
            dfs(e, c, i, -1, d, q);
        }
    }

    cout << ans << endl;
    for (int i = 0; i < n; i++) {
        cout << d[i] << (i == n - 1 ? '\n' : ' ');
    }

    return 0;
}


Measured memory_bytes: 1664
<?php
$n=trim(fgets(STDIN));
$c=0;
for($i=0;$i<$n;$i++){
  if(isPn(trim(fgets(STDIN)))) ++$c;
}
print $c;

function isPn($n){
  if($n<2) return 0;
  if($n==2) return 1;
  if($n%2==0) return 0;
  $max=floor(sqrt($n));
  for($i=3;$i<=$max;$i++) if($n%$i==0) return 0;
  return 1;
}
?>

Measured memory_bytes: 15376
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll INF=1e9+1;

int main(){
    string s;
    cin >> s;
    s[3]='8';
    cout << s << endl;
    return 0;
} 


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

int main() {
  int n;
  cin >> n;
  vector<int> pts(n);
  for (int i = 0; i < n; i++) cin >> pts.at(i);
  sort(pts.begin(), pts.end());
  int sum = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) sum += pts.at(n - 1 -i);
    else sum -= pts.at(n - 1 - i);
  }
  cout << sum << endl;
}


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

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

    long long total = 0;
    for(int i = 1; i <= N; i++) {
        if(i % 3 != 0 && i % 5 != 0) {
            total += i;
        }
    }

    cout << total << endl;

    return 0;
}

Measured memory_bytes: 3632
/*
coded by : Bissultanov Yedyge;
:)
¤
•
¦
§
*/
#include <bits/stdc++.h>
 
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
 
#define mp make_pair
#define np next_permutation
 
#define bg begin()
#define ed end()
 
#define int long long
#define ioi return 0;
 
#define sz size()
#define fix fixed<<setprecision
 
#define lb lower_bound
#define ub upper_bound
 
#define fr first
#define sc second
 
#define pb push_back
#define ppb pop_back
 
#define pf push_front
#define ppf pop_front
 
typedef long double ld;
typedef unsigned long long ull;
 
const int N = (int)5e5 + 7;
const int INF = (int)1e9 + 7;
 
using namespace std;
 
int ans, cnt;
int n , m;
int a[N];
string s , t;

main(){
	ios
		cin >> s >> t;
		cout << t << s;
	ioi	
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import deque
def main():
    K = int(input())
    que = deque(["1", "2", "3", "4", "5", "6", "7", "8", "9"])
    if K <= 9:
        print(que[K-1])
    else:
        K -= 9
        while K >= 0:
            v = que.popleft()
            if v[-1] != "0":
                K -= 1
                v1 = v + str(int(v[-1])-1)
                if K == 0:
                    print(v1)
                    break
                que.append(v1)
            K -= 1
            v2 = v + v[-1]
            if K == 0:
                print(v2)
                break
            que.append(v2)
            if v[-1] != "9":
                K -= 1
                v3 = v + str(int(v[-1])+1)
                if K == 0:
                    print(v3)
                    break
                que.append(v3)
if __name__ == "__main__":
    main()

Measured memory_bytes: 50012
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}
const ll inf = 1e17;
ll N, M, L, Q;
ll fuel[305][305];
ll dist[305][305];
ll s[105000], t[105000];
ll A[100000], B[100000], C[100000];

void input(){
    cin>>N>>M>>L;
    for(int i = 1; i <= M; i++)cin>>A[i]>>B[i]>>C[i];
    cin>>Q;
    for(int i = 1; i <= Q; i++)cin>>s[i]>>t[i];
}

int main(){
    input();
    for(int i = 1; i <= N; i++){
        for(int j = 1;j <= N; j++){
            fuel[i][j] = inf;
            dist[i][j] = inf;
        }
        fuel[i][i] = 0;
        dist[i][i] = 0;
    }
    for(int i = 1; i <= M; i++){
        chmin(fuel[A[i]][B[i]], C[i]);
        chmin(fuel[B[i]][A[i]], C[i]);
    }
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= N; j++){
            for(int k = 1; k <= N; k++){
                chmin(fuel[j][k], fuel[j][i]+fuel[i][k]);
            }
        }
    }
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= N; j++){
            if(i==j)continue;
            if(fuel[i][j] <= L) chmin(dist[i][j], 1ll);
        }
    }

    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= N; j++){
            for(int k = 1; k <= N; k++){
                chmin(dist[j][k], dist[j][i]+dist[i][k]);
            }
        }
    }
    for(int i = 1; i <= Q; i++){
        if(dist[t[i]][s[i]] < inf) cout<<dist[t[i]][s[i]]-1<<endl;
        else cout<<-1<<endl;
    }
    return 0;
}

Measured memory_bytes: 4864
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn gcd(x: i64, y: i64) -> i64 {
  if y == 0 {
    x
  } else {
    gcd(y, x % y)
  }
}

fn lcm(x: i64, y: i64) -> i64 {
  x * y / gcd(x, y)
}

fn trailing_zero(mut x: i64) -> i64 {
  let mut z = 0;
  loop {
    if x & 1 != 0 {
      return z;
    }
    x >>= 1;
    z += 1;
  }
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    m: i64,
    a: [i64; n],
  }
  let z = trailing_zero(a[0]);
  if ! a.iter().all(|&x| trailing_zero(x) == z) {
    puts!("0\n");
    return;
  }
  let mut l = 1;
  for &x in &a {
    l = lcm(l, x / 2);
  }

  puts!("{}\n", (m + l) / (2 * l));
}


Measured memory_bytes: 6396
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

def count(N, p):
    cnt = 0
    while N != 0:
        cnt += N // p
        N //= p
    return cnt

N = int(input())
mod = 10 ** 9 + 7
Primes = primes(N)
ans = 1
for p in Primes:
    ans *= (count(N, p) + 1)
    ans %= mod
print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#define mod 998244853 
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int a;
	string s;
	cin >> a;cin.ignore();
	cin >> s;
	if(a < 3200)
	    cout << "red\n";
	else
	    cout << s << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);++i)
#define rep2(i,j,n) for(int i=(j);i<=(n);++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;
typedef vector<long long int> vll;

int main() {
	int n;
	cin >> n;
	vi dp(n + 1, 0);
	rep(i, 0, n) {
		int a;
		cin >> a;
		dp[a] = dp[a - 1] + 1;
	}
	cout << (n - *max_element(all(dp))) << endl;
}

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

int main(){
    string s, t;
    cin >> s >> t;
    ll op[s.size() + 1][t.size() + 1] = {{0}};
    memset(op, 0, sizeof(op));
    for(int i = 1; i <= s.size(); i++){
    	for(int j = 1; j <= t.size(); j++){
    		if(s[i - 1] == t[j - 1])
    			op[i][j] = op[i - 1][j -1] + 1;
    		else
    			op[i][j] = max(op[i - 1][j], op[i][j - 1]);
    	}
    }
    string ans = "";
    ll i = s.size(), j = t.size();
    while(i > 0 && j > 0){
    		if(s[i - 1] == t[j - 1]){
    			ans.push_back(s[i - 1]);
    			i--;
    			j--;
    		}
    		else if(op[i - 1][j] >= op[i][j - 1])
    			i--;
    		else
    			j--;
    	}
  	for(int i = 0; i < ans.size(); i++)
  			cout << ans[ans.size() - 1 - i];
    return 0;
 }

Measured memory_bytes: 73904
#include<stdio.h>

#define MAX 100000

typedef struct{
  char mark;
  int number;
}card;

int partition(card *,int,int);
void quicksort(card *,int,int);
int Stable(card *,card *,int);

int main()
{
  int n,i;
  card A[MAX],in[MAX];

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++)
    {
      scanf(" %c %d",&A[i].mark,&A[i].number);
      in[i] = A[i];
    }
  
  quicksort(A,0,n-1);
  
  if(Stable(in,A,n)) printf("Stable\n");
  else printf("Not stable\n");

  for(i = 0 ; i < n ; i++)
    {    
      printf("%c %d\n",A[i].mark,A[i].number);
    }
  
  return 0;
}

int partition(card *A,int p,int r)
{
  int x,i,j;
  card change;

  x = A[r].number;

  i = p-1;

  for(j = p ; j < r ; j++)
    {
      if(A[j].number <= x)
	{
	  i++;
	  change = A[i];
	  A[i] = A[j];
	  A[j] = change;
	}
    }
  change = A[i+1];
  A[i+1] = A[r];
  A[r] = change;

  return i+1;
}

void quicksort(card *A,int p,int r)
{
  int q;
  if(p < r)
    {
      q = partition(A,p,r);
      quicksort(A,p,q-1);
      quicksort(A,q+1,r);
    }
  return;
}

int Stable(card *in,card *out,int n)
{
  int i,j,a,b;

  for(i = 0 ; i < n-1 ; i++)
    {
      for(a = 0 ; a < n ; a++)
	{
	  if(out[i].number == out[i+1].number)
	    {
	      if(in[a].number == out[i].number)
		{
		  if(in[a].mark == out[i].mark)
		    {
		      in[a].number = -1;
		      break;
		    }
		  else return 0;
		}
	    }
	}
    
    }
  return 1;
}



Measured memory_bytes: 3304
N, M =  map(int, input().split())

count = [0] * M
for n in range(N):
  KA = list(map(int, input().split()))
  for k in range(KA[0]):
    count[KA[k + 1] - 1] += 1

ans = 0
for m in range(M):
  if(count[m] == N):
    ans += 1
print(ans)

Measured memory_bytes: 3060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.InputStream;

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

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextIntArray(n);
            int[] b = in.nextIntArray(n);

            int ans = 0;
            long sum = 0;
            List<Integer> list = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                if (a[i] >= b[i]) {
                    list.add(a[i] - b[i]);
                } else {
                    ans++;
                    sum += b[i] - a[i];
                }
            }

            list.sort(new ReverseComparator<>());

            for (int x : list) {
                if (sum > 0) {
                    ans++;
                    sum -= x;
                }
            }

            out.println(sum > 0 ? -1 : ans);
        }

    }

    static class ReverseComparator<T extends Comparable<T>> implements Comparator<T> {
        public int compare(T o1, T o2) {
            return o2.compareTo(o1);
        }

    }

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

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

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

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

    }
}



Measured memory_bytes: 47716
#include <stdio.h>

int fibonacci(int n){
  int i,a=1,b=1,tmp=1;

  for(i=1;i<n;i++){
    tmp=a+b;
    a=b;
    b=tmp;
  }
  return tmp;
}

main(){
  int n,result;

  scanf("%d",&n);
  if(n>=0 && n<=44){
  result=fibonacci(n);
  }

  printf("%d\n",result);
  return 0;
}

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

int main(){
    ll k; cin >> k;
    ll n=0;
    ll m=1;
    rep(i,k){
        n+=m*7;
        n%=k;
        if(n==0){
            cout << i+1 << endl;
            return 0;
        }
        m*=10;
        m%=k;
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <chrono>
#include <random>
#include <iterator>
#include <numeric>
#include <set>
using namespace std;
typedef long long ll;

int dp[15][200];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(1){
		int n,k,s; cin >> n >> k >> s;
		if(n==0&&k==0&&s==0)break;
		for(int i=0;i<=k;i++){
			for(int j=0;j<=s;j++){
				dp[i][j]=0;
			}
		}
		dp[0][0]=1;
		for(int i=1;i<=n;i++){
			for(int j=s;j>=i;j--){
				for(int l=0;l<k;l++){
					dp[l+1][j]+=dp[l][j-i];
				}
			}
		}
		printf("%d\n",dp[k][s] );
	}
}


Measured memory_bytes: 3080
#include<iostream>
using namespace std;
int n,x,y;
int isP[1000000];
int t[10000],u[10000],ans[10000];
void Prime(){
  for(int i=0;i<1000001;i++)isP[i]=1;
  isP[0]=isP[1]=0;
  for(int i=2;i*i<1000001;i++){
    if(isP[i])for(int j=i*i;j<1000001;j++)isP[j]=0;
  }
}
void init(){
  for(int i=0;i<10000;i++)ans[i]=t[i]=0;
}
int main(){
  Prime();
  while(cin>>n&&n){
    init();
    for(int i=0;i<n-1;i++){
      t[((n-i-1)*(n-i-1))%n]=1;
    }
    x=0;
    for(int i=0;i<10001;i++){
      if(t[i])u[x++]=i;
    }
    for(int i=0;i<x;i++){
      for(int j=0;j<x;j++){
	if(i==j)continue;
	y=u[i]-u[j];
	if(y<0)y+=n;
	if(y>((n-1)/2))y=n-y;
	ans[y]++;
      }
    }
    for(int i=1;i<=(n-1)/2;i++){
      cout<<ans[i]<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 5168
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

long long const MOD = 1000000007LL;

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

    int res;
    double ave = 1000000;
    for (int i = 0; i < n; i++) {
        double h;
        cin >> h;
        if (ave > abs(a - t + 0.006 * h)) {
            ave = abs(a - t + 0.006 * h);
            res = i + 1;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 384
//بسم الله الرحمن الرحيم
///   ***   ---   |||		 In the name of ALLAH		|||   ---   ***   ///
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define el << endl
#define PI 3.141592653589793238
#define _test_ int t; cin >> t; while(t--)
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define file() freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)
ll gcd ( ll  a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }
int dx[]={0,0,+1,-1,+1,-1,-1,+1};
int dy[]={+1,-1,0,0,+1,-1,+1,-1};
///*......................*//* LET'S BEGIN (-_^) *//*............................///
const int mx= 2e5+123;
int n,x,t;

void _case_()
{
    cin >> n >> x >> t;
    (n%x) ? cout << t*(n/x+1) el : cout << t*(n/x) el;
}

int main()
{

    optimize();
    //_test_
      _case_();
    return 0;

}

///////////*  N A Y E M  *///////////

Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
#include<stack>
#include<queue>
#include<map>
#include<set>

using namespace std;

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

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

int main(){
    int n, h, w;
    cin >> n >> h >> w;
    cout << (n-h+1)*(n-w+1) << endl;

}


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

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

	int count = 0;

	if(a > b){
		count += a;
		--a;
	}else{
		count += b;
		--b;
	}

	if(a > b){
		count += a;
	}else{
		count += b;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int x[1000000];
int main() {
	for (int i = 2; i < 1000000; i++) {
		for (int j = 2; j <= sqrt(i); j++) {
			if (i%j == 0) {
				goto E;
			}
		}
		x[i] = 1;
	E:;
	}
	int a, b;
	while (cin >> a) {
		for (int i = a - 1; i >= 0; i--) {
			if (x[i] == 1) { cout << i << ' '; break; }
		}
		for (int i = a + 1; i < 1000000; i++) {
			if (x[i] == 1) { cout << i << endl; break; }
		}
	}
}

Measured memory_bytes: 5064
H, W = map(int, input().split())
s = []
for i in range(H):
  s.append(input())
  
for i in range(H):
  for j in range(W):
    if s[i][j] == "#":
      flag = False
      for x, y in [[1, 0],[-1, 0],[0, 1],[0, -1]]:
        if i + x >= 0 and i + x <= H - 1 and j + y >= 0 and j + y <= W - 1 and s[i + x][j + y] == '#':
          flag = True
      if not flag:
        print('No')
        exit(0)
print('Yes')



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

int main()
{
  int A, B;
  cin >> A >> B;
  
  int counter = 0;
  for (int i = A; i <= B; i++)
  {
    int digits_1 = i / 10000 % 10;
    int digits_2 = i / 1000 % 10;
    int digits_4 = i / 10 % 10;
    int digits_5 = i % 10;
    
    if ((digits_1 == digits_5) && (digits_2 == digits_4))
    {
      counter++;
    }
  }
  
  cout << counter << endl;

  return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end

int mod = 1e9+7;
struct Mint {
    int val;
    Mint inv() const {
        int tmp, a = val, b = mod, x = 1, y = 0;
        while(b) tmp = a / b, a -= tmp * b, swap(a, b), x -= tmp * y, swap(x, y);
        return Mint(x);
    }
public:
    Mint() :val(0) {}
    Mint(ll x) :val(x >= 0 ? x % mod : x % mod + mod) {}
    int mtoi() { return this->val; }
    Mint pow(ll t) { Mint res = 1,b = *this; while(t){if(t&1)res *= b;b *= b;t >>= 1;}return res; }
    Mint& operator+=(const Mint& x) { if ((val += x.val) >= mod) val -= mod; return *this; }
    Mint& operator-=(const Mint& x) { if ((val += mod - x.val) >= mod) val -= mod; return *this; }
    Mint& operator*=(const Mint& x) { val = (ll)val * x.val % mod; return *this; }
    Mint& operator/=(const Mint& x) { return *this *= x.inv(); }
    bool operator==(const Mint& x) const { return val == x.val; }
    bool operator!=(const Mint& x) const { return val != x.val; }
    bool operator<(const Mint& x) const { return val < x.val; }
    bool operator<=(const Mint& x) const { return val <= x.val; }
    bool operator>(const Mint& x) const { return val > x.val; }
    bool operator>=(const Mint& x) const { return val >= x.val; }
    Mint operator+(const Mint& x) const { return Mint(*this) += x; }
    Mint operator-(const Mint& x) const { return Mint(*this) -= x; }
    Mint operator*(const Mint& x) const { return Mint(*this) *= x; }
    Mint operator/(const Mint& x) const { return Mint(*this) /= x; }
};
struct factorial {
    vector<Mint> Fact, Finv;
public:
    factorial(int maxx) {
        Fact.resize(maxx+1,Mint(1)),Finv.resize(maxx+1); rep(i,0,maxx)Fact[i+1]=Fact[i]*Mint(i+1);
        Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*Mint(i);
    }
    Mint fact(int n,bool inv) { if(inv) return Finv[n]; else return Fact[n]; }
    Mint nPr(int n,int r) { if(n<0||n<r||r<0) return Mint(0); else return Fact[n]*Finv[n-r]; }
    Mint nCr(int n,int r) { if(n<0||n<r||r<0) return Mint(0); else return Fact[n]*Finv[r]*Finv[n-r]; }
};

int main(){
    int n; scanf("%d",&n);
    string s,t; cin>>s>>t;
    Mint dp[26]; dp[s[0]-'a']=1;
    rep(i,1,n-1)dp[s[i]-'a']+=dp[t[i]-'a'];
    printf("%d\n",dp[t[n-1]-'a'].mtoi());
    return 0;
}


Measured memory_bytes: 3420