akhauriyash/Code-Regression huggingface dataset:
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{
		ll int n,r;
		cin>>n>>r;
		for(ll int i=0;true;i++)
		{
			ll int rr;
			if(n>=10) rr=i;
			else rr=i-100*(10-n);
			if(rr==r)
			{
				cout<<i<<endl;
				return 0;
			} 
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

    long long N;
    cin >> N;

    long long h, n, w;
	bool flag = false;
    for (long long i = 1; i <= 3500; i++){
        for(long long j = i; j <= 3500; j++){
            long long a = i * j * N;
            long long b = 4 * i * j - N * i - N * j;
            if (b > 0 && a % b == 0){
                h = i;
                n = j;
                w = a / b;
              	flag = true;
                break;
            }
        }
      if(flag ==  true) break;
    }
    
    cout << h << " " << n << " " << w << endl;
    
    

    return 0;
}



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

int main () {
    int s, w;
    cin >> s >> w;
    if (w >= s) cout << "unsafe" << endl;
    else cout << "safe" << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cctype>
#include<string>
using namespace std;

int main(){
    string str1,str2;
    int n;
    int a=0,b=0;

    cin >> n;
    for(int i=0;i<n;i++){
        cin >> str1 >> str2;
        if(str1>str2){
            a += 3;
        }else if(str1==str2){
            a +=1;
            b +=1;
        }else if(str1<str2){
            b += 3;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 3184
def resolve():
    s=input()
    ans=0
    for i in ['+','-']:
        for m in ['+','-']:
            for n in ['+','-']:
                if eval(s[0]+i+s[1]+m+s[2]+n+s[3])==7:
                    ans=s[0]+i+s[1]+m+s[2]+n+s[3]+'=7'
    print(ans)
resolve()

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

int n, k;
double x[60], y[60], c[60], r[60];
double EPS = 1e-9;

double dist(pair<double, double> p, pair<double, double> q) {
	double xx = (p.first - q.first)*(p.first - q.first);
	double yy = (p.second - q.second)*(p.second - q.second);

	return sqrt(xx + yy);
}

vector<pair<double, double>> circle_circle_intersection(double x1, double y1, double r1, double x2, double y2, double r2) {
	vector<pair<double, double>> ans;
	double d = dist(make_pair(x1, y1), make_pair(x2, y2));
	if (d > r1 + r2) {
		return ans;
	}
	if (x1 == x2 && y1 == y2) {
		ans.emplace_back(x1, y1); return ans;
	}
	if (d < abs(r1 - r2)) {
		ans.emplace_back(x1, y1); return ans;
	}

	double a = (r1*r1 - r2*r2 + d*d)/(2*d);
	double h = sqrt(r1*r1 - a*a);

	//cout << d << ' ' << a << ' ' << h << '\n';

	double x3 = (x2 - x1)*(a/d) + x1;
	double y3 = (y2 - y1)*(a/d) + y1;

	ans.emplace_back(x3 + h*(y2 - y1)/d, y3 - h*(x2 - x1)/d);
	ans.emplace_back(x3 - h*(y2 - y1)/d, y3 + h*(x2 - x1)/d);

	return ans;
}

int check(double t) {
	int ans = 0;
	for (int i = 0; i < n; i++) {
		r[i] = t/c[i];
	}

	for (int i = 0; i < n; i++) {
		int cnt = 0;
		pair<double, double> p(x[i], y[i]);
		for (int k = 0; k < n; k++) {
			if (dist(p, make_pair(x[k], y[k])) <= r[k] + EPS) cnt++;
		}
		ans = max(ans, cnt);
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			vector<pair<double, double>> pts = circle_circle_intersection(x[i], y[i], r[i], x[j], y[j], r[j]);
			for (auto p: pts) {
				int cnt = 0;
				//cout << i << ' ' << j << ' ' << p.first << ' ' << p.second << '\n';
				//cout << x[i] << ' ' << y[i] << ' ' << r[i] << '\n';
				//cout << x[j] << ' ' << y[j] << ' ' << r[j] << '\n';
				for (int k = 0; k < n; k++) {
					if (dist(p, make_pair(x[k], y[k])) <= r[k] + EPS) cnt++;
				}
				ans = max(ans, cnt);
			}
		}
	}
	return ans;
}

signed main() {
	ios::sync_with_stdio(0); cin.tie(0);
	//feenableexcept(29);

	cin >> n >> k;
	if (k == 1) {
		cout << "0\n"; exit(0);
	}
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> c[i];
	}

	double lo = 0, hi = 100000000;
	for (int ite = 0; ite < 100; ite++) {
		double mid = (lo + hi)/2;

		if (check(mid) >= k) {
			hi = mid;
		} else {
			lo = mid;
		}
	}
	cout << fixed << setprecision(9) << hi << '\n'; 

	return 0;
}


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

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

	long long all = 0;
	for( int i = 0; i < N; i++ ) {
		if( i == 0 ) all += abs( A[0] );
		else all += abs( A[i] - A[i - 1] );
	}
	all += abs( A[N - 1] );

	for( int i = 0; i < N; i++ ) {
		long long ans = all;
		if( i == 0 ) ans += abs( A[1] ) - abs( A[0] ) - abs( A[1] - A[0] );
		else if( i == N - 1 ) ans += abs( A[N - 2] ) - abs( A[N - 1] ) - abs( A[N - 1] - A[N - 2] );
		else ans += abs( A[i + 1] - A[i - 1] ) - abs( A[i] - A[i - 1] ) - abs( A[i + 1] - A[i] );
		cout << ans << endl;
	}
}


Measured memory_bytes: 3768
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	vector<int>valA;
	vector<int>valZ;
	int stringLength = s.size();
	for(int i=0;i<stringLength;i++)
	{
			if(s[i]=='A')
			{
				valA.push_back(i);
			}
			else if(s[i]=='Z')
			{
					valZ.push_back(i);
			}
	}
	sort(valA.begin(), valA.end());
	sort(valZ.begin(), valZ.end());
	//int sizeA = valA.size();
	int sizeB = valZ.size();
	cout<<valZ[sizeB-1]-valA[0]+1<<"\n";
}


Measured memory_bytes: 1364
n=int(input())
l=[str(input()) for i in range(n)]
flag=0
for i in range(n-1):
    if l[i][-1]!=l[i+1][0]:
        flag=1
        break

s_l=set(l)
if len(l)!=len(s_l):
    flag=1

if flag==1:
    print("No")
else:
    print("Yes")



Measured memory_bytes: 3060
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
typedef long long ll;

using namespace std;


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

Measured memory_bytes: 1024
/*
 * src.cpp
 *
 *  Created on: 2016/07/29
 *      Author: joi
 */

#include <bits/stdc++.h>

using namespace std;

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

const int INF=1e8;

int n,m;
map<string,int> item;
map<string,vector<string> > w;

map<string,bool> flg;

int dfs(string s){
	if (flg[s]){
		return item[s];
	}
	int res=0;
	vector<string> v=w[s];
	flg[s]=true;
	if (v.size()==0){
		res=INF;
	}else{
		REP(i,(int)v.size()){
			res+=dfs(v[i]);
		}
	}
	return item[s]=min(item[s],res);
}

int main(){
	do{
		cin>>n;
		if (n){
			item.clear();
			w.clear();
			flg.clear();
			REP(i,n){
				string s;
				int p;
				cin.ignore();
				cin>>s>>p;
				item[s]=p;
			}
			cin>>m;
			cin.ignore();
			REP(i,m){
				string s;
				cin>>s;
				int k;
				cin>>k;
				REP(j,k){
					string q;
					cin>>q;
					w[s].push_back(q);
				}
			}
			string s;
			cin>>s;
			cout<<dfs(s)<<endl;
		}
	}while(n);
	return 0;
}

Measured memory_bytes: 3096
import java.util.*;
public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int price1 = scanner.nextInt();
        int price2 = scanner.nextInt();
        int price3 = scanner.nextInt();
        long sum = price1 + price2 + price3;
        int max = price1;
        if (price2 > max) {
            max = price2;
        }
        if (price3 > max) {
            max = price3;
        }
        System.out.println(sum - max);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long
#define db long double
#define fi first
#define se second
#define  pb push_back
#define  pob pop_back
#define W while
#define fn(i,x) for(int i=0;i<x;i++)
#define fs(i,s,x) for(int i=s;i<x;i++)
#define fr(i,x) for(int i=x;i>=0;i--)
#define fit(it,s) for(auto it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 1000000007
#define MAX 1005
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

    // freopen("in.txt","r",stdin);
    // freopen("out.txt","w",stdout);
    
    ll a,p;
    cin >> a >> p;
    cout << ((a*3) + p)/2;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    if ((A + B) % 2 == 1) cout << "IMPOSSIBLE" << endl;
    else cout << (A + B) / 2 << endl;
    return 0;
}


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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(int i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(int i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(int i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
ll dp[1000][1000];
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    int h,w;
    cin>>h>>w;
    char grid[h][w];
    rep(i,h)
    {
        rep(j,w) cin>>grid[i][j];
    }
    fill(dp);
    ll counter=0;
    dp[0][0]=1;
    rep(i,h)
    {
        if(grid[i][0]=='#')
        {
            counter=1;
        }
        if(counter==0) dp[i][0]=1;
        else dp[i][0]=0;
    }
    counter=0;
    rep(i,w)
    {
        if(grid[0][i]=='#')
        {
            counter=1;
        }
        if(counter==0) dp[0][i]=1;
        else dp[0][i]=0;
    }
    for(int i=1;i<h;i++)
    {
        for(int j=1;j<w;j++)
        {
            if(grid[i-1][j]=='.' && grid[i][j-1]=='.')
            {
                dp[i][j]=(dp[i-1][j]%INF+dp[i][j-1]%INF)%INF;
            }
            else if(grid[i-1][j]=='#' && grid[i][j-1]=='.')
            {
                dp[i][j]=dp[i][j-1];
            }
            else if(grid[i-1][j]=='.' && grid[i][j-1]=='#')
            {
                dp[i][j]=dp[i-1][j];
            }
            else dp[i][j]=0;
        }
    }
    cout<<dp[h-1][w-1]<<'\n';
    return 0;
}


Measured memory_bytes: 9088
#include <iostream>
#include <algorithm>
#include<functional>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
int main() {
	int N, M;
	long long dp[100020] = {0};
	cin >> N >> M;
	for (int i = 0; i < 100020; i++) {
		dp[i] = 1;
	}
 
	for (int i = 0; i < M; i++) {
		int a;
		cin >> a;
		dp[a] = 0;
	}
 
	if (N == 1) {
		cout << dp[1];
	}
	else {
		for (int i = 2; i < N + 1; i++) {
			if (dp[i] == 0) {
				dp[i] = 0;
			}
			else {
				dp[i] = dp[i - 1] + dp[i - 2];
				dp[i] %= 1000000007;
			}
		}
		cout << dp[N];
	}
}

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

int main(){

    int N;
    string S;
    cin >> N;
    cin >> S;

    int d[100], min = 0;

    if( S[0] == '(' ) d[0] = 1;
    else if( S[0] == ')' ) d[0] = - 1;
    

    for( int i = 1; i < N; i++ ){
        if( S[i] == '(' ){
            d[i] = d[i-1] + 1;
        }
        if( S[i] == ')' ){
            d[i] = d[i-1] - 1;
        }
    }

    for( int i = 0; i < N; i++ ){
        if( min > d[i] ) min = d[i];
    }

    for( int i = 0; i < - min; i++ ) cout << "(";
    cout << S;
    for( int i = 0; i < d[N-1] - min; i++ ) cout << ")";
    cout << endl;

    return 0;

}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;

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


void Main()
{
	double a,b,x;
	cin>>a>>b>>x;
	x = x/a;

	if(a*b/2 >= x){
		cout << atan(b*b/x/2) * 180 / PI << endl;
	}
	else{
		cout << 90-(atan(a*a/(2*(a*b-x))) * 180 / PI) << endl;
	}


	
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 256
s=str(input())
ans=0
for i in range(len(s)):
  if s[i] in "ACGT":
    count=0
    for j in range(i,len(s)):
      if s[j] in "ACGT":
        count+=1
      else:
        break
    ans=max(ans,count)
print(ans)


Measured memory_bytes: 38384
#include <stdio.h>
#include <string.h>
#define N 1001
int kongetsu[N], sengetsu[N];
int main(void)
{
    char buf[256];
    int i;
    while (strcmp(fgets(buf, 256, stdin), "\n")) {
        int a, b;
        sscanf(buf, "%d,%d", &a, &b);
        sengetsu[a]++;
    }
    while (fgets(buf, 256, stdin)) {
        int a, b;
        sscanf(buf, "%d,%d", &a, &b);
        kongetsu[a]++;
    }
    for (i=0; i<N; ++i) {
        if (sengetsu[i] && kongetsu[i])
            printf("%d %d\n", i, sengetsu[i]+kongetsu[i]);
    }
    return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#define maxn 60
using namespace std;
int n,m;
char a[maxn][maxn],b[maxn][maxn];
int main() {
	scanf("%d %d",&n,&m);
	for (int i=0;i<n;i++)
		scanf("%s",a[i]);
	for (int i=0;i<m;i++)
		scanf("%s",b[i]);
	bool t=false;
	for (int i=0;i<n-m+1;i++) {
		for (int j=0;j<n-m+1;j++) {
			bool t1=true;
			for (int k=i;k<=i+m-1;k++) {
				for (int l=j;l<=j+m-1;l++) {
					if (a[k][l]!=b[k-i][l-j]) {
						t1=false;
						break;
					}
				}
				if (!t1)
					break;
			}
			if (t1) {
				t=true;
				break;
			}
		}
		if (t)
			break;
	}
	if (t)
		printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	static long dist[][];
	static int R;
	static boolean used[];
	static int r[];
	static long ans = Long.MAX_VALUE;

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");
		int N = Integer.parseInt(str[0]);
		int M = Integer.parseInt(str[1]);
		R = Integer.parseInt(str[2]);

		long edge[][] = new long[N][N];

		for (int i = 0; i < N; i++) {
			Arrays.fill(edge[i], Long.MAX_VALUE);
		}

		used = new boolean[N];

		r = new int[R];
		str = br.readLine().split(" ");
		for (int i = 0; i < R; i++) {
			r[i] = Integer.parseInt(str[i]) - 1;
		}

		for (int i = 0; i < M; i++) {
			str = br.readLine().split(" ");
			int a = Integer.parseInt(str[0]) - 1;
			int b = Integer.parseInt(str[1]) - 1;
			int c = Integer.parseInt(str[2]);

			edge[a][b] = c;
			edge[b][a] = c;
		}
		dist = wf(edge, N);
		for (int i : r) {
			used[i] = true;
			dfs(i, 0, 1);
			used[i] = false;
		}
		System.out.println(ans);
	}

	static long[][] wf(long edge[][], int n) {
		long dp[][] = edge;

		for (int k = 0; k < n; k++) {
			for (int i = 0; i < n; i++) {
				if (dp[i][k] == Long.MAX_VALUE)
					continue;
				for (int j = 0; j < n; j++) {
					if (dp[k][j] == Long.MAX_VALUE)
						continue;
					dp[i][j] = Math.min(dp[i][j], dp[i][k] + dp[k][j]);
				}
			}
		}
		return dp;
	}

	static void dfs(int now, long cost, int depth) {
		if (depth == R) {
			ans = Math.min(ans, cost);
		} else {
			for (int i : r) {
				if (!used[i]) {
					used[i] = true;
					dfs(i, cost + dist[now][i], depth + 1);
					used[i] = false;
				}
			}
		}
	}
}

class Edge implements Comparable<Edge> {
	int to;
	int cost;

	public Edge(int to, int cost) {
		this.to = to;
		this.cost = cost;
	}

	public int compareTo(Edge e) {
		return this.cost - e.cost;
	}
}

Measured memory_bytes: 31440
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

void solve (set<string> &orders, string header, map<char, vector<int>> &candidates, string &base, int n, int k)
{
	for (auto &candidate : candidates)
	{
		auto &v = candidate.second;

		orders.insert(header + candidate.first);
		if (k <= orders.size()) break;

		map<char, vector<int>> candy;
		for (auto i : v)
		{
			if (i+1 < n) candy[base[i+1]].push_back(i+1);
		}

		solve(orders, header + candidate.first, candy, base, n, k);
	}

	return;
}
int main ()
{
	string s;
	cin >> s;
	int n = s.size();

	int k;
	cin >> k;

	map<char, vector<int>> candidates;
	for (int i=0; i<n; ++i)
	{
		candidates[s[i]].push_back(i);
	}
	set<string> orders;

	solve(orders, "", candidates, s, n, k);

	for (auto sub : orders)
	{
		if (0 == --k)
		{
			cout << sub << endl;
			break;
		}
	}

	
	return 0;
}

Measured memory_bytes: 384
# -*- coding:utf-8 -*-
import sys
N, M = map(int, input().split())
A = [ 0 for tmp in range(N) ]
B = [ 0 for tmp in range(N) ]
for tmp in range(M):
    a, b = map(int, input().split())
    if a == N or b == N:
        c = a if a != N else b
        B[c-1] = 1
    if a == 1 or b == 1:
        c = a if a != 1 else b
        A[c-1] = 1

for tmp in range(N):
    if A[tmp] and B[tmp]:
        print('POSSIBLE')
        sys.exit()
print('IMPOSSIBLE')

Measured memory_bytes: 6320
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
int main(void) {
    ll n,k;
    cin>>n>>k;
    ll a[n];
    rep(i,n){cin>>a[i];}
    ll sum=0;
    rep(i,n){sum+=a[i];}
    vector<int> divs;
    rep(i,int(sqrt(sum))+1){
        if(sum%(i+1)==0){
            divs.push_back((i+1));
            divs.push_back(sum/(i+1));
        }
    }
    sort(divs.begin(),divs.end(),greater<int>());
    DEBUG{
        rep(i,divs.size()){
            cout << divs[i] << endl;
        }
    }
    for(auto x:divs){
        ll amari[n]={};
        ll cumsum[n+1]={};
        ll cumsum2[n+1]={};
        rep(i,n){
            cumsum[i]=cumsum2[i]=0;
        }
        rep(i,n){
            amari[i]=a[i]%x;
        }
        sort(amari,amari+n);
        rep(i,n){
            cumsum[i+1]=cumsum[i]+amari[i];
            cumsum2[i+1]=cumsum2[i]+(amari[i]==0 ? 0 : x-amari[i]);
        }
        DEBUG{
            rep(i,n+1){
                cout << cumsum[i] << " ";
            }
            cout << endl;
            rep(i,n+1){
                cout << cumsum2[i] << " ";
            }
            cout << endl;
        }
        rep(i,n){
            if(cumsum[i]==cumsum2[n]-cumsum2[i]&&cumsum[i]<=k){
                cout << x << endl;
                return 0;
            }
        }
    }
    cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#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 all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
#define vcin(a) for(int i=0;i<(a).size();i++) cin>>(a)[i];

int main()
{
    int N;
    cin >> N;
    vint A(N);
    ll sum = 0;
    rep(i, N)
    {
        cin >> A[i];
        A[i] -= (i+1);
        sum += A[i];
    }
    sort(all(A));
    ll b = A[N/2],c=A[N/2+1];
    ll sum1 = 0, sum2 = 0;
    rep(i, N)
    {
        sum1 += abs(A[i] - (b));
        sum2 += abs(A[i] - (c));
    }
    cout << min({sum1, sum2});
    return 0;
}

Measured memory_bytes: 1024
def f():
    h, w, n = map(int, input().split())
    md = 10 ** 9 + 7
    k = [list(map(int, input().split())) for _ in range(n)] + [[h, w]]

    # 壁をマンハッタン距離順に
    k.sort(key=lambda x: x[0] + x[1])

    # 階乗と逆元とコンビネーションを事前準備
    fct = [1] * (h + w + 1)
    re_fct = [1] * (h + w + 1)
    fct_i = 1
    for i in range(1, h + w + 1):
        fct_i = fct_i * i % md
        fct[i] = fct_i
    # fct_i**(md-2)が逆元re_i
    re_i = pow(fct_i, md - 2, md)
    for i in range(h + w, 1, -1):
        re_fct[i] = re_i
        re_i = re_i * i % md
    cmb = lambda a, b: fct[a] * re_fct[b] * re_fct[a - b] % md

    # こっから本体
    dp = [0] * (n + 1)
    for i, [r, c] in enumerate(k):
        dpi = cmb(r + c - 2, r - 1) % md
        for j in range(i):
            dr, dc = r - k[j][0], c - k[j][1]
            if dr >= 0 and dc >= 0:
                dpi = (dpi - dp[j] * cmb(dr + dc, dr)) % md
        dp[i] = dpi
    print(dp[-1])


f()


Measured memory_bytes: 50392
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int ans=0;
  int N;
  cin >> N;
  int L[N];
  for(int i=0;i<N;i++){
    cin >> L[i];
  }
  sort(L,L+N);
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      for(int k=j+1;k<N;k++){
        if(L[i]!=L[j] && L[j]!=L[k] && L[k]!=L[i] && L[i]+L[j]>L[k]){
          ans++;
        }
      }
    }
  }
cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
long long x, curr(100);
int main() {
    DAU
    cin >> x;
    for (int i = 1 ;; ++i) {
        curr += curr / 100;
        if (curr >= x) {
            cout << i;
            PLEC
        }
    }
    PLEC
}


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

#define ll long long
#define mx  100005
#define mod 1000000009
#define lim 10000000
#define inf 1e9
#define N 18
using namespace std;


int main(){
	ios_base::sync_with_stdio(false);
     int a,b;cin>>a>>b;
     a--,b--;
     cout<<a*b<<"\n";
	return 0;
}


Measured memory_bytes: 256
A,B,C,D,E,F = gets.split.map(&:to_i)

rmax = 0
ans = []

0.upto(F/(100*A)) do |a|
  0.upto((F/100 - A*a)/B) do |b|
    next if a == 0 && b == 0
    mw = 100*(A*a + B*b)
    0.upto((F-mw)/C) do |c|
      0.upto((F-mw-C*c)/D) do |d|
        ms = C*c + D*d
        r = (100.0 * ms) / (mw + ms)
        if r <= 100.0*E/(100+E) && r >= rmax
          ans = [mw + ms, ms]
          rmax = r
        end
      end
    end
  end
end

puts ans.join(" ")


Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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;
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
ll dp[10010];

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    int N; cin >> N;
    vector<ll> A(N);
    REP(i,N) cin >> A[i];

    sort(A.begin(), A.end());
    REP(i,N-1){
        if(A[i]==A[i+1]){
            cout << "NO" << endl;
            return 0;
        }
    }

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


Measured memory_bytes: 1792
use std::io;
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    n.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    n.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let v: Vec<usize> = read_vec();
    let n = v[0];
    let m = v[1];
    let mut a = vec![vec![0; m]; n];
    let mut b = vec![0; m];
    for i in 0..n {
        let c: Vec<usize> = read_vec();
        for j in 0..m {
            a[i][j] = c[j];
        }
    }
    for i in 0..m {
        b[i] = read();
    }
    for i in 0..n {
        let mut sum = 0;
        for j in 0..m {
            sum += a[i][j] * b[j];
        }
        println!("{}", sum);
    }
}



Measured memory_bytes: 5048
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
bool check(vector<int>a){
  if(a[0]!=(int)a.size()) return false;
  rep(i,1,a.size()){
    if(a[i]!=a[i-1] ) return false;
  }
  return true;
}
void solve(vector<int>&a ,int n,int k){
  if(k<=0) return ;
  if(check(a)) return;
  vector<int> pre(n,0);
  rep(i,0,n){
    pre[max(i-a[i],0)]++;
    if(min(n-1,i+a[i])+1<n) pre[min(n-1,i+a[i])+1]--;
  }
  rep(i,1,n){
    pre[i]+=pre[i-1];
  }
  rep(i,0,n) a[i]=pre[i];
  k--;
  solve(a,n,k);
}
int main(){
    optimizeIO();
    int n,k;
    cin>>n>>k;
    std::vector<int>a(n);
    rep(i,0,n) cin>>a[i];
    solve(a,n,k);
    rep(i,0,n) cout<<a[i]<<" ";
    cout<<endl;
}


Measured memory_bytes: 36852
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
#include <bitset>
typedef long long ll;
typedef long double ld;
#define PI  3.14159265358979323846

#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
    string N;
    cin >> N;
    if (N[0]=='7'||
        N[1]=='7'||
        N[2]=='7') {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

ll dp[105][10101];

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

    ll N, W;
    cin >> N >> W;
    vector<ll> v(N), w(N);
    REP(i, N) cin >> v[i] >> w[i];

    // chodo との違いは初期化の仕方．dp[0][i] を全て0にすると「重みw以下で〜」になる
    REP(i, N){
    	REP(j, 10101){
    		dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
    		if(j+w[i]<10101) dp[i+1][j+w[i]] = max(dp[i+1][j+w[i]], dp[i][j]+v[i]);
    	}
    }

    /*
    REP(i, N+1){
    	REP(j, W+1){
    		cout << dp[i][j] << " ";
    	}
    	cout << endl;
    }
    */

    cout << dp[N][W] << endl;
    return 0;
}


Measured memory_bytes: 11060
from collections import deque
from collections import defaultdict

N,M=map(int,raw_input().split())
nl=[ [] for i in range(N+1) ]
cost={}

for i in range(M):
	L,R,D=map(int,raw_input().split())
	if i==0:start=L
	nl[L].append(R)
	nl[R].append(L)
	cost[(L,R)]=D
	cost[(R,L)]=-D


d=[ None for i in range(N+1) ]
V=[ 0 for i in range(N+1) ]

def dfs(start):
	q = deque([]) 
	V[start]=1
	d[start]=0
	q.append(start)

	while len(q)!=0:
		v=q.pop()
		for i in nl[v]:
			if V[i]!=1:
				V[i]=1
				q.append(i)
				d[i]=d[v]+cost[(v,i)]
			else:
				if d[i]-d[v]!=cost[(v,i)]:
					print "No"
					quit()

for i in range(1,N+1):
	if V[i]==0:
		dfs(i)
else:
	print "Yes"




Measured memory_bytes: 100892
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  string w[4] = {"dreamer","dream","eraser","erase"};
  cin >> S;
  bool flag[100000] = {0};
  for(int p = 0;p < 4;p++){
    for(int i = 0;i <= S.size() - w[p].size();i++){
      string g;
      for(int j = 0;j < w[p].size();j++){
	g += S[i + j];
      }
      if(g == w[p]){
	for(int j = 0;j < w[p].size();j++){
	  flag[i + j] = true;
	}
      }
    }
  }
  int sum = 0;
  for(int i = 0;i < S.size();i++){
    sum += flag[i];
  }
  if(sum == S.size()){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


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

#define pb push_back
#define ll unsigned long long
#define maxn 100005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define F first
#define S second
const ll mod = 998244353;
    
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m, l;
    cin >> n >> m >> l;
    ll d[n][n] = {};
    memset(d, 0x3f, sizeof(d));
    f (m) {
        int x, y, dd;
        cin >> x >> y >> dd;
        x--, y--;
        d[x][y] = d[y][x] = min(d[x][y], (ll)dd);
    }
    f(n) {
        fr(j,0,n) {
            fr(k,0,n) {
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
            }
        }
    }
    f(n) {
        fr(j,0,n) {
            if (d[i][j] <= l) {
                d[i][j] = 1;
            }
            else {
                d[i][j] = 1e9;
            }
        }
    }
    f(n) {
        fr(j,0,n) {
            fr(k,0,n) {
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
            }
        }
    }
    int q;
    cin >> q;
    while (q--) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        if (d[x][y] > n) {
            cout << -1 << '\n';
        }
        else {
            cout << d[x][y] - 1 << '\n';
        }
    }
}

Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>

using namespace std;
#define REP(i,m,n) for(int i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

vector<int>v{ 0,0,0 };

int main() {
	int q;
	cin >> q;
	REP(i, 3, 110000) {
		if (i % 2 == 0) {
			v.push_back(v[i - 1]);
		}
		else {
			bool prime = true;
			int p = i;
			for (int j = 2; j*j <= p; j++) {
				if (p%j == 0) {
					prime = false;
					break;
				}
			}
			p = (p + 1) / 2;
			for (int j = 2; j*j <= p; j++) {
				if (p%j == 0) {
					prime = false;
					break;
				}
			}
			if (prime == true) {
				v.push_back(v[i - 1] + 1);
			}
			else {
				v.push_back(v[i - 1]);
			}

		}	
	}
	REP(i, 0, q) {
		int a, b;
		cin >> a >> b;
		int ans = v[b] - v[a - 1];
		printf("%d\n", ans);
	}
	return 0;
}

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

int main() {
  string s;
  int a;
  cin >> a >> s;
  cout << (a >= 3200 ? s : "red") << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <stack>
#include <bitset>
#include <set>
#include <list>
#include <deque>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = 4.0*atan(1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f;
const int NINF = -INF -1;
const int N=510;
int gcd(int a,int b)
{
    return (!b)?a:gcd(b,a%b);
}
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    int tem=0;
    int g;
    bool fla=0;
    int maxn=0;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&g);
        if(g==k)
            fla=1;
        if(g>maxn)
            maxn=g;
        g=gcd(g,tem);
        tem=g;
    }
    if(maxn<k)
       printf("IMPOSSIBLE\n");
    else if((maxn-k)%g==0)
        printf("POSSIBLE\n");
    else
        printf("IMPOSSIBLE\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define at(x,i) get<i>(x);
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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(){
    while(true){
        ll n;cin >> n;
        if(!n)break;
        vl v(n);
        rep(i,n)cin >> v[i];
        vvl dp(n,vl(n,0));
        rep(j,n){
            perl(i,j+1,0){
                if(j-i==0)continue;
                if(j-i==1){
                    if(abs(v[i]-v[j])<=1)dp[i][j]=2;
                    continue;
                }
                if(dp[i+1][j-1]==j-i-1&&abs(v[i]-v[j])<=1)dp[i][j]=dp[i+1][j-1]+2;
                rep(k,j-i){
                    chmax(dp[i][j],dp[i][i+k]+dp[i+k+1][j]);
                }
            }
        }
        cout << dp[0][n-1] <<endl;
    }
}



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

int main(){
    int H, W;
    cin >> H >> W;
    char a[1000][1000];
    
    for(int i=0; i<H+2; i++){
        for(int j=0; j<W+2; j++){
            a[i][j] = '#';
        }
    }
    
    for(int i=1; i<H+1; i++){
        for(int j=1; j<W+1; j++){
            cin >> a[i][j];
        }
    }
    for(int i=0; i<H+2; i++){
        for(int j=0; j<W+2; j++){
            cout << a[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 384
s=input()
x=int(s[:2])
y=int(s[2:])
if 0<x<=12 and 0<y<=12:
    print("AMBIGUOUS")
elif 0<x<=12:
    print("MMYY")
elif 0<y<=12:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 38256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner in=new Scanner(System.in);
    int n=in.nextInt();
    int[] a=new int[n];
    int[] b=new int[n];
    int[] c=new int[n-1];
    for(int i=0;i<n;i++){
      a[i]=in.nextInt()-1;
    }
    for(int i=0;i<n;i++){
      b[i]=in.nextInt();
    }
    for(int i=0;i<n-1;i++){
      c[i]=in.nextInt();
    }
    int tmp=a[0];
    int res=b[tmp];
    
    for(int i=1;i<n;i++){
      res+=b[a[i]];
      res+=(tmp+1==a[i])?c[tmp]:0;
      tmp=a[i];
    }
    System.out.println(res);
  }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int N, K;
    std::cin >> N >> K;

    if (N % K == 0) {
        std::cout << 0 << std::endl;
    } else {
        std::cout << 1 << std::endl;
    }
    return 0;
}

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

int main() {
	string s, t;
	cin >> s >> t;
	int dp[3010][3010] = { 0 };
	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < t.size(); j++) {
			if (s[i] == t[j]) {
				dp[i + 1][j + 1] = max(dp[i][j] + 1, dp[i + 1][j + 1]);
			}
			dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j]);
			dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1]);
		}
	}
	string ans = "";
	int i = (int)s.size(), j = (int)t.size();
	while (i > 0 && j > 0) {
		if (dp[i][j] == dp[i - 1][j]) {
			i--;
		}
		else if (dp[i][j] == dp[i][j - 1]) {
			j--;
		}
		else {
			ans = s[i - 1] + ans;
			i--, j--;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 35712
import java.util.Scanner;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int d = scan.nextInt();
        int counter = 0;
        int[] array = new int[n*2];
        for(int a=0; a<n*2; a=a+2){
            array[a] = scan.nextInt();
            array[a+1] = scan.nextInt();
            if(Math.sqrt(Math.pow(array[a],2)+Math.pow(array[a+1],2))<=d){
                counter++;
            }
        }
        System.out.println(counter);
        scan.close();
    }
}

Measured memory_bytes: 51560
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {

    ll n,y;
    cin >> n >> y; 
    y /= 1000;
    rep(i, n+1) {
        rep(j, n+1-i) {
            ll k = n-i-j;
            ll en = 10 * i + 5 * j + k;
            if(en==y) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl; 
    return 0;
}


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

typedef complex<double> P;


P f(int W,int H,int t){
	if( t <= W-1 ) return P(t,0);
	else if( t <= W + H - 2 ) return P(W-1,0) + P(0,t-(W-1));
	else return P(W-1 - ( t - (W + H - 2) ),H-1);
}


int main(){
	int W,H;
	cin >> W >> H;
	int t[2] = {};
	int N;
	cin >> N;
	int ans = 0;
	for(int i = 0 ; i < N ; i++){
		int x;
		cin >> x;
		t[x]++;
		P A = f(W,H,t[0]);
		P B = f(W-1,H-2,t[1]) + P(0,1);
		//cout << A << " " << B << endl;
		if( fabs(abs(A-B)-1) < 1e-9 )	ans++;
	}
	cout << ans << endl;
}

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

using namespace std;

int main() {

    string s;

    while(cin >> s) {

        for(int i = 0; i < s.size(); ++i) {
            if(s[i] == '@') {
                for(int j = 0; j < s[i + 1] - '0'; ++j) {
                    cout << s[i + 2];
                }
                i += 2;
            } else {
                cout << s[i];
            }
        }

        cout << endl;

    }

}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

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

  vector<vector<int>>dp(N,vector<int>(2,0));
  dp[0][0]=A[0][0];
  for(int i=0;i<N;i++){
    for(int j=0;j<2;j++){
      if(i==0&&j==0)continue;
      if(i-1>=0)dp[i][j]=max(dp[i][j],dp[i-1][j]+A[i][j]);
      if(j-1>=0)dp[i][j]=max(dp[i][j],dp[i][j-1]+A[i][j]);
    }
  }
  cout<<dp[N-1][1]<<endl;
  return 0;
}


Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

V<ll> z_algo(const string &S) {
    V<ll> ret(S.size());
    ll c = 0;
    for(ll i = 1; i < S.size(); i++) {
        if(i + ret[i - c] < c + ret[c]) {
            ret[i] = ret[i - c];
        } else {
            ll j = max<ll>(0, c + ret[c] - i);
            for(; i + j < S.size() && S[j] == S[i + j]; j++);
            ret[i] = j;
            c = i;
        }
    }
    ret[0] = S.size();
    return ret;
}

int main() {
    ll N;
    string S;
    cin >> N >> S;
    ll ans = 0;
    for(ll i = 0; i < S.size(); i++) {
        string SS = S.substr(i);
        auto z_res = z_algo(SS);
        DEBUG(SS, z_res);
        for(ll j = 0; j < SS.size(); j++) {
            ll val = z_res[j];
            chmax(ans, min(val, j));
        }
    }
    cout << ans << endl;
    return 0;
}


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

int k, mod;

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


Measured memory_bytes: 3632