akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007
#define INF 1e9

//vector<vector<pii>> G(100);

void search(vvi &use,set<pii> &st,int i,int j){
  pii P(i,j);
  if(st.count(P)) return;
  if(use.at(i).at(j) == -1){
    st.insert(P);
    return;
  }
  int k = use.at(i).at(j);
  search(use,st,i,k);
  search(use,st,k,j);
}

int main(){
  int n,m;
  cin >> n >> m;
  vector<pii> data(m);
  vvi dis(n,vi(n,INF));
  vvi use(n,vi(n,-1));
  rep(i,n) dis.at(i).at(i) = 0;
  
  rep(i,m){
    int a,b,c;
    cin >> a >> b >> c;
    dis.at(a-1).at(b-1) = c;
    dis.at(b-1).at(a-1) = c;
    //G.at(a-1).push_back(pii(b-1,c));
    //G.at(b-1).push_back(pii(a-1,c));
    data.at(i) = pii(a-1,b-1);
  }
  rep(k,n){
    rep(i,n){
      rep(j,n){
        if(dis.at(i).at(j) > dis.at(i).at(k) + dis.at(k).at(j)){
          dis.at(i).at(j) = dis.at(i).at(k) + dis.at(k).at(j);
          use.at(i).at(j) = k;
        }
      }
    }
  }
  
  set<pii> st;
  rep(i,n){
    rep(j,n){
      if(i == j)continue;
      search(use,st,i,j);
    }
  }
  int ans = 0;
  rep(i,m){
    pii P = data.at(i);
    if(!st.count(P)) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl

signed main(){
    int m,f,b;
    cin >> m >> f >> b;
    if(m+f<b){
        cout << "NA" << endl;
    }else{
        cout << max(0LL,b-m) << endl;
    }
    return 0;
}   


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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define all(a) (a.begin(), a.end())

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

int N;

void solve() {
	cin >> N;
	int i = N;
	for (; true; ++i) {
		bool fl = true;
		int t = i;
		int d = t%10;
		t /= 10;
		while (t) {
			if (t%10 != d) {
				fl = false;
				break;
			}
			d %= 10;
			t /= 10;
		}
		if (fl) {
			cout << i << '\n';
			return;
		}
	}
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

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

const long long MAX_A = std::pow(10, 12);
const long long MAX_B = std::pow(10, 12);
const long long MAX_K = std::pow(10, 12);

long long A, B, K;
long long out_A, out_B;

int main() {
    std::cin >> A >> B >> K;
    if (K < A) {
        out_A = A - K;
        out_B = B;
    } else if (A <= K &&  K < (A + B)) {
        out_A = 0;
        out_B = A + B - K;
    } else if ((A + B) <= K) {
        out_A = 0;
        out_B = 0;
    }
    std:: cout << out_A << " " << out_B;
    return 0;
}

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

int main() {
  int a[3], r = 0;
  rep(i, 3) cin >> a[i];
  sort(a, a + 3);
  if ((a[1] - a[0]) % 2 == 1) {
    a[2]++;
    a[0]++;
    r++;
  }
  r += ((a[1] - a[0]) / 2);
  r += (a[2] - a[1]);
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {

    static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}

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

        BigDecimal A = BigDecimal.valueOf(sc.nextLong());
        BigDecimal B = BigDecimal.valueOf(sc.nextDouble());

        System.out.println(A.multiply(B).divide(BigDecimal.valueOf(1),0,BigDecimal.ROUND_FLOOR));


    }

}


Measured memory_bytes: 37736
n = int(input())
A = list(map(int, input().split()))

M = max(A)
m = min(A)
for i, a in enumerate(A):
    if a == M:
        max_id = i
    if a == m:
        min_id = i

ans = []
if m >= 0:
    for i in range(n-1):
        ans.append((i+1, i+2))
elif M <= 0:
    for i in reversed(range(1, n)):
        ans.append((i+1, i))
else:
    if abs(M) >= abs(m):
        for i, a in enumerate(A):
            if a < 0:
                ans.append((max_id+1, i+1))
        for i in range(n-1):
            ans.append((i+1, i+2))
    else:
        for i, a in enumerate(A):
            if a > 0:
                ans.append((min_id+1, i+1))
        for i in reversed(range(1, n)):
            ans.append((i+1, i))
print(len(ans))
for i in range(len(ans)):
    print(*ans[i])


Measured memory_bytes: 9172
//

fun main() {
    abc080c()
}

fun abc080c() {
    val n = readLine()!!.toInt()
    val schedule = List(n) { mutableSetOf<Int>() }
    val profit = mutableListOf<LongArray>()
    for (i in 0 until n) {
        for ((index, isOpen) in readLine()!!.split(" ").map { it == "1" }.withIndex()) {
            // 月曜午前＝0 .. 金曜午後＝9
            if (isOpen) schedule[i].add(index)
        }
    }
    for (i in 0 until n) {
        val p = readLine()!!.split(" ").map { it.toLong() }.toLongArray()
        profit.add(p)
    }
    val pattern = mutableListOf<Set<Int>>()
    generatePattern(0, mutableSetOf<Int>(), pattern)
    var maxValue = Long.MIN_VALUE
    for (p in pattern) {
        var value = 0L
        for (i in 0 until n) {
            val count = schedule[i].intersect(p).count()
            value += profit[i][count]
        }
        if (value > maxValue) maxValue = value
    }
    println(maxValue)
}

private fun generatePattern(index: Int, current: MutableSet<Int>, pattern: MutableList<Set<Int>>) {
    if (index == 10) {
        if (current.isNotEmpty()) pattern.add(current)
        return
    }
    generatePattern(index + 1, current, pattern)
    // このやり方だとMutableSetのインスタンスがおなじになって全部同じ結果になってしまう
    // deep copyして別インスタンスに分岐してやらないと結果がおかしくなる
    val c = mutableSetOf<Int>()
    c.addAll(current)
    c.add(index)
    generatePattern(index + 1, c, pattern)
}

Measured memory_bytes: 57020
#include "bits/stdc++.h"
using namespace std;

int main() {
	int n,m;
	while (cin >> n >> m) {
		if (!n)break;
		vector<int>t(n);
		vector<int>h(m);
		int in, ts = 0, hs = 0;
		for (int i = 0; i < n; ++i) {
			cin >> in;
			t[i] = in;
			ts += in;
		}
		for (int i = 0; i < m; ++i) {
			cin >> in;
			h[i] = in;
			hs += in;
		}
		//	sort(t.begin(), t.end());
		//	sort(h.begin(), h.end());
		int mi = 201, f = 0;
		int nt = 0, nh = 0;
		int ans[2];
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < m; ++j) {
				nt = ts - t[i] + h[j];
				nh = hs - h[j] + t[i];
				if (nt == nh) {
					if (t[i] + h[j] < mi) {
						ans[0] = t[i];
						ans[1] = h[j];
						mi = t[i] + h[j];
						f = 1;
					}
				}

			}
		}
		if (f)cout << ans[0] << " " << ans[1] << endl;
		else cout << -1 << endl;
	}
	return 0;
}


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

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

    int64_t time = n / (a + b);

    int64_t count = time * a;
    if (n - time * (a + b) <= a){
        count += n - time * (a + b);
    }
    else{
        count += a;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
l = map(int, raw_input().split())
if len(l) == 2:
    a = l[0]; b = l[1]
else:
    a = l[0]; b = input()
p = map(int, raw_input().split())
q = map(int, raw_input().split())
ans = 0
for i in range(a):
    if b - i <= ans: break
    j = 0; k = i
    cnt = 0
    while 1:
        if p[j] == q[k]:
            cnt += 1; j += 1; k += 1
        else: j += 1
        if j == a: break
    ans = max(ans, cnt)
print ans

Measured memory_bytes: 6780
def c(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N,K = [int(i) for i in input().split()]
for i in range(1,K+1):
    num1 = c(K-1,i-1,mod)
    num2 = c(N-K+1,i,mod)
    ans = (num1*num2) % (10**9+7)
    print(ans)

Measured memory_bytes: 4584
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);
#define rad2deg(a) ((a)/M_PI * 180.0)
#define deg2rad(a) ((a)/180.0 * M_PI)
const std::string yes = "Yes";
const std::string no  = "No";

int solve(int n){
    int ret=0;
    while(n>0){
        ret += n%10;
        n /= 10;
    }
    return ret;
}

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

    int ans = 0;
    for(int i=1; i<=n; i++){
        int buf = solve(i);
        if(a<=buf && buf<=b) ans += i;
    }
    std::cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, a[10005], t, ac;
bool com[10005];
void gcd(int &a, int b){
	if(a < b) swap(a,b);
	while(b){
		a %= b;
		swap(a,b);
	}
}
int main(){
	scanf("%d", &n);
	rep(i,n+1){
		scanf("%d", a+i);
		gcd(ac,abs(a[i]));
	}
	for(int p = 2; p <= n; p++) if(!com[p]){
		bool ok = a[n] % p == 0;
		rep(i,p-1){
			long long tmp = 0;
			for(int j = i; j < n; j += p-1) tmp += a[j];
			if(tmp % p) ok = false;
		}
		if(ok) printf("%d\n", p);
		for(int t = p*p; t <= n; t += p) com[t] = true;
	}
	for(int p = 2; p*p <= ac; p++) if(ac % p == 0){
		if(n < p) printf("%d\n", p);
		while(ac % p == 0) ac /= p;
	}
	if(ac != 1 && n < ac) printf("%d\n", ac);
}

Measured memory_bytes: 256
n, x = map(int, input().split())
m = 2*n-1

if n==2 and x==2:
    print("Yes")
    print("1\n2\n3")
elif x==1 or x==m:
    print("No")
else:
    if x < n:
        print("Yes")
        base = [str(i) for i in [m, x, 1, m-1]]
        ans = [str(i) for i in range(2, n) if i!=x] + base + [str(i) for i in range(n, m-1)]
        print("\n".join(ans))
    else:
        print("Yes")
        base = [str(i) for i in [1, x, m, 2]]
        ans = [str(i) for i in range(3, n)] + base + [str(i) for i in range(n, m) if i!=x]
        print("\n".join(ans))


Measured memory_bytes: 20236
#include <iostream>
#include <algorithm>
#define INF 1e+9
using namespace std;

int main(){
	int n,m,p,d[20010],mi = INF,pos = 0;
	cin >> n >> m >> p;
	for(int i = 0;i < m;i++) cin >> d[i];
	d[m++] = p;
	sort(d,d + m);
	for(int i = 0;i <= m;i++) d[i + m] = d[i] + n;
	while(d[pos] != p) pos++;
	for(int i = pos;i < m + pos;i++){
		int dist1 = d[i] - p,dist2 = n - d[i + 1] + p;
		mi = min(mi,min(dist1,dist2) * 2 + max(dist1,dist2));
	}
	cout << mi * 100 << endl;
	return 0;
}

Measured memory_bytes: 3180
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();
		int[] A=new int[N];
		for(int i=0; i<N; i++) {
			A[i]=sc.nextInt();
		}
		long gcd=A[0];
		for(int i=1; i<N; i++){
			gcd=gcd(gcd,A[i]);
		}
		//pl(gcd);
		boolean ans=false;
		for(int i=0; i<N; i++) {
			if(A[i]>K) {
				if((A[i]-K)%gcd==0) {
					ans=true;
				}
			}
			else if(A[i]==K) {
				ans=true;
			}
		}
		if(ans) {
			pl("POSSIBLE");
		}
		else {
			pl("IMPOSSIBLE");
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static long lcm(long m, long n) {
		return m / gcd(m, n)*n;
	}
	public static long gcd(long m, long n) {
		if(m < n) return gcd(n, m);
		if(n == 0) return m;
		return gcd(n, m % n);
	}
}

Measured memory_bytes: 34460
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n,a,b;
const int M=1e9+7;
ll ksm(ll x,ll y){
    ll s=1;
    while(y){
        if(y&1)s=(s*x)%M;
        x=(x*x)%M;
        y>>=1;
    }
    return s;
}
ll work(int x){
    ll s,c;
    s=c=1;
    for(int i=1;i<=x;i++)s=(s*i)%M;
    for(int i=n-x+1;i<=n;i++)c=(c*i)%M;
    return (c*ksm(s,M-2))%M;
}
int main(){
	in(n);in(a);in(b);
    cout<<(((ksm(2,n)-1)%M-work(a)%M-work(b)%M)%M+M)%M<<endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
 
typedef unsigned long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  D2(x)       { cerr << "[" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }
#define  all(x)      (x).begin(), (x).end()
#define  mem(a)      memset(a , 0 ,sizeof a)
#define  deb(x)      cout << #x << " - " << x << "\n";
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcount(x)
#define  deb2(x,y)   cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n"
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b)  for(int i=a ; i>=b ; --i)
 
#define PI 3.141592653589793
const ll p = 5;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;

int main() {
    IOS;
    int n; cin >> n;
    ll ans = 0;
    map<pair<int,int>,int>mp;
    
    rep(i,1,n+1){
        string s = to_string(i);
        int l = s[0]-'0',r = s[s.size()-1]-'0';
        mp[{l,r}]++;
        ans += 2*(mp[{r,l}]) - (l == r);
    }
    
    cout << ans;
}

Measured memory_bytes: 3752
#include<iostream>

#define DEBUG
#define NMAX 1000

using namespace std;

int main(){
    int N,M,A[NMAX];
    int now;
    int ans=0;

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

    now=0;
    while(1){
        int max=-1;
        int min=101;
        for(int i=0;i<M;i++){
            if(max<A[(i+now)%N]) max=A[(i+now)%N];
            if(min>A[(i+now)%N]) min=A[(i+now)%N];
        }
        ans+=max-min;
        now+=M;
        if(now==N) break;
        now=now%N;
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
inline ll LCM(ll a, ll b){return a / GCD(a, b) * b;}
inline ll powint(ll x, ll y){ll r=1;while(y){if(y&1)r*=x;x*=x;y>>=1;}return r;}
inline ll powmod(ll x, ll y, ll m = MOD){ll r=1;while(y){if(y&1)r*=x;x*=x;r%=m;x%=m;y>>=1;}return r;}
/* END OF TEMPLATE */

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, d;
    cin >> n >> d;
    vvll x(n, vll(d, 0));
    rep(i, n)rep(j, d){
        cin >> x[i][j];
    }
    ll ans = 0;
    rep(i, n)repr(j, i+1, n){
        ll dist = 0;
        rep(k, d){
            dist += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        }
        if((ll)sqrt(dist)*(ll)sqrt(dist) == dist){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
static const LL INF = 1<<50;

using namespace std;

int n,k,ans;
LL s[10001];
string num[11];
int t=0;
void cal(string sum,int depth,int bit){
    if(depth==k){
        int num;
        num=atoi(sum.data());
        s[t]=num;
        t++;
        return;
    }
    for(int i=1;i<=n;++i){
        int b=1<<i;
        if(bit&b){
            int k=bit-b;
            cal(sum+num[i],depth+1,k);
        }
    }
}

int main(){
    while(1){
        memset(s,0,sizeof(s));
        int p=1;
        t=0;
        cin>>n>>k;
        if(n==0&&k==0)break;
        for(int i=1;i<=n;++i){
            p+=pow(2,i);
            cin>>num[i];
        }
        cal("",0,p);
        sort(s,s+t);
        for(int i=0;i<t;++i){
            if(s[i]&&s[i]!=s[i+1]){
                ans++;
            }
        }
        cout<<ans<<endl;
        ans=0;
    }
}

Measured memory_bytes: 1360
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int a = scan.nextInt();
			int b = scan.nextInt();
			if(a == 0 && b == 0){
				break;
			}
			int n = scan.nextInt();
			int[][] route = new int[a][b];
			for(int i = 0;i < a;i++){
				for(int j = 0;j < b;j++){
					if(i == 0 && j == 0){
						route[i][j] = 1;
					}else{
						route[i][j] = -1;
					}
				}
			}
			for(int i = 0;i < n;i++){
				route[scan.nextInt()-1][scan.nextInt()-1] = 0;
			}
			for(int i = 0;i < a;i++){
				for(int j = 0;j < b;j++){
					if(route[i][j] < 0){
						if(i == 0){
							route[i][j] = route[i][j-1];
						}else if(j == 0){
							route[i][j] = route[i-1][j];
						}else{
							route[i][j] = route[i-1][j] + route[i][j-1];
						}
					}
				}
			}
			System.out.println(route[a-1][b-1]);
		}
	}
}

Measured memory_bytes: 20208
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

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

using ll = long long;

std::string N;
bool fl = false;

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

  rep( i, N.size()-2 )
  {
    fl |= N[i]==N[i+1] && N[i+1] == N[i+2];
  }

  puts( fl ? "Yes" : "No" );

  return 0;
}

Measured memory_bytes: 256
import sys
import math
from scipy.misc import comb  # atcoderではspecial→misc, permは使えない

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()

N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(N - 1):
    for l in range(i + 1, N):
        ans += math.sqrt((xy[i][0] - xy[l][0]) ** 2 + (xy[i][1] - xy[l][1]) ** 2)
ans *= (N - 1) / comb(N, 2)
print(ans)


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

int main() {
    ll N,r=0;
    cin >> N;
    vector<ll> A(N),t(N);
    rep(i,N)
        cin >> A.at(i);
    sort(A.begin(), A.end());

    if(N%2) {
        ll r1=0,r2=0;
        rep(i,N/2)
            t.at((i+1)*2) = A.at(i);
        t.at(0) = A.at(N/2);
        rep(i,N/2)
            t.at(i*2+1) = A.at(i+N/2+1);
        rep(i,N-1)
            r1 += abs(t.at(i)-t.at(i+1));
        
        rep(i,N/2)
            t.at(i*2) = A.at(i+N/2+1);
        t.at(N-1) = A.at(N/2);
        rep(i,N/2)
            t.at(i*2+1) = A.at(i);
        rep(i,N-1)
            r2 += abs(t.at(i)-t.at(i+1));

        r = max(r1,r2);
    } else {
        rep(i,N/2)
            t.at(i*2) = A.at(i+N/2);
        rep(i,N/2)
            t.at(i*2+1) = A.at(i);
        rep(i,N-1)
            r += abs(t.at(i)-t.at(i+1));
    }

    cout << r << endl;
}

Measured memory_bytes: 1792
n=int(input())
p=[]
for i in range (n):
	p.append(int(input()))
pos=0
num=0
n_th = 0
s={}
for i in p:
	if i-1 in s:
		s[i]=s[i-1]+1
	else:
		s[i]=1
print(n-max(s.values()))

Measured memory_bytes: 35024
#include <stdio.h>
#include <algorithm>
using namespace std;
#include <string.h>
int vis[20][20];
int book[10][10];
int map[10][10];
int flag,n;
void dfs(int x)
{
	if(flag) return ;
	if(x>=8)
	{
		for(int i=0;i<8;i++)
		{
			for(int j=0;j<8;j++)
			if(map[i][j]) printf("Q");
			else printf(".");
			printf("\n");
		}
		flag=1;
		return ;
	} 
	for(int i=0;i<8;i++)
	{
	  if(map[x][i]) 
        dfs(x+1);
	  else if(!vis[0][i]&&!vis[1][x+i]&&!vis[2][x-i+n])
	  	  {
	  		vis[0][i]=vis[1][x+i]=vis[2][x-i+n]=1;
	  		map[x][i]=1;
	  		dfs(x+1);
	  		map[x][i]=0;
	  		vis[0][i]=vis[1][x+i]=vis[2][x-i+n]=0;
		 } 
	}
	return;
}
int main()
{
	
	while(~scanf("%d",&n))
	{
	   int x,y;flag=0;
	   memset(book,0,sizeof(map));
	   memset(book,0,sizeof(book));
	   memset(vis,0,sizeof(vis));
	   for(int i=1;i<=n;i++)
	   {
	   	scanf("%d %d",&x,&y);
	   	map[x][y]=1;
	   vis[0][y]=vis[1][x+y]=vis[2][x-y+n]=1;
	   }
	   dfs(0);
	}
	return 0;
}


Measured memory_bytes: 2692
H, N = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]
max_A = max([a for a, _b in AB])

dp = [10**18] * (H+max_A)
dp[0] = 0
#print(dp)

for i in range(H):
  for a, b in AB:
    dp[i+a] = min(dp[i]+b, dp[i+a])
    
print(int(min(dp[H:])))


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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

			String b = nextString();
			String ans="";
			switch(b){
			case "A":ans="T";break;
			case "T":ans="A";break;
			case "C":ans="G";break;
			case "G":ans="C";break;

			}
			System.out.println(ans);

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21204
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int long long i=0;i<n;i++)
using namespace std;

int main(){
    int x1,x2,y1,y2;
    cin>>x1>>y1>>x2>>y2;
    int tx=x2-x1;
    int ty=y2-y1;
    cout<<x2-ty<<" "<<y2+tx<<" "<<x1-ty<<" "<<y1+tx<<endl;


    return 0;
}


Measured memory_bytes: 256
n,m = map(int, input().split())
li = [0] * (n+1)

for i in range(m):
    a,b = map(int, input().split())
    li[a] += 1
    li[b] += 1

ans = 'YES' if all([x % 2 == 0 for x in li]) else 'NO'
print(ans)


Measured memory_bytes: 5040
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
typedef long long ll;
using namespace std;

int main(){
    ios::sync_with_stdio(0);
	cin.tie(0);
    
    int n,m;
    cin >> n >> m;
    vector<vector<int>> s(m, vector<int>(n+1));
    vector<int> k(m);
    vector<int> p(m);
    REP(i, m) {
        cin>>k[i];
        REP(j, k[i]) {
            cin>>s[i][j];
        }
    }
    REP(i, m) cin>>p[i];
    int ans = 0;
    bool ok;
    int mod2;

    for (int bit = 0; bit < (1 << n); ++bit) {
        ok = true;
        REP(i, m) {  // 電球
            mod2 = 0;
            // (i>>(v[j][l]-1) & 1
            REP(j, k[i]) { //　ついてるかを見極める
                if (bit & 1<<(s[i][j]-1)) mod2 += 1;
                // cout << "turn on light: " << bitset<5>(bit) << " ";
                // cout << s[i][j] << " " << (1 << (s[i][j]-1)) << " " << (bit & 1<<(s[i][j]-1)) << endl;
            }
            if(mod2 % 2 != p[i]) ok = false;
        }
        if(ok){
            // cout << bit << endl;
            ans += 1;
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 3656
open System

let [| A; B; H; M |] = stdin.ReadLine().Split() |> Array.map float

let hour = 30. * H + 0.5 * M
let minute = 6. * M
let angle = abs (hour - minute)
let radian = angle * Math.PI / 180.

A * A + B * B - 2. * A * B * Math.Cos radian
|> Math.Sqrt
|> stdout.WriteLine


Measured memory_bytes: 29496
def solve():
  n = int(input())
  a = list(map(int, input().split()))
  josi = [0]*n
  for i in range(n-1):
    if a[i] != 0:
      josi[a[i]-1] += 1
  for i in josi:
    print(i)
  return 0
 
if __name__ == "__main__":
  solve()


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define AC cout << "AC" << endl;
#define WA cout << "WA" << endl;

#define out(s) cout << s << endl;

#define ll long long
#define ull unsigned long long

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
    int K;
    string S;
    cin >> K >> S;

    if (S.size() <= K) {
        out(S);
    } else {
        cout << S.substr(0, K) << "..." << endl;
    }
}

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

int main()
{   
    int N, Q; string S;
    cin >> N >> S >> Q;
    
    vector<set<int>> vsi(26);
    for (int i = 0; i < S.size(); ++i) {
        vsi[S[i] - 'a'].insert(i);
    }
    for (int i = 0; i < Q; ++i) {
        int t; 
        cin >> t;
        if (t == 1) {
            int p; char c;
            cin >> p >> c; p--;
            char sc = S[p];
            vsi[sc - 'a'].erase(p);
            S[p] = c;
            vsi[c - 'a'].insert(p);
        } else {
            int l, r;
            cin >> l >> r; l--; r--;
            int ans = 0;
            for (char c = 0; c < 26; ++c) {
                auto it = vsi[c].lower_bound(l);
                if (it != vsi[c].end() && *it <= r) ++ans;
            }
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 24196
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {
        static int R;

        static void Main(string[] args)
        {
          //入力を受け取る
          var NM = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
          var N = NM[0];
          var M = NM[1];
          var X = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
          Array.Sort(X);
          
          if(N >= M){
            Console.WriteLine(0);
          }else{
            var distance = new long[M-1];
            for(int i = 1;i < M ; i++){
              distance[i-1] = X[i]-X[i-1];
              //Console.WriteLine(distance[i-1]);
            }
            distance = distance.OrderBy(a => -a).ToArray();
            var ans = distance.Sum();
            //Console.WriteLine(ans);
            for(int i = 0;i < N-1 ; i++){
              ans -= distance[i];
            }
            Console.WriteLine(ans);
          }
          

          
        }
}







Measured memory_bytes: 25184
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 998244353;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

ll dp[3005][3005];
ll arr[3005];
ll n;
ll recur(ll pos, ll rem) {

  if (rem < 0) {
    return 0;
  }
  if (rem == 0) {
    return pos - 1;
  }
  if (pos == n + 1)
    return 0;

  ll &ans = dp[pos][rem];
  if (ans != -1)
    return ans;

  ans = recur(pos + 1, rem - arr[pos]) + recur(pos + 1, rem);

  if (ans >= mod)
    ans -= mod;
  return ans;
}

ll recur2(ll pos, ll rem) {

  if (rem < 0) {
    return 0;
  }
  if (rem == 0) {
    return 1;
  }
  if (pos == n + 1)
    return 0;

  ll &ans = dp[pos][rem];
  if (ans != -1)
    return ans;

  ans = recur2(pos + 1, rem - arr[pos]) + recur2(pos + 1, rem);

  if (ans >= mod)
    ans -= mod;
  return ans;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll s;
  cin >> n >> s;
  for (ll i = 1; i <= n; i++)
    cin >> arr[i];

  memset(dp, -1, sizeof(dp));

  ll res = 0;
  for (ll i = 1; i <= n; i++) {
    res += (n + 1) * i % mod * recur2(i + 1, s - arr[i]) % mod;
    if (res >= mod)
      res -= mod;
  }

  memset(dp, -1, sizeof(dp));
  for (ll i = 1; i <= n; i++) {
    res -= i * recur(i + 1, s - arr[i]) % mod;
    if (res < 0)
      res += mod;
  }

  cout << res << en;

  return 0;
}


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

/*............................*/

#define uint uint64_t
#define mx 100001
#define ll long long int
#define ull unsigned long long int
#define pii pair<int, int>
#define pll pair<long long int, long long int>
#define mp make_pair
#define pb push_back
#define inf INT_MAX
#define pi acos(-1)
#define eps 1e-8
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / __gcd(a, b)
#define input(ara, n)          \
   for (int i = 0; i < n; i++) \
   scanf("%d", &ara[i])
#define inputl(ara, n)                   \
   for (long long int i = 0; i < n; i++) \
   scanf("%lld", &ara[i])
#define pf(a) printf("%d\n", a);
#define pfl(a) printf("%lld\n", a);
#define pfi(a) printf("%d ", a);
#define pfll(a) printf("%lld ", a);
#define sc(a) scanf("%d", &a)
#define scc(a, b) scanf("%d %d", &a, &b)
#define sccdbl(a, b) scanf("%lf %lf", &a, &b)
#define sccc(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scccdbl(a, b, c) scanf("%lf %lf %lf", &a, &b, &c)
#define scl(a) scanf("%lld", &a)
#define sccl(a, b) scanf("%lld %lld", &a, &b)
#define scccl(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
using namespace std;
int main()
{
   // int t;
   // sc(t);
   // while (t--)
   // {

   // }
  int n;
  sc(n);
  ll ara[n];
  for(ll i=0;i<n;i++){
     scl(ara[i]);
  }
  ll preffix[n+2],suffix[n+2];
  preffix[1]=ara[0];
  for(ll i=2;i<=n;i++){
     preffix[i]=gcd(preffix[i-1],ara[i-1]);
  }
  suffix[n]=ara[n-1];
  for(ll i=n-1;i>=1;i--){
     suffix[i]=gcd(suffix[i+1],ara[i-1]);
  }
  ll ans=max(suffix[2],preffix[n-1]);
  for(ll i=2;i<n;i++){
     ans=max(ans,gcd(preffix[i-1],suffix[i+1]));
  }
  pfl(ans);
   return 0;
}


Measured memory_bytes: 6168
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
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 (b < a) { a = b; return 1; } return 0; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        vll A(N);
        rep(i, 0, N) cin >> A[i];

        ll b;
        rep(i, 0, 1) {
                ll s = 1;
                ll ans = 0;
                rep(j, 0, N) {
                        ans += s * A[j];
                        s *= -1;
                }
                b = ans;
        }

        vll B(N);
        B[0] = b;
        rep(i, 1, N) {
                B[i] = 2 * A[i-1] - B[i-1];
        }
        rep(i, 0, N) {
                cout << B[i];
                if (i != N-1) cout << ' ';
                else cout << endl;
        }
}


Measured memory_bytes: 4768
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a * b;
        int length = 2 * (a + b);
        System.out.println(area + " " + length);
    }
}


Measured memory_bytes: 26072
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>

int main(){
    string w;
    cin >> w;
    map<char,int> ma;
    rep(i,0,w.size()){
        ma[w[i]]++;
    }

    bool flg = true;
    for(auto x : ma){
        if(x.second%2!=0) flg = false;
    }
    cout << (flg ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(){
  int i,j,k,l;
  int A,B,M;
  scanf("%d %d %d",&A,&B,&M);
  int Al[A],Bl[B],D[M];
  int amin=100000,bmin=100000;
  for(i=0;i<A;i++){
    scanf("%d ",&Al[i]);
    if(Al[i] < amin)
      amin=Al[i];
  }
  for(i=0;i<B;i++){
    scanf("%d ",&Bl[i]);
    if(Bl[i] < bmin)
      bmin=Bl[i];
  }
  
  int ans;
  
  ans = amin+bmin;
  
  for(i=0;i<M;i++){
    scanf("%d %d %d",&j,&k,&l);
    if(ans > (Al[j-1]+Bl[k-1]-l))
      ans = Al[j-1]+Bl[k-1]-l;
  }
  
  printf("%d\n",ans);
  return 0;
}



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

int main(){
    int n, m, q;
    cin >> n >> m >> q;
    vector<ll> a(q), b(q), c(q), d(q);
    rep(i,q){
        int A, B, C, D;
        cin >> A >> B >> C >> D;
        A--; B--;
        a[i]=A; b[i]=B; c[i]=C; d[i]=D;
    }
    vector<vector<ll>> memo;
    for(int A=1; A<=m; A++){
        for(int B=A; B<=m; B++){
            for(int C=B; C<=m; C++){
                for(int D=C; D<=m; D++){
                    for(int E=D; E<=m; E++){
                        for(int F=E; F<=m; F++){
                            for(int G=F; G<=m; G++){
                               for(int H=G; H<=m; H++){
                                    for(int I=H; I<=m; I++){
                                        for(int J=I; J<=m; J++){
                                           memo.push_back({A,B,C,D,E,F,G,H,I,J});
                                        }
                                    } 
                                }
                            } 
                        }
                    }
                } 
            }
        }
    }
    ll ans = 0;
    ll l = memo.size();
    for(ll i=0; i<l; i++){
        const vector<ll> test = memo[i];
        if(test.size()==0) continue;
        ll res = 0;
        rep(j,q){
            if(test[b[j]] - test[a[j]] == c[j]) res += d[j];
        }
        ans = max(ans, res);
    }
    cout << ans << endl;
}


Measured memory_bytes: 13936
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n, dato, error=0;
		n = reader.nextInt();
		for(int i=1; i <= n; i++) {
			dato = reader.nextInt();
			if(dato != i) {
				++error;
			}
		}
		if(error <=2)
			System.out.println("YES");
		else
			System.out.println("NO");
	}

}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
int main(){
  long n,ans;
  ans=1;
  cin >> n;
  vector<int> a(n,0);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=1;i<n;i++){
    if(a[0]>=a[i]){
      ans++;
      a[0]=a[i];
    }
  }
  cout << ans << endl;
}
    


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

#define pb push_back
#define mp make_pair

typedef pair<int, int> pii;
typedef long long ll;

int h, w;
string s[205];
string c[205];

int main() {
#ifdef LOCAL                       
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> h >> w;
  for (int i = 0; i < h; ++i) {
    cin >> s[i];
  }
  for (int i = 0; i < 2 * h; ++i) {
    c[i].resize(w);
    for (int j = 0; j < w; ++j) {
      c[i][j] = s[(i + 2) / 2 - 1][j];
    }
  }
  for (int i = 0; i < 2 * h; ++i) {
    cout << c[i] << '\n';
  }
  return 0;
}

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

using namespace std;
#define int long long
const int INF = 200000000007;


  
signed main(){
    int n,ans=0;
    cin>>n;
    int t=sqrt(n);
    for(int i=1;i<t+1;i++){
        if(n%i==0&&i< n/i -1)ans+=n/i -1;
    }

    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <string>
#include <utility>
#include <cmath>
#include <cstdio>

using namespace std;

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

using ll = long long;
using ull = unsigned long long;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif


void solve() {
    int N, M, X;
    int A[100];
    cin >> N >> M >> X;
    int cost1 = 0, cost2 = 0;
    rep(i, M) {
        int A;
        cin >> A;
        if (A < X) {
            cost1++;
        } else {
            cost2++;
        }
    }
    printf("%d\n", min(cost1, cost2));
}


int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.Scanner;
 
public class Main {
    public static int divisors(int a, int b, int c) {
        int count = 0;
        if (b >= c && a <= c) count++;

        b = Math.min(b, c / 2);
        for (int i = a; i <= b; i++) {
            if (c % i == 0) count++;
        }
        return count;
    }
 
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        // int y = sc.nextInt();
        // int r = sc.nextInt();
        System.out.println(divisors(a,b,c));
    }
}


Measured memory_bytes: 26412
# AOJ 0216 Cutting Down Water Bills
# Python3 2018.6.23 bal4u

while 1:
	w = int(input())
	if w < 0: break
	s = 1150
	if w > 10:
		if w <= 20: s+= (w-10)*125
		else: s += 1250
	if w > 20:
		if w <= 30: s += (w-20)*140
		else: s += 1400
	if w > 30: s += (w-30)*160;
	print(4280-s)



Measured memory_bytes: 5584
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    
    map<int,int> mp;
    rep(i,v.size()){
        mp[v[i]]++;
    }
    
    int ans = 0;
    for(const auto &elm:mp){
        int e,c;
        tie(e,c) = elm;
        if(c<e)ans+=c;
        else if(c>e)ans+=c-e;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5120
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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 (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m,l;cin>>n>>m>>l;

  vector<vector<pair<int,int>>> d(n,vector<pair<int,int>>(n,{1e9,1e9}));

  rep(i,m)
  {
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    if(c>l)continue;
    d[a][b]={0,c};
    d[b][a]={0,c};
  }
  rep(i,n)
  {
    d[i][i]={0,0};
  }
  // nは頂点数
  rep(x,3)for (int i = 0; i < n; i++)      // 経由する頂点
    for (int j = 0; j < n; j++)    // 開始頂点
     for (int k = 0; k < n; k++)  // 終端
     {
       int nf,ns;
       if(d[j][i]>=(pair<int,int>){1e9,1e9})continue;
       if(d[i][k]>=(pair<int,int>){1e9,1e9})continue;

       if(d[i][k].first+d[j][i].first==0&&d[i][k].second+d[j][i].second<=l)
       {
         nf=0;
         ns=d[j][i].second+d[i][k].second;
       }
       else
       {
         nf=d[j][i].first+d[i][k].first+1;
         ns=d[i][k].second;
       }
       d[j][k] = min(d[j][k],{nf,ns} );
     }
  int q;
  cin>>q;

  rep(i,q)
  {
    int a,b;
    cin>>a>>b;
    a--;b--;
    int res=d[a][b].first;
    if(res>=1e9)cout<<-1;
    else cout<<res;
    cout<<"\n";
  }
  cout<<endl;

}


Measured memory_bytes: 1280
//
// Created by file on 18/07/01.
//

#include <bits/stdc++.h>


using namespace std;

int main() {

    string str;
    int cnt = 0;

    cin >> str;

    for (int i = 0; i < str.size(); ++i) {
        if (str[i] == '1') {
            cnt++;
        }

    }

    cout << cnt << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
#define ll long long
#define fm_t  ll t;cin>>t;while(t--)
#define fr(i,a,b) for( ll i=a;i<b;i++)
#define fr1(i,n,a) for( ll i=n-1;i>=a;i--)
#define sz(x) (ll)(x).size()
#define all(v)  (v).begin(), (v).end()
#define Sort(x) sort(x.begin(),x.end())
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
const ll mod = 998244353;
#define Mod 1000000007

#define inf 1e18
#define ld long double
#define pll pair<ll, ll> 
#define vi vector<int>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vvi vector< vector<int> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<ll, ll>, ll >
#define pi pair<ll, ll>
#define ppi pair<pair<ll, ll>, ll>
#define ump unordered_map<ll,ll>
#define pri priority_queue< pair<ll,ll> , vector< pair<ll,ll> >, greater< pair<ll,ll> > >
void ingraph(vl graph[], ll m){ll x, y;fr(i,0,m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}

#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)

//setprecision(10)
//greater<int>()
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}


ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll modinv(ll a){
    return modpower(a,mod-2);
}   
 
 

int main()
{
      
  fast;
  int x;
  cin>>x;
  if(x>=30)
    cout<<"Yes\n";
  else cout<<"No\n";
    
//cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
return 0;
}

Measured memory_bytes: 3652
def divide_list(l):
    divided_list = [[None, None] for _ in range(len(l) - 1)]
    for i, dl in enumerate(divided_list):
        dl[0], dl[1] = l[0:(i+1)], l[(i+1):]
    return divided_list


def mat_chain_mult(idx_list):
    global a
    global c

    start, end = idx_list[0], idx_list[-1]


    if c[start][end] is not None:
        return c[start][end]

    if len(idx_list) == 1:
        c[start][end] = 0
    elif len(idx_list) == 2:        
        c[start][end] = a[start] * a[start+1] * a[start+2]
    else:
        divided_list = divide_list(idx_list)
        cc = a[start] * a[end+1]
        
        c[start][end] = min([mat_chain_mult(dl0) + mat_chain_mult(dl1) + cc * a[len(dl0) + start] for dl0, dl1 in divided_list])
    
    return c[start][end]
    

if __name__ == "__main__":
    n = int(input())
    a = [0] * (n + 1)
    c = [[None] * n for _ in range(n)]

    for i in range(n-1):
        a[i] = list(map(int, input().split()))[0]
    a[n-1], a[n] = list(map(int, input().split()))

    print(mat_chain_mult(list(range(n))))


Measured memory_bytes: 9524