akhauriyash/Code-Regression huggingface dataset:
/**
 *    Author:  "Robin Singh" !!!!    
**/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define mp make_pair
#define str string 
#define szz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)     // 0 -> n-1 (i,0,n)
#define bk(i, j, k) for(int i = j-1; i >= k; i--)  // n-1 -> 0 (i,n,0)
#define frit(it, a) for(__typeof((a).begin()) it = a.begin(); it != a.end(); ++it)
#define mem(ptr)  memset(ptr, 0, sizeof ptr)  // use fill() for value other than 0 //
#define rtn return 
#define itt(a)   __typeof((a).begin())
#define RT  (cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n")  // Run Time
#define nl "\n"  // New Line
#define dbg(x) (cerr << #x << " = " << x << "  ")
#define enl (cerr << "\n")
#define dbgg(x,y) (cerr << #x << " = " << x << " -> " << #y << " = " << y << "\n")
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int,int> > vpii;
typedef vector< pair<ll, ll> > vpll;
const long long mod = 1e9+7;
const ld eps = 1e-9;
const int inf = (1<<30);
const ll INF = (1LL<<61);

ll gcd(ll a,ll b) { return b==0 ? a : gcd(b, a%b); }
ll expo(ll x, ll y){ ll res = 1; x = x % mod;  while (y > 0) { if (y & 1)res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
void matmul(ll a[][2], ll b[][2]) { ll tmp[2][2]; for(int i=0; i<2; i++) { for(int j=0; j<2; j++) { tmp[i][j] = 0; for(int k=0; k<2; k++) tmp[i][j] = (tmp[i][j] + a[i][k]*b[k][j]) % mod; }} for(int i=0; i<2; i++) for(int j=0; j<2; j++) a[i][j] = tmp[i][j]; }
ll fibo(int n)    // returns nth fibonacci number, also S(n) = f(n+2)-1
{ if(n == 0) return 0; else if(n == 1) return 1; ll T[2][2] = { {0, 1} , {1, 1} }; ll res[2][2] = { {1, 0}, {0,1} }; n--; while(n) { if(n & 1) matmul(res, T); n >>= 1; matmul(T, T); } return res[1][1]; }

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    if(n%2==0) cout << n;
    else cout << 2*n;
    return 0;
}

Measured memory_bytes: 256
K=gets.chomp.to_i
a,b=gets.chomp.split.map(&:to_i)

flg = 0
a.upto(b) { |n|
 if n%K == 0
  flg = 1
end
}

 if flg == 1
  puts "OK"
else
  puts "NG"
end 

Measured memory_bytes: 14380
#include <iostream>
using namespace std;
int main() {
  string atcoder, contest, s;
  cin >> atcoder >> s >> contest;
  string ans = "A";
  for (int i = 0; i < s.size(); i++) {
    if (s[i] >= 'A' && s[i] <= 'Z') {
      ans += s[i];
    }
  }
  cout << ans << "C" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#define neko 510
#define meko 100010
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~i))
#define rf(i,a,b) for(register int i=(a);i>=(b);i=~(-i))
int n,m,x[meko],y[meko],book[neko],now,ans;
int Must[neko][neko];
bool kill(int u)
{
	Must[u][u]=1;
	rf(i,m,1)
	{
		if(Must[u][x[i]]&&Must[u][y[i]])return 0;
		if(Must[u][x[i]]||Must[u][y[i]])Must[u][x[i]]=Must[u][y[i]]=1;
	}
	return 1;
}
int main()
{
	scanf("%d%d",&n,&m);
	f(i,1,m)scanf("%d%d",&x[i],&y[i]);
	f(i,1,n)book[i]=kill(i);
	f(i,1,n)if(book[i])
	 f(j,i+1,n)if(book[j])
	  {
		 now=1;
		 f(k,1,n)if(Must[i][k]&&Must[j][k]){now=0;break;}
		 ans+=now;
	  }return printf("%d\n",ans),0;
}

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

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

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

int main() {
  int H, W; cin >> H >> W;
  vector<string> S(H);
  for (int i = 0; i < H; i++) cin >> S.at(i);
  vector<vector<int>> ans(H, vector<int>(W, 0));
  vector<int> dy = { 1, 1, 1, 0, 0, -1, -1, -1 };
  vector<int> dx = { -1, 0, 1, -1, 1, -1, 0, 1 };
  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      if (S.at(y).at(x) == '.') continue;
      ans.at(y).at(x) = -1;
      for (int d = 0; d < 8; d++) {
        int ny = y + dy.at(d);
        int nx = x + dx.at(d);
        if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
        if (ans.at(ny).at(nx) == -1) continue;
        ans.at(ny).at(nx)++;
      }
    }
  }
  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      if (ans.at(y).at(x) == -1) cout << '#';
      else cout << ans.at(y).at(x);
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

/*

----------------------------------------

xs[m]は、

mの立っているビットの個数をkとするとき、
mのビットが立っているところにいるk人のと、
0番からk - 1番までの男との間で成立するマッチングの個数

を表すとする

xs[0] = 1

xs[m]は、累乗を用いて
m = or(i; 0 .. k) m[i]
とかかれるとき
m = sum xs[m[i] xor m]
ただしこの和は、k - 1番の男とm[i]の表す女がマッチする場合にわたる和


求めるものは
xs[1<<n - 1]

----------------------------------------

xs[0] = 1


xs[m]は、(i; 0 .. n) に対して、以下の和

mのビットの立っている個数をkとする

1<<i & m == 0 ならば 0

1<<i & m > 0 であって、

	as[i][k - 1] == 0 ならば 0
	
	as[i][k - 1] > 0 ならば xs[m ^ (1<<i)]

*/

const long mod = 1_000_000_007;

void main(){
 int n = read.to!int;
 
 int[][] as;
 foreach(i; 0 .. n) as ~= readln.chomp.split.map!(to!int).array;
 
 long[] xs = [1];
 foreach(m; 1 .. 1<<n){
	 long k = 0;
	 foreach(i; 0 .. n) if(m & (1<<i)) k += 1;
	 
	 long x = 0;
	 foreach(i; 0 .. n){
		 debug writeln("m:", m, " k:", k, " i:", i, " xs:", xs);
		 if(m & (1<<i)) if(as[i][k - 1] > 0){
			 x += xs[m ^ (1<<i)];
			 x %= mod;
		 }
	 }
	 xs ~= x;
 }
 
 xs[(1<<n) - 1].writeln;
 
}


Measured memory_bytes: 27644
//1,2,3,5,6,9,10,13,17
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> da(9);
  bool ans=true;
  da={1,2,3,5,6,9,10,13,17};
  for(int i=0;i<9;i++){
    if(n==da[i])
      ans=false;
  }
  if(ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

const int _ = 4e5 + 7;
struct Edge{int end , upEd;}Ed[_ << 1];
int head[_] , cntEd , N , M , du[_]; char str[_];

void addEd(int a , int b){Ed[++cntEd] = (Edge){b , head[a]}; head[a] = cntEd; ++du[b];}

int main(){
	scanf("%d %d %s" , &N , &M , str + 1);
	for(int i = 1 ; i <= M ; ++i){
		int x , y; scanf("%d %d" , &x , &y);
		if(str[x] == str[y]){addEd(x , y + N); addEd(y , x + N);}
		else{addEd(x + N , y); addEd(y + N , x);}
	}
	queue < int > q; int cnt = 0;
	for(int i = 1 ; i <= 2 * N ; ++i) if(!du[i]) q.push(i);
	while(!q.empty()){
		int t = q.front(); q.pop(); ++cnt;
		for(int i = head[t] ; i ; i = Ed[i].upEd)
			if(!--du[Ed[i].end]) q.push(Ed[i].end);
	}
	puts(cnt == 2 * N ? "No" : "Yes"); return 0;
}

Measured memory_bytes: 8704
N, X = map(int,input().split())

a = [1] #i番目にはi番目に作られるハンバーガーの大きさが入っている : a[i+1] = 2 * a[i] + 3
p = [1] #i番目にはi番目に作られるハンバーガーのパティの枚数　: p[i+1] = 2 * p[i] + 1
for i in range(N):
    a.append(2*a[i]+3)
    p.append(2*p[i]+1)
def function(N,X):
    if N <= 0 :
        return 0 if X<= 0 else 1
    elif X <= a[N-1] + 1 :
        ret = function(N-1,X-1)
        return ret
    else:
        ret  = 1 + p[N-1]
        ret +=  function(N-1,X-a[N-1]-2)
        return ret
print(function(N,X))


Measured memory_bytes: 3064
//#include<bits/stdc++.h> using namespace std;
#include<iostream>
using namespace std;
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<stack>
#include<queue> //priority_queue inside queue
#include<deque>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl '\n'
typedef long long ll;
typedef unsigned long long ull;
#define f(i,start,end) for(i=start;i<=end;i++)
#define min_heap priority_queue<int, vector<int>, greater<int> >
#define max_heap priority_queue<int>
#define eb emplace_back

bool isPrime(int n)
{
    for(int i=2; i*i<=n; i++)
    {
        if(n%i==0) return false;
    }
    return true;
} //returns true if prime!


int main()
{
    fast;
//int t=0,tc=0; cin >> tc; f(t,1,tc) //testcases
    {
        int n; cin >> n;
        int a[4] = {0};
        string s;
        while(n--)
        {
            cin >> s;
            if(s=="AC") a[0]++;
            else if(s=="WA") a[1]++;
            else if(s=="TLE") a[2]++;
            else a[3]++;
        }
        cout << "AC x " << a[0] << nl;
        cout << "WA x " << a[1] << nl;
        cout << "TLE x " << a[2] << nl;
        cout << "RE x " << a[3] << nl;
    }
    return 0;
}
    

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define si(x) scanf("%d",&x)
#define pi(x) printf("%d\n",x)
#define s(x) scanf("%I64d",&x)
#define p(x) printf("%I64d\n",x)
#define sc(x) scanf("%s",x)
#define pc(x) printf("%s",x)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define M 1000000007
#define N 200002
#define inf 1e15
#define PQG priority_queue< int,std::vector<int>,std::greater<int> >
#define PQL priority_queue< int,std::vector<int>,std::less<int> >
#define PQPL priority_queue<pii ,vector< pii >, less< pii > >
#define PQPG priority_queue<pii ,vector< pii >, greater< pii > >

using namespace std;

int main(){
int n;
cin>>n;
int ans=0;
for(int i=1;;i++){
    int temp=i*(i+1)/2;
    if(temp>=n){
        ans=i;
        break;
    }
}
cout<<ans<<endl;

return 0;
}


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

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

    string s;
    cin >> s;
    int q;
    cin >> q;

    bool fr = true;
    while(q--){
        int k;
        cin >> k;
        if(k == 1){
            if(fr) fr = false;
            else fr = true;
        }else{
            int a;
            cin >> a;
            string c;
            cin >> c;
            if(a == 1){
                if(fr) s.insert(0, c);
                else s += c;
            }else{
                if(fr) s += c;
                else s.insert(0, c);
            }
        }
    }
    
    if(!fr) reverse(s.begin(), s.end());

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 912
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

string solve(string s, char c){
    if('A' <= s[0] && s[0] <= 'Z')
        s[0] += 'a' - 'A';
    s += '_';
    int n = s.size();

    int j = 0;
    vector<string> vs;
    for(int i=0; i<n; ++i){
        if('A' <= s[i] && s[i] <= 'Z'){
            s[i] += 'a' - 'A';
            vs.push_back(s.substr(j, i-j));
            j = i;
        }else if(s[i] == '_'){
            vs.push_back(s.substr(j, i-j));
            j = i+1;
        }
    }

    int m = vs.size();
    if(c == 'U')
        vs[0][0] += 'A' - 'a';
    s = vs[0];

    for(int i=1; i<m; ++i){
        if(c == 'D'){
            s += '_' + vs[i];
        }else{
            vs[i][0] += 'A' - 'a';
            s += vs[i];
        }
    }
    return s;
}

int main()
{
    for(;;){
        string s;
        char c;
        cin >> s >> c;
        if(s == "EndOfInput")
            return 0;

        cout << solve(s, c) << endl;
    }
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

string s;

int main(){
	cin >> s;
	if(s[0]==s[1]&&s[1]==s[2]){
		cout << "Yes" << endl;
	}else if(s[1]==s[2]&&s[2]==s[3]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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

const int INF = 2e9;

int main(){
    ll n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> cnt(n,0);
    int now = 1;
    ll fir = 0;
    ll sec = 0;
    while(true){
        int next = a[now-1];
        cnt[now-1]++;
        if(cnt[now-1] == 1)fir++;
        else if(cnt[now-1] == 2)sec++;
        else if(cnt[now-1] == 3)break;
        now = next;
    }
    if(k <= fir){
        now = 1;
        rep(i,k){
            int next = a[now-1];
            now = next;
        }
    }
    else{
        k -= fir;
        k %= sec;
        rep(i,k){
            int next = a[now-1];
            now = next;
        }
    }
    cout << now << endl;
}

Measured memory_bytes: 4808
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 15:51-

            int n = sc.nextInt();
            int q = sc.nextInt();

            ArrayList[] tree = new ArrayList[n];
            for (int i = 0; i < tree.length; i++) tree[i] = new ArrayList();

            for (int i = 0; i < n - 1; i++) {
                int a = sc.nextInt() - 1;
                int b = sc.nextInt() - 1;

                tree[a].add(b);
                tree[b].add(a);
            }

            int[] vs = new int[n];
            for (int i = 0; i < q; i++) vs[sc.nextInt() - 1] += sc.nextInt();

            ArrayDeque<WeightNode> qu = new ArrayDeque<>();
            qu.addLast(new WeightNode(0, 0));
            boolean[] seen = new boolean[n];
            int[] ret = new int[n];

            while (!qu.isEmpty()) {
                WeightNode cur = qu.removeFirst();
                seen[cur.node] = true;

                int myval = cur.weight + vs[cur.node];
                ret[cur.node] = myval;

                ArrayList<Integer> children = tree[cur.node];
                for (Integer child : children) if (!seen[child]) {
                    qu.addFirst(new WeightNode(child, myval));
                }
            }

            for (int v : ret) {
                out.print(v + " ");
            }
            out.println();
        }
    }
    
    private static class WeightNode {
        private final int node;
        private final int weight;

        public WeightNode(int node, int weight) {
            this.node = node;
            this.weight = weight;
        }
    }

}


Measured memory_bytes: 210872
# ABC109D - Make Them Even
def main():
    H, W, *A = map(int, open(0).read().split())
    A = [[i & 1 for i in a] for a in zip(*[iter(A)] * W)]
    ans = []
    for i in range(H):  # move left to right
        for j in range(W - 1):
            if A[i][j]:
                A[i][j + 1] ^= 1
                ans += ["{} {} {} {}".format(i + 1, j + 1, i + 1, j + 2)]
    for i in range(H - 1):  # move up to down
        if A[i][W - 1]:
            A[i + 1][W - 1] ^= 1
            ans += ["{} {} {} {}".format(i + 1, W, i + 2, W)]
    print(len(ans))
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()

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

int main() {
  long A, B;
  cin >> A >> B;

  int cheapest = 0;
  for (int i = 1; i <= 1000; i++) {
    float price = i * 0.08;
    int priceCut = floor(price);
    if (priceCut == A) {
      float price2 = i * 0.1;
      int priceCut2 = floor(price2);
      if (priceCut2 == B) {
        cout << i << endl;
        return 0;
      }
    }
  }

  cout << -1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        a[i] = 0;
    }
    int d, temp;
    for (int i = 0; i < k; i++)
    {
        cin >> d;
        for (int j = 0; j < d; j++)
        {
            cin >> temp;
            a[temp - 1] = 1;
        }
    }
    int res = 0;
    for (int i = 0; i < n; i++)
    {
        if (a[i] == 0)
            res++;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rel register ll
#define rec register char
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) pc('-'),x=-x;
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e5;
typedef ll fuko[yuzu|10];
fuko a;
int main(){
int i,n=read(),k=read();
for (i=1;i<=n;++i) a[i]=read();
ll llx=1e18;
for (i=k;i<=n;++i) llx=min(llx,min(abs(a[i-k+1]),abs(a[i]))+a[i]-a[i-k+1]);
write(llx);
}

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

#define FOR(i,S,E) for(int i=S; i<E; i++)
#define ri(x) scanf("%d", &x)
#define rii(x,y) scanf("%d%d", &x, &y)

int main() {
    int N, A, B;
    rii(N, A);
    ri(B);
    int turn = 1;
    while(abs(A-B)>1) {
        if (turn) {
            if (A<B) A++;
            else A--;
        } else {
            if (A<B) B--;
            else B++;
        }
        turn = !turn;
    }

    if (!turn) {
        printf("Alice\n");
    } else {
        printf("Borys\n");
    }
}


Measured memory_bytes: 128
#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 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  REP(i, N) cin >> a[i];
  
  int MIN = INF;
  int sum = 0;
  REP(i,100){
    sum = 0;
    REP(j,N){
      sum += (a[j] - i)*(a[j] - i);
    }
    MIN = min(MIN,sum);
  }
  cout << MIN << endl;
}

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

int main() {
	int n, r, ans;
	
	scanf("%d%d", &n, &r);
	if(n>=10) ans = r;
	else ans = r + (10-n)*100;
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 256
#!/home/ymduu/.rbenv/shims/ruby

S=STDIN.gets

ls=S.split("")
first=-1
last=20000000
count=0
for i in ls do
    #puts i
    if first==-1 && i=="A"
        first=count
    elsif i=="Z"
        last=count
    end
    count+=1
    
end
puts last-first+1


Measured memory_bytes: 16636
MOD = 10 ** 9 + 7
K = int(input())
M = len(input())
N = M + K

pow25 = [1] * (N + 1)
fac = [1] * (N + 1)
inv = [1] * (N + 1)
for x in range(1, N + 1):
    fac[x] = fac[x - 1] * x % MOD
    pow25[x] = pow25[x - 1] * 25 % MOD
inv[N] = pow(fac[N], MOD-2, MOD)
for x in range(N - 1, -1, -1):
    inv[x] = inv[x + 1] * (x + 1) % MOD

def binom(n, k):
    return fac[n] * inv[n - k] % MOD * inv[k] % MOD

ans = 0
for k in range(M, N + 1):
    ans += binom(N, k) * pow25[N - k] % MOD
    ans %= MOD
print(ans)

Measured memory_bytes: 148764
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef long long ll;
typedef vector<char> vchar;
typedef vector<long long> vll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 1000000007
#define MOD 1e9+7
int main(){
  //input
  string s;cin>>s;
  int i,w,l;w=0;
  for(i=0;i<(s.size());i++){
    // o, x 
    if(s.at(i) =='o'){w++;}
  }
  //caricurate
  l=15-(s.size())+w;
  if(l>7){cout<<"YES"<<endl;}
  else{cout<<"NO"<<endl;}
  //output
}

Measured memory_bytes: 256
import bisect
N = int(input())
Alist = list(map(int,input().split()))
Blist = list(map(int,input().split()))
Clist = list(map(int,input().split()))
Alist.sort()
Clist.sort()
retnum = 0 
for i in Blist:
    Anum = bisect.bisect_left(Alist,i)
    Cnum =  N - bisect.bisect_right(Clist,i)
    retnum +=(Anum * Cnum)
print(retnum)


Measured memory_bytes: 105444
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data',function(chunk){

var x = chunk.split(' ');
x[0] = Number(x[0])
x[1] = Number(x[1])
x[2] = Number(x [2])
x.sort();
console.log(x[0]+' '+x[1]+' '+x[2]);

});

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

ll moduloMul(ll a, ll b)
{
    ll res = 0;
    a %= mod;
    while (b)
    {
        if (b & 1)
            res = (res + a) % mod;
        a = (2 * a) % mod;
        b >>= 1;
    }
    return res;
}

int main()
{
    ll n, *a, i, ans, sum;
    cin >> n;
    a = new ll[n];
    for (i = 0; i < n; i++)
        cin >> a[i];
    for (i = 1, sum = 0; i < n; i++)
        sum = sum + a[i];
    for (i = 0, ans = 0; i < n - 1; i++)
    {
        ans = (ans + moduloMul(a[i], sum)) % mod;
        sum = sum - a[i + 1];
    }
    cout << ans << endl;
}

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

int main(void){
    int n,a,b,ans=0,sum;
    cin>>n>>a>>b;
    for(int i=1; i<=n; i++){
        sum = 0;
        int tmp=i;
        while(tmp>=1){
            sum += tmp % 10;
            tmp /= 10;
        }
        if(a<=sum && sum<=b) ans += i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

long long calc_combination_num(long long N, long long K);

int main(void)
{
    long long K;
    long long N;
    long long combination;

    scanf("%llu %llu", &N, &K);

    combination = calc_combination_num(N, K);
    printf("%llu\n", combination);
   
    return 0;

}

long long calc_combination_num(long long N, long long K)
{
    long long combination;
    long long pattern;

    if(K == 0){
        return 0;
    }

    if(K % 2 == 1){
        pattern = N / K;
        combination = pattern * pattern * pattern;
        return combination;
    }else{
        pattern = (N + K / 2) / K;
        combination = pattern * pattern * pattern;
        pattern = N / K;
        combination += pattern * pattern * pattern;
        return combination;
    }
}

Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>
int main(){
  int X,N,i,j,y,d,min,ans,tmp;
  y=0;
  min=150;
  scanf("%d %d",&X,&N);
  if(N==0){
    printf("%d",X);
    return 0;
  }
  int p[N];
  for(i=0;i<N;i++) scanf("%d",&p[i]);
  for(i=0;i<N;i++){
	for(j=i+1;j<N;j++){
	    if(p[i]>p[j]){
          tmp=p[i];
          p[i]=p[j];
          p[j]=tmp;
        }
    }
  }
  for(i=0;i<102;i++){
    if(i==p[y]){
      y++;
      continue;
    }
    d=abs(X-i);
    if(d<min){
      min=d;
      ans=i;
    }
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int A,B,C,D,E,F;
    cin>>A>>B>>C>>D>>E>>F;

    A*=100; B*=100;

    int W=-1,S;
    for(int a=0;a<=F;a+=A) for(int b=0;a+b<=F;b+=B){
        for(int c=0;a+b+c<=F;c+=C) for(int d=0;a+b+c+d<=F;d+=D){
            int w=a+b,s=c+d;
            if(s>w/100*E) continue;
            if(w+s>0 and (W==-1 or s*(W+S)>S*(w+s))){
                W=w; S=s;
            }
        }
    }
    cout<<W+S<<' '<<S<<endl;

}


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

using namespace std;
using LL = long long;

constexpr int N = 3e5 + 5;
constexpr LL mod = 1e9 + 7;

LL in[N], cnt[64], p2[N];

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

    int n;
    cin >> n;

    for (int i = 0; i < 60; i++) p2[i] = (1LL << i) % mod;

    for (int i = 1; i <= n; i++) cin >> in[i];

    LL result = 0;

    for (int I = n; I >= 1; I--) {
        LL d = in[I];
        for (int j = 0; j < 60; j++) {
            if (d >> j & 1) {
                result += (n - I - cnt[j]) * p2[j] % mod;
                result %= mod;
            }
            else {
                result += cnt[j] * p2[j] % mod;
                result %= mod;
            }
        }

        for (int j = 0; j < 60; j++) {
            if (d >> j & 1) {
                cnt[j]++;
            }
        }
    }

    cout << result << endl;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<double>v(n);
  for(auto&e:v)cin >> e;
  double ave=0;
  for(auto&e:v)ave+=e;
  ave = ave / n;
  int argi = 0;
  for(int i = 0; i < n; ++i){
    if(abs(v[i]-ave) < abs(v[argi]-ave))argi = i;
  }
  cout << argi << endl;
}

Measured memory_bytes: 3772
// header {{{
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <utility>
#include <string>
#include <sstream>
#include <queue>
#include <map>
#include <list>
#include <stack>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;

#define ALPHABET    26
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)
#define INF         1000000005

typedef long long ll;
typedef unsigned long long ull;
// }}}
// data structure {{{

// Union-Find
// verified AOJ DSL_1_A
struct UF {
    vector<int> p;  // parent
    vector<int> r;  // rank

    UF(int n) {
        p.resize(n);
        r.resize(n);
        for(int i=0;i<n;i++){
            p[i] = i;
            r[i] = 1;
        }
    }

    int find(int x) {
        if(x == p[x]){
            return x;
        }else{
            return p[x] = find(p[x]);
        }
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(r[x] < r[y]){
            p[x] = y;
        }else{
            p[y] = x;
            if(r[x] == r[y]){
                r[x]++;
            }
        }
    }
};
//}}}

int main() {
    int n, k, l;cin >> n >> k >> l;
    UF ufp(n), ufr(n);
    for(int i=0;i<k;i++){
        int a, b;cin >> a >> b;a--;b--;
        ufp.unite(a, b);
    }
    for(int i=0;i<l;i++){
        int a, b;cin >> a >> b;a--;b--;
        ufr.unite(a, b);
    }

    map<pair<int, int>, int> m;

    for(int i=0;i<n;i++){
        pair<int, int> p = {ufp.find(i), ufr.find(i)};
        m[p]++;
    }

    for(int i=0;i<n;i++){
        pair<int, int> p = {ufp.find(i), ufr.find(i)};
        cout << m[p] << " ";
    }
    cout << endl;
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    set<char> st;
    for (int i = 'a'; i <= 'z'; ++i) st.insert((char)(i));
    for (char c : s) st.erase(c);
    if (st.empty()) cout << "None" << endl;
    else cout << *begin(st) << endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
	static long f(long A, long C, long D) {
		if(A == 0) return 0;
		long mulC = A / C, mulD = A / D;
		long mulCD = A / LCM(C, D);
		return A - mulC - mulD + mulCD;
	}
	static long GCD(long x, long y) {
		if(Math.max(x, y) % Math.min(x, y) == 0) return Math.min(x, y);
		return GCD(Math.min(x, y), Math.max(x, y) % Math.min(x, y));
	}
	static long LCM(long x, long y){
		return (x / GCD(x,y)) * y;
	}
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()) {
			long A = sc.nextLong(), B = sc.nextLong(), C = sc.nextLong(), D = sc.nextLong();
			System.out.println(f(B, C, D) - f(A - 1, C, D));
		}
	}
}

Measured memory_bytes: 22996
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var n string
	fmt.Fscan(r, &n)

	if strings.Contains(n, "7") {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

// Union-Find
type unionFind struct {
	d []int
}

func newUnionFind(n int) *unionFind {
	uf := new(unionFind)
	uf.d = make([]int, n)
	for i := 0; i < n; i++ {
		uf.d[i] = -1
	}
	return uf
}

func (uf *unionFind) find(x int) int {
	if uf.d[x] < 0 {
		return x
	}
	uf.d[x] = uf.find(uf.d[x])
	return uf.d[x]
}

func (uf *unionFind) unite(x, y int) bool {
	rootX := uf.find(x)
	rootY := uf.find(y)
	if rootX == rootY {
		return false
	}

	if uf.d[rootX] < uf.d[rootY] {
		uf.d[rootX] += uf.d[rootY]
		uf.d[rootY] = rootX
	} else {
		uf.d[rootY] += uf.d[rootX]
		uf.d[rootX] = rootY
	}

	return true
}

func (uf *unionFind) same(x, y int) bool {
	return uf.find(x) == uf.find(y)
}

func (uf *unionFind) size(x int) int {
	return -uf.d[uf.find(x)]
}

// mod combination
func modpow(a, n, mod int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % mod
		}
		a = a * a % mod
		n = n / 2
	}
	return res
}

func modcomb(n, a, mod int) int {
	x := 1
	y := 1
	for i := 0; i < a; i++ {
		x = x * (n - i)
		x %= mod
		y = y * (i + 1)
		y %= mod
	}
	return x * modpow(y, mod-2, mod) % mod
}

func modfactorial(n, mod int) int {
	result := 1
	for i := 1; i <= n; i++ {
		result = (result * i) % mod
	}
	return result
}

// Utility

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func primeFactor(x int) map[int]int {
	res := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			res[i]++
			x = x / i
		}
	}
	if x != 1 {
		res[x] = 1
	}
	return res
}

func divisor(x int) []int {
	res := make([]int, 0)
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			res = append(res, i)
			if i != x/i {
				res = append(res, x/i)
			}
		}
	}
	return res
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}

func reverseString(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

// Queue ...
type Queue []int

// pop ...
func (q *Queue) empty() bool {
	return len(*q) == 0
}

// push ...
func (q *Queue) push(i int) {
	*q = append(*q, i)
}

// pop ...
func (q *Queue) pop() (int, bool) {
	if q.empty() {
		return 0, false
	} else {
		res := (*q)[0]
		*q = (*q)[1:]
		return res, true
	}
}

// Stack ...
type Stack []int

// pop ...
func (s *Stack) empty() bool {
	return len(*s) == 0
}

// push ...
func (s *Stack) push(i int) {
	*s = append(*s, i)
}

// pop ...
func (s *Stack) pop() (int, bool) {
	if s.empty() {
		return 0, false
	} else {
		index := len(*s) - 1
		res := (*s)[index]
		*s = (*s)[:index]
		return res, true
	}
}


Measured memory_bytes: 1824
#include<stdio.h>

int dp[50];

int fib(int n)
{
    if (n == 0 || n == 1) {
        return dp[n] = 1;
    }
    if (dp[n] != - 1) {
        return dp[n];
    }
    return dp[n] = fib(n - 1) + fib(n -2);
}

int main()
{
    int n, i;
    for (i = 0; i < 50; i++) {
        dp[i] = -1;
    }

    scanf("%d", &n);
    printf("%d\n", fib(n));

    return 0;
}


Measured memory_bytes: 2048
def WarshallFloyd(d):
    v = len(mat)
    for k in range(v):
        for i in range(v):
            for j in range(v):
                d[i][j] = min(d[i][j],d[i][k]+d[k][j])

n,m,r = map(int, input().split())
ls = list(map(int, input().split()))
INF = 1001001001001
mat = [[INF]*n for _ in range(n)]
for i in range(m):
    u,v,c = map(int, input().split())
    u-=1
    v-=1
    mat[u][v]=c
    mat[v][u]=c

WarshallFloyd(mat)

from itertools import permutations

ans=INF
for p in permutations(ls):
    now=0
    for i in range(len(p)-1):
        now+=mat[p[i]-1][p[i+1]-1]
    ans=min(ans,now)

print(ans)






Measured memory_bytes: 46568
def legendre(n):

	ans1=0
	tp=2
	while(n//tp>0):
		ans1+=n//tp
		tp=tp*2

	ans2=0
	fp=5
	while(n//fp>0):
		ans2+=(n//fp)//2
		fp=fp*5

	if(N%2==0):
		# ans2//=2
		ans=min(ans1,ans2)
	else:
		ans=0

	return ans

N=int(input())

print(legendre(N))


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll R, C, K; cin >> R >> C >> K;
  ll goods[R][C] = {};
  rep(i,K) {
    ll r, c, v; cin >> r >> c >> v; r--; c--;
    goods[r][c] = v;
  }

  vector<vector<vector<ll>>> dp; dp.resize(R); rep(i,R) { dp[i].resize(C); rep(j,C) dp[i][j].resize(4); }
  dp[0][0][1] = goods[0][0];
  rep(i,R) rep(j,C) rep(k,4) {
    if (i!=R-1) {
      dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][k]);
      dp[i+1][j][1] = max(dp[i+1][j][1], dp[i][j][k]+goods[i+1][j]);
    }
    if (j!=C-1) {
      dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k]);
      if (k!=3) dp[i][j+1][k+1] = max(dp[i][j+1][k+1], dp[i][j][k]+goods[i][j+1]);
    }
  }

  ll result = *max_element(all(dp[R-1][C-1]));
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 706792
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
typedef long long ll;
using namespace std;
ll intpow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = intpow(N, P/2);
        return t*t;
    }
    return N * intpow(N, P-1);
}
ll gcd(ll n,ll m){
    n = max(n,m);
    m = min(n,m);
    if(n%m == 0)return m;
    return gcd(m,n%m);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}

int main(){
int n,cnt;
  bool flag0,flag1,flag2,flag3;
 cnt = 0;
cin >> n;
vector<int>v;
for(int i=1;i<10000000;i++){
  int target = i;
    while(target > 0){
        v.push_back(target%4);
        target = target/4;
    }
    ll sum = 0;
  flag3=flag1=flag2=0;
  flag0 = 1;
    for(int j=0;j<v.size();j++){
        if(v[j] == 0)flag0=0;
        if(v[j] == 1){sum +=3*intpow(10,j);flag1=1;}
        if(v[j] == 2){sum +=5*intpow(10,j);flag2=1;}
        if(v[j] == 3){sum +=7*intpow(10,j);flag3=1;}
    }
    if(sum>n)break;
    if(flag0 && flag1 && flag2 && flag3)cnt++;
    v.clear();
}
cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1.0e9
#define MOD 1.0e9+7
using namespace std;
typedef long long ll;

int N;
const int MAX_N = 100000;
int x[MAX_N+1];

int gcd(int a, int b) {
    int large = max(a, b);
    int small = min(a, b);
    if (small == 0) return large;
    else return gcd(small, large % small);
}

int main() {
    cin >> N;
    for (int i = 0; i < N+1; i++) cin >> x[i];
    sort(x, x+N+1);
    int diff[N];
    for (int i = 0; i < N; i++) diff[i] = x[i+1] - x[i];
    int ans = diff[0];
    for (int i = 1; i < N; i++) {
        ans = gcd(ans, diff[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i,n) for(int i = 0; i < int(n);++i)
#define pb push_back
#define vi vector<int>
#define vb vector<bool>
#define vll vector<ll>
#define sz(x) (int)x.size()
void perebor(int ind,int n,vi a){
    if(ind == n - 1){
        return;
    }

}

int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    /* ll t;
    cin >> t;
    while(t--){
    	solve();
    }*/
    ll n;
    cin >> n;
    vi d(n);
    for(auto &i: d){
        cin >> i;
    }
    int sum = 0;
    for(int i = 0; i < n-1; i++){
        for(int j = i+1; j < n;j++){
            sum += d[i] * d[j];
        }
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define ll long long
int main()
{
    ll t,r,i,j,k,l,m,a;
    double b,c,d;
    cin>>r>>t>>a;
    d=INT_MAX;
    for(i=0; i<r; i++)
    {
        cin>>k;
        b=k*0.006;
        c=t-b;
        if(abs(a-c)<d)
        {
            d=abs(a-c);
            j=i;
        }
    }
    cout<<j+1<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    int c[] = new int[50];
    int v[] = new int[50];
    int ans=0;

    for(int i=0;i<n;i++){
      v[i]=scanner.nextInt();
    }

    for(int i=0;i<n;i++){
      c[i]=scanner.nextInt();
    }

    for(int i=0;i<n;i++){
      if(v[i]-c[i]>0){
        ans+=v[i]-c[i];
      }
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
int monster[1000010];
int cnt;
int main(){
	int n;
	cin>>n;
	int x;
	for(x=1;x<=n+1;x++)
	{
		cin>>monster[x];
	}
	long long cnt=0;
	for(x=1;x<=n;x++)
	{
		int a;
		cin>>a;
		int kurang=min(a,monster[x]);
		a-=kurang;
		cnt+=kurang;
		monster[x]-=kurang;
		if(a>0)
		{
			kurang=min(a,monster[x+1]);
			a-=kurang;
			cnt+=kurang;
			monster[x+1]-=kurang;
		}
	}
	cout<<cnt<<endl;
}

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

int w,h;
int map[16][16];
int dp[16][16][4][2];

int rec(int x,int y,int state,bool str){
    if(state == 1 || x < 0 || x >= w) return 0;
    if(state == 2 && !str) return 0;
    if(y >= h-1) return 1;
    if(dp[y][x][state][str] != -1) return dp[y][x][state][str];
    int res;
    if(state == 2) res = rec(x,y+2,map[y+2][x],true);
    else res = (rec(x-1,y+1,map[y+1][x-1],false) + rec(x,y+1,map[y+1][x],true) + rec(x+1,y+1,map[y+1][x+1],false));
    return dp[y][x][state][str] = res;
}

int main(){
    while(cin >> w >> h,w||h){
        memset(dp,-1,sizeof(dp));
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++) cin >> map[i][j];
        }
        int d = 0;
        for(int i=0;i<w;i++) d += rec(i,0,map[0][i],true);
        cout << d << endl;
    }
}

Measured memory_bytes: 1168
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 30 00:17:54 2020

@author: yukio
"""


n=int(input())
lst=[int(input())for _ in range(n)]
minv=lst[0]
maxv=-float("inf")
for i in range(1,n):
    maxv=max(maxv,lst[i]-minv)
    minv=min(minv,lst[i])

print(maxv)


Measured memory_bytes: 13628
g = list(input())

sum, d, r, p = 0, 0, 0, 0
f = 0
lake_list = []

for c in g:
    if c == "\\":
        if f == 0:
            f, d, r = 1, 1, 1
        else:
            d += 1
            r += (1 + (d-1))
    elif c == "_":
        if f == 1:
            r += d
    else:
        if f == 1:
            d -= 1
            r += d
            if d == 0:
                f = 0
                sum += r
                lake_list.append([p, r])
                r = 0
    p += 1

d, r, p = 0, 0, len(g)-1
f = 0
g.reverse()

for c in g:
    if c == "/":
        if f == 0:
            f, d, r = 1, 1, 1
            pr = p
        else:
            d += 1
            r += (1 + (d-1))
    elif c == "_":
        if f == 1:
            r += d
    else:
        if f == 1:
            d -= 1
            r += d
            if d == 0:
                if [pr, r] not in lake_list:
                    sum += r
                    lake_list.append([pr, r])
                f = 0
                r = 0
    p -= 1

lake_list.sort()
print(sum)
print(len(lake_list), end="")
i = 0
while i != len(lake_list):
    print(" {}".format(lake_list[i][1]), end="")
    i += 1
print()



Measured memory_bytes: 6540
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let  s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        a:[i32;9],
        n:usize,
        b:[i32;n],
    }
    let mut a = a;
    for x in b {
        for y in a.iter_mut().filter(|z| **z == x) {
            *y = 0;
        }
    }
    for _ in a
        .chunks(3)
        .filter(|sl| sl.iter().fold(0, |s, x| s + *x) == 0)
    {
        println!("Yes");
        return;
    }
    for i in 0..3 {
        let mut s = 0;
        for j in 0..3 {
            s += a[i + j * 3];
        }
        if s == 0 {
            println!("Yes");
            return;
        }
    }
    if a[0] + a[4] + a[8] == 0 || a[2] + a[4] + a[6] == 0 {
        println!("Yes");
        return;
    }
    println!("No");
}

// fn read<T: std::str::FromStr>() -> T {
//     let mut s = String::new();
//     std::io::stdin().read_line(&mut s).unwrap();
//     s.trim().parse().ok().unwrap()
// }

// fn read_vec<T: std::str::FromStr>(n: usize) -> Vec<T> {
//     (0..n).map(|_| read()).collect::<Vec<_>>()
// }


Measured memory_bytes: 4352
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace abc176
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
            solve_abc176B();
            Console.Out.Flush();
        }

        public static void solve_abc176B()
        {
            string s = Console.ReadLine();
            int sum = 0;
            for (int i = 0; i < s.Length; i++)
            {
                sum += Convert.ToInt32(s[i].ToString());
            }
            Console.WriteLine(sum % 9 == 0 ? "Yes" : "No");
        }

        public static void solve_abc176A()
        {
            int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int w = (a[0] + a[1] - 1) / a[1];
            Console.WriteLine(w * a[2]);
        }
    }
}

Measured memory_bytes: 33912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
typedef pair<ll,ll> ll_pair;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define MAX_V 100001
#define INF (1e9+1)
struct edge{
	int to,cost;
};
int V,E,r,a,b,c;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(){
	FOR(i,0,MAX_V)d[i]=INF;
	d[r]=0;
	priority_queue< pair<int,int> > Q;
	Q.push( make_pair(0,r) );
	while(Q.size()){
		pair<int,int> p=Q.top();
		Q.pop();
		int cost=-p.first,es=p.second;
		if(cost>d[es])continue;
		FOR(i,0,G[es].size()){
			edge e=G[es][i];
			int to=e.to;
			int newcost=cost+e.cost;
			if(newcost<d[to]){
				d[to]=newcost;
				Q.push(make_pair(-d[to],to));
			}
		}
	}
	FOR(i,0,V){
		if(d[i]==INF)cout<<"INF"<<endl;
		else cout<<d[i]<<endl;
	}
}



int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>V>>E>>r;
	FOR(i,0,E){
		cin>>a>>b>>c;
		G[a].push_back((edge){b,c});
	}
	dijkstra();
	return 0;
}



Measured memory_bytes: 12948
#include <iostream>

using namespace std;

int
main()
{
  int a, b;
  cin >> a >> b;
  if (a % 2 == 0 || b % 2 == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
def YesNo(b):
    print("Yes" if b else "No")


def solve(v, l, ini):
    ml = 8000*2+1
    dp = [[False]*ml for i in range(len(l)+1)]
    for i in range(len(ini)):
        dp[0][ini[i]+8000] = True
    for i in range(1, len(l)+1):
        for j in range(ml):
            if (j+l[i-1]) < ml and dp[i-1][j]:
                dp[i][j+l[i-1]] = True
            if (j-l[i-1]) >= 0 and dp[i-1][j]:
                dp[i][j-l[i-1]] = True
    return dp[len(l)][v+8000]


s = input()
x, y = map(int, input().split())
si = 0
while si < len(s) and s[si] == 'F':
    si += 1

s = s[si:]
if len(s) == 0:
    YesNo(x == si and y == 0)
else:
    f = s.split('T')[1:]
    xl, yl = [0], [0]
    for i in range(len(f)):
        if len(f[i]) == 0:
            continue
        if i % 2 == 0:
            yl.append(len(f[i]))
        else:
            xl.append(len(f[i]))

    YesNo(solve(x, xl, [si]) and solve(y, yl[1:], [-yl[0], yl[0]]))


Measured memory_bytes: 467296
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<random>
using namespace std;


int main()
{
	int N, M, T;
	cin >> N >> M >> T;
	vector<int> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	vector<int> m(T, 1);
	for (int i = 0; i < N; ++i) {
		int idx = a[i];
		for (int j = 0; j < M; ++j) {
			if(idx - j - 1 >= 0) m[idx - j - 1] = 0;
			if(idx + j < T) m[idx + j] = 0;
		}
	}
	int ans = accumulate(begin(m), end(m), 0);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3132
import java.util.*;

public class Main{
        
	public static void main (String[] args) throws java.lang.Exception { 
             Scanner sc = new Scanner(System.in);
                          
            String S = sc.next();
              
            int a[] = new int[26];
            
            for(int i = 0;i < S.length();i++){
                   char ch = S.charAt(i);   
                   
                   a[(char)ch - 'a']++;
                                      
            }      
            
            for(int i = 0;i < 26;i++){
                if(a[i] >= 2){
                    System.out.println("no");
                    return;
                }
            }
            
            System.out.println("yes");
                
        }        
}
               
         
        

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

int main(){
int n;
cin >> n;
vector<int> a(0);
vector<int> b(0);
vector<int> c(0);

int in;
  
for(int i=0;i<n;i++){
  cin >> in;
  a.push_back(in);
}

for(int i=0;i<n;i++){
  cin >> in;
  b.push_back(in);
}

for(int i=0;i<n-1;i++){
  cin >> in;
  c.push_back(in);
}

int ans = 0;

for(int i=0;i<n;i++){
  ans += b.at(a.at(i) - 1);
  if(i > 0){
  if(a.at(i) - a.at(i-1) ==1){
    ans += c.at(a.at(i-1) - 1);
  }
  }
}

cout << ans << endl;

}

Measured memory_bytes: 256