akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

// Low Linkを計算して橋と関節点を見つける
// ref : http://kagamiz.hatenablog.com/entry/2013/10/05/005213
struct low_link
{
    int n, m;
    vector<vector<int>> G;
    vector<pair<int, int>> bridge;
    vector<int> articulation;
    vector<int> ord, low;
    vector<bool> vis;

    low_link(vector<vector<int>> G, int n, int m) : G(G), n(n), m(m)
    {
        ord.resize(n);
        low.resize(n);
        vis.resize(n);

        int k = 0;
        REP(i, n){
            if(!vis[i]) dfs(i, -1, k);
        }

        SORT(bridge);
        SORT(articulation);
    }

    vector<pair<int, int>> get_bridge(){
        return bridge;
    }

    vector<int> get_articulation(){
        return articulation;
    }

private:
    void dfs(int v, int p, int &k)
    {
        vis[v] = true;
        
        ord[v] = k++;
        low[v] = ord[v];
        
        bool isArticulation = false;
        int ct = 0;
        
        // for (int i = 0; i < G[v].size(); i++){
        for (auto&& c : G[v]){
            if (!vis[c]){
                ct++;
                dfs(c, v, k);
                low[v] = min(low[v], low[c]);
                if (~p && ord[v] <= low[c]) isArticulation = true;
                if (ord[v] < low[c]) bridge.push_back(make_pair(min(v, c), max(v, c)));
            }
            else if (c != p){
                low[v] = min(low[v], ord[c]);
            }
        }
        
        if (p == -1 && ct > 1) isArticulation = true;
        if (isArticulation) articulation.push_back(v);
    }
};

int main(void)
{
    int v,e;
    cin >> v >> e;
    vector<vector<int>> G(v);
    REP(i, e){
        int s,t;
        cin >> s >> t;
        G[s].pb(t);
        G[t].pb(s);
    }

    low_link low(G, v, e);
    // auto b = low.get_bridge();
    // for(auto&& bi : b){
    //     pr(bi.fi, bi.se);
    // }
    auto a = low.get_articulation();
    for(auto&& ai : a){
        pr(ai);
    }
}


Measured memory_bytes: 5664
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char s[200005][16];
int cmp(const void*a,const void*b){return strcmp(s[*(int*)a],s[*(int*)b]);}
int main(){
    int n,i;
    int c[200050];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s",s[i]);
            c[i]=i;
    }
    qsort(c,n,sizeof(int),cmp);
    int a[200005];
    a[c[0]]=1;
    for(i=1;i<n;i++){
        if(strcmp(s[c[i]],s[c[i-1]])==0)
            a[c[i]]=a[c[i-1]]+1;
        else
            a[c[i]]=1;
    }
    int max=0;
    for(i=0;i<n;i++)
        if(a[i]>max)
            max=a[i];
    for(i=0;i<n;i++)
        if(a[c[i]]==max)
            printf("%s\n",s[c[i]]);
    return 0;
}

Measured memory_bytes: 6636
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var D = int.Parse(Console.ReadLine());
        var map = new Dictionary<int, string>();
        map.Add(25, "Christmas");
        map.Add(24, "Christmas Eve");
        map.Add(23, "Christmas Eve Eve");
        map.Add(22, "Christmas Eve Eve Eve");

        Console.WriteLine(map[D]);
    }


}



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

using namespace std;

#define PB push_back
#define f first
#define s second

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

const int N = 300005;

map<ll, ll> ct;
ll a[N];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    for(int i=1; i<=n; i++)
    {
        cin >> a[i];
        ct[a[i]+i]++;
    }
    ll ans = 0;
    for(int i=n; i>=1; i--)
    {
        ll x = i-a[i];
        ans += ct[x];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 27884
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
using namespace std;

typedef long long ll;

const int mod = 1000000007;
const int Maxn = 2005;

int C[Maxn][Maxn];
int a, b;
int res;

int main()
{
	for (int i = 0; i < Maxn; i++) {
		C[i][0] = C[i][i] = 1;
		for (int j = 1; j < i; j++)
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
	}
	scanf("%d %d", &a, &b);
	res = (res + a + 1) % mod;
	for (int z1 = 1; z1 < b; z1++) {
		int mult1 = C[b - 1][z1];
		int la = a - z1;
		if (la >= 0) {
			res = (res + ll(la + 1) * (la + 2) / 2 % mod * ll(mult1)) % mod;
			for (int z2 = 1; z2 < z1; z2++) {
				int mult2 = ll(mult1) * C[z1 - 1][z2] % mod;
				int ra = la - z2;
				if (ra >= 0)
					res = (res + ll(ra + 1) * (ra + 2) / 2 % mod * ll(mult2)) % mod;
			}
		}
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 15232
#include <iostream>

using namespace std;

int main(void) {
    int A, B, K;
    cin >> A >> B >> K;
    for(int i=A; i<=B; i++) {
        if((A <= i && i < A+K) || (B-K < i && i <=B))
        cout << i << endl;
    }
    return 0;
}


Measured memory_bytes: 256
program AGC032A
    implicit none
    integer(8)::N,i,j
    integer(8)::flg=0
    integer(8)::same,count
    integer(8),allocatable,dimension(:)::A,B

    read(5,*)N
    allocate(A(N))
    allocate(B(N))
    read(5,*)(B(i),i=1,N)

    do i=1,N
        if(B(i)>i)then
            flg=1
        end if
    end do

    if(flg==1)then
        print'(i0)',-1
    else
        do i=1,N
            same=1
            count=1
            do j=1,N
                if(B(j)/=0)then
                    if(B(j)==count)then
                        same=j
                    end if
                    count=count+1
                end if
            end do
            
            A(i)=B(same)
            B(same)=0
        end do

        do i=1,N
            print'(i0)',A(N-i+1)
        end do
    end if
    
end program AGC032A

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>

using namespace std;

int dp[10000][100];

int main(void) {
    int N,W,v[200],w[200],res=0;
    scanf("%d%d",&N,&W);
    for(int i=0; i<N; i++)
        scanf("%d%d",&v[i],&w[i]);

    for(int i=0; i<N; i++) {
        for(int j=0; j<w[i]; j++)
            dp[j][i+1] = dp[j][i];
        for(int j=w[i]; j<=W; j++)
            dp[j][i+1] = max(dp[j-w[i]][i+1]+v[i],max(dp[j-w[i]][i]+v[i], dp[j][i]));
    }
    for(int j=0; j<=W; j++)
        res = max(res, dp[j][N]);
    printf("%d\n", res);

    return 0;
}

Measured memory_bytes: 4928
#include <iostream>
#include <map>


using namespace std;
int main(){
  int N;
  cin >> N;
  
  int a[N];
  map<int, int> mp;
  
  for(int i=0;i<N;i++){
    cin >> a[i];
    mp[a[i]] ++;}
  
  int answer=0;
  
  for(auto p:mp){
    if (p.second < p.first) answer += p.second; 
    else answer += (p.second - p.first);}
  
  cout << answer;
  
  
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

bool dfs(const vector<vecint>&g, vecint& vis, int i, int k) {
  int n=g.size();
  REP(j,n) {
    if (g[i][j]) {
      if (vis[j] == 0) {
        vis[j] = -k;
        if (!dfs(g, vis, j, -k)) return false;
      } else if (vis[j] == k) return false;
    }
  }
  return true;
}

int main()
{
  int n,m;
  cin>>n>>m;
  vector<vecint> g(n, vecint(n, 1));
  REP(i,n) g[i][i] = 0;
  REP(i,m) {
    int a,b;
    cin>>a>>b;
    --a;--b;
    g[a][b] = 0;
    g[b][a] = 0;
  }
  REP(i,n){
    REP(j,n) {
      cerr<<g[i][j];
    }
    cerr<<endl;
  }
  vecint vis(n, 0);
  int k = 1;
  REP(i,n) {
    if (vis[i] == 0) {
      vis[i] = k;
      if (!dfs(g, vis, i, k)) {
        cout<<-1<<endl;
        return 0;
      }
      ++k;
    }
  }
  map<int,int> num;
  REP(i,n) {
    ++num[vis[i]];
  }
  vecint d(k);
  REP(i,k) {
    int pos = num[i];
    int neg = num[-i];
    d[i] = abs(pos - neg);
  }
  vector<bool> dp(2*n-1, false);
  int offset = n;
  dp[offset] = true;
  REP(i,k) {
    vector<bool> tmp(2*n + 1, false);
    REP(j,2*n+1) {
      int down = j-d[i];
      if (down >= 0) {
        tmp[down] = tmp[down] || dp[j];
      }
      int up = j+d[i];
      if (up <= 2*n) {
        tmp[up] = tmp[up] || dp[j];
      }
    }
    swap(dp, tmp);
  }
  int md = 2*n;
  REP(i,n+1) {
    if (dp[i+offset]) md = min(md, i);
  }
  int a = (n-md) / 2, b = (n+md) / 2;
  int ans = a * (a-1) / 2 + b * (b-1) / 2;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2304
#include <iostream>

using namespace std;

int main()
{
  char s[4];
  int ans = 0;
  
  cin >> s;
  
  for (int i = 0; i < 4; i++) {
    if (s[i] == '-') {
      ans--;
    }
    else {
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a+b==15)
		puts("+");
	else if(a*b==15)
		puts("*");
	else
		puts("x");	
	return 0;
	
}

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

int main() {
  int a , b , c , d;
  cin >> a >> b >> c >> d;
  while ( a > 0 ){
    c = c-b;
    if ( c<=0 ){
      break;
    }
    a = a-d;
  }
  if( c<=0 ){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
// https://atcoder.jp/contests/abc159/tasks/abc159_d

#include <iostream>
#include <vector>

using namespace std;

int N;
vector<int> A;

long long nC2(int n) {
    if (n <= 1) return 0;
    return (long long)n * (n-1) / 2;
}

void solve() {
    long long all = 0;
    vector<int> count(N + 1, 0);
    for (int i = 0; i < A.size(); ++i) {
        count[A[i]]++;
    }
    for (int i = 0; i < count.size(); ++i) {
        all += nC2(count[i]);
    }
    for (int i = 0; i < A.size(); ++i) {
        long long diff = nC2(count[A[i]]) - nC2(count[A[i]] - 1);
        cout << all - diff << endl;
    }
}

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

    cin >> N;
    A.assign(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    solve();

    return 0;
}

Measured memory_bytes: 4224
def modpow(a, n, mod):
    if n == 0:
        return 1
    else:
        if n % 2 == 0:
            return (modpow((a * a)%mod, n//2, mod)) % mod
        else:
            return ((a%mod) * modpow(a, n-1, mod)) % mod

# modが素であるとする
def modinv(a, mod):
    return modpow(a, mod-2, mod) % mod

def moddiv(a, b, mod):
    return ((a%mod) * modinv(b, mod)) % mod

def modbase(n, k, mod):
    fact = [1 for _ in range(n+1)]
    inv = [1 for _ in range(n+1)]
    finv = [1 for _ in range(n+1)]

    for i in range(2, n+1):
        fact[i] = (fact[i-1] * i) % mod
        inv[i] = (-inv[mod % i] * (mod // i)) % mod
        finv[i] = (finv[i-1] * inv[i]) % mod
    return fact, inv,finv


N, M, K = [int(i) for i in input().split()]
mod = 998244353
# N-1 V K
fact, inv, finv = modbase(N-1, K, mod)
dic = {}
dic[0] = 1
for k in range(1, K+1):
    dic[k] = fact[N-1] * (finv[k] * finv[N-k-1] % mod) % mod

sum = 0
for k in range(K+1):
    sum += M * (modpow(M-1 , N-1-k, mod) * dic[k] % mod) % mod
    sum %= mod
print(sum)


Measured memory_bytes: 123136
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var n = int.Parse(spl[0]);
        var m = int.Parse(spl[1]);

        route = new List<int>[n];
        for(int i=0; i<n; i++) {
            route[i] = new List<int>();
        }
        for(int i=0; i<m; i++) {
            spl = input.ReadLine().Split(' ');
            var a = int.Parse(spl[0])-1;
            var b = int.Parse(spl[1])-1;
            route[a].Add(b);
            route[b].Add(a);
        }

        Arrows = new int[n];
        Costs = new long[n];
        FillArray(Costs, long.MaxValue);
        Costs[0] = 0;

        //Search(0, -1, -1);
        Search();

        var sb = new StringBuilder();
        sb.AppendLine("Yes");
        for(int i=1; i<n; i++) {
            sb.AppendLine((Arrows[i] + 1).ToString());
        }

        return sb;
    }

    public static List<int>[] route;
    public static int[] Arrows;
    public static long[] Costs;

    static void Search() {
        var q = new Queue<int>();

        //最初の要素追加
        foreach (var nu in route[0]) {
            Costs[nu] = 1;
            Arrows[nu] = 0;
            q.Enqueue(nu);
        }

        while (q.Any()) {
            var x = q.Dequeue();

            foreach(var next in route[x]) {
                if(Costs[next] == long.MaxValue) {
                    Costs[next] = Costs[x] + 1;
                    Arrows[next] = x;

                    q.Enqueue(next);
                }
            }
        }
    }

    //static void Search2(int p, int from, long cost) {
    //    //Debug.WriteLine(x);

    //    //探索終了判定
    //    if (from < 0 || (cost + 1) < Costs[p]) {
    //        Costs[p] = cost + 1;
    //        Arrows[p] = from;
    //    } else {
    //        return;
    //    }

    //    //次の再帰
    //    foreach (var next in route[p]) {
    //        if (next != from) {
    //            Search(next, p, Costs[p]);
    //        }
    //    }
    //}

    static void FillArray<T>(T[] array, T value) {
        for (int i = 0; i < array.Length; i++)
            array[i] = value;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 52544
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

int main() {
  int A,B;
  cin >> A >> B;
  if(B%A == 0) cout << A+B << endl;
  else cout << B-A << endl;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

dp = [1] * n
dp[0] = 0

for i in range(1, n):
    if i == 1:
        dp[i] = abs(h[i] - h[i-1])
    else:
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))

print(dp[n-1])

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

int n;
int a[250005];
int id[505][505];
int dis[505][505],res[505][505];
bool lgl[505][505];
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			dis[i][j]=min(min(i-1,n-i),min(j-1,n-j));
		}
	}
	for(int i=1;i<=n*n;i++){
		int s;
		scanf("%d",&s);
		int x=(s-1)/n+1,y=(s-1)%n+1;
		res[x][y]=dis[x][y];
		lgl[x][y]=1;
		queue<pair<int,int>> q;
		q.emplace(x,y);
		while(q.size()){
			pair<int,int> T=q.front();
			q.pop();
			int x=T.first,y=T.second;
			int to=dis[x][y]+(!lgl[x][y]);
			for(int i=0;i<4;i++){
				int nx=x+dx[i],ny=y+dy[i];
				if(nx<1||nx>n||ny<1||ny>n){
					continue;
				}
				if(dis[nx][ny]>to){
					dis[nx][ny]=to;
					q.emplace(nx,ny);
				}
			}
		}
	}
	int sum=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			sum+=res[i][j];
		}
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 5980
#include<stdio.h>
int main(){
	int n;
	scanf("%d",&n);
	int A[n];
	int i,j;
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	int swap=0,sort;
	for(i=0;i<n;i++){
		for(j=1;j<n;j++){
			if(A[j-1]>A[j]){
				sort=A[j];
				A[j]=A[j-1];
				A[j-1]=sort;
				swap++;
			}
		}
	}
	for(i=0;i<n;i++){
		printf("%d",A[i]);
		if(i+1!=n){
			printf(" ");
		}
	}
	printf("\n");
	printf("%d\n",swap);
	return 0;
}



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

public class Main {
	static final int MOD = 1_000_000_007;
    public static long addMod(long a, long b){
    	long tmp = (a+b)%MOD;
    	return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long subMod(long a, long b){
    	return addMod(a,-b);
    }
    public static long multMod(long a, long b){
    	long tmp = (a*b)%MOD;
    	return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long powerMod(long a, long x){ //calculate a^x
        if(x<0)return 0;
        if(x==0)return 1;
        if(x%2==0) {
        	long half = powerMod(a,x/2);
        	return multMod(half,half);
        }
        return (a*powerMod(a,x-1)) % MOD;
    }
    public static long inverseMod(long a){
        return powerMod(a,MOD-2);
    }
    public static long divMod(long a, long b){
    	return multMod(a, inverseMod(b));
    }
    public static long[] makeFactorialArray(int size){
        long[] array = new long[size];
        array[0]=1;
        for(int i=1;i<size;i++){
        	array[i]=multMod(array[i-1],i);
        }
        return array;
    }
    public static long[] makeInversedArray(long[] original){
        long[] array = new long[original.length];
        for(int i=0;i<original.length;i++){
        	array[i] = inverseMod(original[i]);
        }
        return array;
    }
    public static long combination(int n, int r, long[] fact, long[] factInv){
        return multMod(fact[n], multMod(factInv[r],factInv[n-r]));
    }
    
    public static long access(long[] array, int index){
    	if(index<0 || index>=array.length) return 1;
    	else return array[index];
    }
    
    public static long solve(int H, int W, int K){
    	long[][] dp = new long[H+1][W];
    	Arrays.fill(dp[0], 0); dp[0][0]=1;
    	//System.out.println(Arrays.toString(dp[0]));
    	
    	long[] simpleBar = new long[]{1,2,3,5,8,13,21,34,55};
    	
    	for(int h=1;h<=H;h++){
    		for(int w=0;w<W;w++){
    			dp[h][w] += multMod(dp[h-1][w], multMod(access(simpleBar,w-1), access(simpleBar,W-w-2)));
    			dp[h][w] %= MOD;
    			if(w>0) {
    				dp[h][w-1] += multMod(dp[h-1][w], multMod(access(simpleBar,w-2), access(simpleBar,W-w-2)));
    			    dp[h][w-1] %= MOD;
    			}
    			if(w<W-1){
    			    dp[h][w+1] += multMod(dp[h-1][w], multMod(access(simpleBar,w-1), access(simpleBar,W-w-3)));
    			    dp[h][w] %= MOD;	
    			} 
    		}
    		//System.out.println(Arrays.toString(dp[h]));
    	}
    	return dp[H][K];
    }
    
    public static void main(String[] args) {
    	long[] fact = makeFactorialArray(200001);
        long[] factInv = makeInversedArray(fact);
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int K = sc.nextInt()-1;
        System.out.println(solve(H,W,K));
        
    }
}

Measured memory_bytes: 26068
n,m=map(int,input().split())
a=[int(input()) for _ in range(n)]
for i in range(1,m+1):
    for j in range(n-1):
        if a[j]%i>a[j+1]%i:a[j],a[j+1]=a[j+1],a[j]
for i in a:print(i)

Measured memory_bytes: 7744
#pragma warning(disable:4996)
#include "bits/stdc++.h"
using namespace std;

//macro
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,a,b) for(int i=(int)(b) - 1;i>=(int)(a);i--)
#define rrep(i,n) RREP(i,0,n)
#define each(i, ctn) for (auto &&i : (ctn))
#define all(a) (a).begin(),(a).end()
#define mp make_pair
#define INF 114514810
#define INFL 1145148100000000000LL
#define EPS (1e-8)
#define MOD 1000000007
#define PI 3.141592653589793
#define equals(a,b)(fabs((a)-(b))<EPS)

//alias
using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<ll>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vs = vector<string>;
using P = pair<ll, ll>;
template<class T> using heap = priority_queue<T>;
template<class T> using minheap = priority_queue<T, vector<T>, greater<T>>;

//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H);	rep(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n)os << v[i] << (i == n - 1 ? "\n" : " "); return os; }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template<class T> inline void print(const T &x) { cout << x << '\n'; }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;



int main() {
	ull N, M;
	cin >> N >> M;
	ull T = (N - M) * 100 + 1900 * M;
	ull p = pow(2, M);

	ull ans = T * p;
	print(ans);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll a[5000];
  string s;
  cin >> s;
  rep(i,26)a[i]=0;
  rep(i,s.length())a[s[i]-'a']++;
  rep(i,26){
    if(a[i]>1){
      printf("no");
      return 0;
    }
  }
  printf("yes");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll N = S.size();
    rrep(t,N,1){
        rep(i,0,N-t+1){
            bool ok = true;
            rep(k,i,i+t){
                if(S[k] == 'A' || S[k] == 'G' || S[k] == 'T' || S[k] == 'C'){
                }else{
                    ok = false;
                }

            }
            if(ok){
                print(t);
                return 0;
            }
        }
    }
    print(0);

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fst first
#define scd second
constexpr long long mod = 1000000007;
int c[200000], nx[200000], a[200001];
long long dp[200001];
int main()
{
	int n;	
	scanf("%d", &n);
	for(int i = 0; i < n; ++i)
	{
		scanf("%d", &c[i]);
	}
	for(int i = 0; i <= 200000; ++i)
	{
		a[i] = n + 1;
	}
	for(int i = n - 1; i >= 0; --i)
	{
		nx[i] = a[c[i]];
		a[c[i]] = i;
	}
/*	for(int i = 0; i < n; printf("%d ", nx[i++])){}
	printf("\n");*/
	dp[0] = 1;
	for(int i = 0; i < n; ++i)
	{
		//printf("%lld ", dp[i]);
		(dp[i + 1] += dp[i]) %= mod;
		if(nx[i] != i + 1)
		{
			(dp[nx[i]] += dp[i]) %= mod;
		}
	}
	printf("%lld\n", dp[n]);
}

Measured memory_bytes: 4096
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<queue>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;
//include<kyawa>
long dx[4] = { 0,1,0,-1 };
long dy[4] = { 1,0,-1,0 };

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

int main() {

	long H, W; cin >> H >> W;
	long res = 0;

	queue<pair<pair<long , long>, long>> imfo;//<<座標>最短距離>のキュー

	bool visited[2000][2000]; for (int i = 0; i <= 1500; i++) for (int j = 0; j <= 1500; j++) visited[i][j] = true;//初期値をtrueとする
	for (int i = 1; i <= H; i++) for (int j = 1; j <= W; j++){
	char a; cin >> a; 
    if (a == '.') visited[i][j] = false; else imfo.push(make_pair(make_pair(i, j), 0));//訪問済みか?
	}

	while (not imfo.empty()) {
		pair<pair<long, long>, long> nowimfo; nowimfo = imfo.front(); imfo.pop();//先頭の要素を代入->削除

		long x, y, now; //先頭の要素のパラメータ
		x = nowimfo.first.first;
		y = nowimfo.first.second;
		now = nowimfo.second;

		for (int s = 0; s < 4; s++) {
			if (visited[x + dx[s]][y + dy[s]]) continue;

			imfo.push(make_pair(make_pair(x + dx[s], y + dy[s]), now + 1));
            visited[x + dx[s]][y + dy[s]] = true;
    	}
        res = max(res,now);
	}

	cout << res << endl;
}

Measured memory_bytes: 27316
from heapq import heappush, heappop

def dijkstra(adjList, s):
    num = len(adjList)
    dist = [float("INF") for i in range(10)]
    queue = []
    heappush(queue,(0,s))
    dist[s] = 0
    
    while queue != []:
        v_cost, v = heappop(queue)
        if dist[v] < v_cost:
            continue
        for u_cost, u in adjList[v]:
            if u != v and u_cost + dist[v] < dist[u]:
                dist[u] = u_cost + dist[v]
                heappush(queue, (dist[u], u))
    return dist


from sys import stdin
def IL():return list(map(int, stdin.readline().split()))

h,w = IL()
G = [[] for i in range(10)]

for i in range(10):
    l = IL()
    for j in range(10):
        G[i].append((l[j],j))


ans = 0
memo={}
for i in range(h):
    for i in IL():
        if abs(i) == 1:
          pass
        elif i in memo:
          ans += memo[i]
        else:
            t = dijkstra(G, i)[1] 
            memo[i] = t
            ans += t

print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes                \
    cout << "Yes" << endl; \
    return 0;
#define No                \
    cout << "No" << endl; \
    return 0;
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template <typename T>
void print(const T &v);

int main()
{
    int N;
    cin >> N;
    vector<int> x(N), y(N);
    rep(i, N) cin >> x[i] >> y[i];
    double total = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            double dist = sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
            total += dist;
        }
    }
    cout << fixed << setprecision(10) << total * 2 / N << endl;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
n = int(input())
dp = [0] * (n+1)
mod = 10**9+7
dp[0] = n
dp[1] = n*n
SUM = n+n*n
for i in range(2,n):
  dp[i] = (n-1)*(n-1) + n-i+1+SUM-dp[i-2]
  dp[i] %= mod
  SUM += dp[i]
  SUM %= mod
print(dp[n-1])

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

using namespace std;

const int MaxN = 55;

vector <long long> a[MaxN][MaxN];
vector <long long> v[MaxN];

int a1[MaxN], a2[MaxN];

long long mask;

long long maxBit(long long mask)
{
    for(int bit = 51; bit; --bit)
        if((1ll << bit) & mask)
            return 1ll << bit;
}

void go(int x, int y, vector <long long> & a)
{
    if(x < y)
        return;
    if(x == y)
    {
        a.push_back(mask);
        return;
    }

    for(int i = 1; i <= x; ++i)
    {
        mask |= (1ll << i);

        go(x % i, y, a);

        mask ^= (1ll << i);
    }
}


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

    for(int i = 0; i <= 50; ++i)
        for(int j = 0; j <= 50; ++j)
            go(i, j, a[i][j]);

    int n;
    cin >> n;
    for(int i = 1; i <= n; ++i)
        cin >> a1[i];
    for(int i = 1; i <= n; ++i)
    {
        cin >> a2[i];
        v[i] = a[a1[i]][a2[i]];
        if(v[i].empty())
            return cout << -1 << '\n', 0;
    }

    long long ans = 0;

    while(true)
    {
        bool OK = true;

        long long minBit = 0;

        for(int i = 1; i <= n; ++i)
        {
            bool _OK = false;

            for(long long x : v[i])
                if(!x)
                {
                    _OK = true;
                    break;
                }

            if(_OK)
                continue;

            OK = false;

            long long curMin = (1ll << 51);

            for(long long x : v[i])
                curMin = min(curMin, maxBit(x));

            if(curMin == 51)
                return cout << -1 << '\n', 0;

            minBit = max(minBit, curMin);
        }

        if(OK)
            break;

        ans |= minBit;

        for(int i = 1; i <= n; ++i)
        {
            bool _OK = false;

            for(long long x : v[i])
                if(!x)
                {
                    _OK = true;
                    break;
                }

            if(_OK)
                continue;

            for(int j = 0; j < v[i].size(); ++j)
            {
                if(maxBit(v[i][j]) > minBit)
                {
                    v[i].erase(v[i].begin() + j);
                    --j;
                    continue;
                }
                if(maxBit(v[i][j]) == minBit)
                    v[i][j] ^= minBit;
            }
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>

typedef struct tag_posn {
	double x;
	double y;
} posn;

int main(void) {
	posn input[4];
	int i;

	while(scanf("%lf %lf", &input[0].x, &input[0].y) != EOF) {
		for(i = 1; i < 4; i++) {
			scanf("%lf %lf", &input[i].x, &input[i].y);
		}

		if(input[0].x <= input[3].x && input[2].x <= input[1].x) {
			if(input[0].y <= input[3].y && input[2].y <= input[1].y)
				printf("YES\n");
			else
				printf("NO\n");
		}

		else
			printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 612
import sys

S = list(input())

length = 0
maxlen = 0

for s in S:
	if s == 'A' or s == 'T' or s == 'C' or s == 'G' :
		length += 1
		maxlen = max(maxlen,length)
	else :
		length = 0

print(maxlen)




Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M = 2e5+5;
int ct[M];
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	for(int i=0;i<n;i++)
	{
		ct[i+1]=ct[i];
		if(s[i]=='R')
			ct[i+1]++;
	}
	int ans = 1e6;
	for(int i=0;i<=n;i++)
	{
		int w = i-ct[i];
		int r = ct[n]-ct[i];
		ans = min(ans,max(w,r));
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 4492
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll a, b;
    cin >> a >> b;
    if (a * b < 0)
    {
        cout << "Zero" << endl;
        return 0;
    }
    if (a + b > 0)
    {
        cout << "Positive" << endl;
    }
    else
    {
        if ((b - a + 1) % 2)
        {
            cout << "Negative" << endl;
        }
        else
        {
            cout << "Positive" << endl;
        }
    }
}

Measured memory_bytes: 256
from sys import stdin
from math import atan

def input():
    return stdin.readline()[:-1]


def intput():
    return int(input())


def sinput():
    return input().split()


def intsput():
    return map(int, sinput())


a, b, x = intsput()

if x / a > 0.5 * a * b:
    print(atan((2 * a ** 2 * b - 2 * x) / a ** 3) / 3.14159265358979 * 180)
else:
    print(atan(a * b ** 2 / 2 / x) / 3.14159265358979 * 180)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){

    long long int N,i;
    cin >> N;

    for(i = 0; i < N + 1; i++) {
        long long int y = i * i;
        if(y > N) {
            break;
        }
    }

    cout << (i - 1) * (i - 1) << endl;

    return 0;
}


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

int main(){
        int q=0;
        int command,value;
        cin >> q;
        vector<int> A;
        for(int i = 0;i<q;i++){
                cin >> command;
                if(command==0){
                        cin >> value;
                        A.push_back(value);
                }
                if(command==1){
                        cin >> value;
                        cout << A[value] << endl;
                }
                if(command==2){
                        A.pop_back();
                }

        }
        return 0 ;

}



Measured memory_bytes: 3832
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#pragma optimize("TKACHENKO-GORYACHENKO")
#define psl pair <string, ll>
#define pls pair <ll, string>
#define x first
#define y second
#pragma GCC optimize("O3")
#define plll pair <pair <ll, ll>, ll>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
 
typedef long long ll;
 
typedef long double ld;
 
using namespace std;
 
const ll maxn = 1e6;
 
ll n, m, k, t;

map <string, ll> M;

ll T[maxn];
 
int main()
{
	ll q, w, e, a, b, c, d;
	pyshnapyshnakaa;
	cin >> n;
	string s;
	for (q = 0; q < n; q++) {
		cin >> s >> T[q];
		M[s] = q; 
	}
	cin >> s;
	ll i = M[s];
	ll ans = 0;
	for (q = i + 1; q < n; q++) {
		ans += T[q];
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,x,n) for(int i=x;i<n;i++)
#define breps(i,x,n) for(int i=x;i>=n;i--)
#define exrep(x,vec) for(auto&& x : vec);
#define PI 3.14159265358979323846264338327950288
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)
typedef long long ll;
using namespace std;

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	int N, M; cin >> N >> M;
	vector<pair<int, int>> student(N);
	vector<pair<int, int>> point(M);
	rep(i, N) cin >> student[i].first >> student[i].second;
	rep(i, M) cin >> point[i].first >> point[i].second;

	rep(i, N) {
		int ans = -1;
		int D = inf;
		rep(j, M) {
			int d = abs(student[i].first - point[j].first) + abs(student[i].second - point[j].second);
			if (D > d) {
				D = d;
				ans = j + 1;
			}
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	string s,t;
	cin>>s>>t;
	ll n = s.size(), m = t.size();
	ll ans = m;
	for(ll i=0;i<=n-m;i++){
		ll count=0;
		for(ll j=i,k=0;k<m;j++,k++){
			if(s[j] != t[k])	count++;
		}
		ans = min(ans, count);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <bitset>
#include <set>

using ll = long long;
using namespace std;

int main(void) {
	int n;
	cin >> n;
	
	if( n % 2 == 0 ) cout << n / 2 << endl;
	else cout << n / 2 + n % 2 << endl;
		
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
  
int main(){
      
    string str;
    int a = 0, i = 0;
      
    while(1){
      
        cin >> str;
          
        if(str == "0")break;
          
        for(i = 0; i < str.size(); ++i){
          
            a += str[i] - '0';
        }
          
        cout << a << endl;
        a = 0;
    }
      
    return 0;
}


Measured memory_bytes: 3200
#include <iostream>

using namespace std;

/*
x = lcm(a1, ..., an);
*/

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n, v, sum = 0;
    cin >> n;
    while(n-- > 0){
        cin >> v;
        sum += v - 1;
    }
    cout << sum << '\n';
    return 0;
}


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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;

    int dx1 = tx - sx;
    int dy1 = ty - sy;

    string s1, s2;

    for (int i = 0; i < dx1; ++i) {
        s1 += 'R';
        s2 += 'L';
    }

    for (int i = 0; i < dy1; ++i) {
        s1 += 'U';
        s2 += 'D';
    }

    string s3, s4;

    s3 += 'L';
    s4 += 'R';

    for (int i = 0; i < dy1+1; ++i) {
        s3 += 'U';
        s4 += 'D';
    }

    for (int i = 0; i < dx1+1; ++i) {
        s3 += 'R';
        s4 += 'L';
    }

    s3 += 'D';
    s4 += 'U';

    cout << s1 + s2 + s3 + s4 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
const int INF = 1e8;
using namespace std;

const int MAX_V = 10005;

class Edge{
	public:
		int to, cap, rev;
		Edge(int to, int cap, int rev) : to(to), cap(cap), rev(rev) {}
};

class Flow{
	private:
		vector<Edge> G[MAX_V];
		bool used[MAX_V];
		int level[MAX_V]; //sからの距離
		int iter[MAX_V]; //どこまで調べ終わったか
		int dfs(int v, int t, int f){
			if(v == t) return f;
			used[v] = true;
			rep(i,G[v].size()){
				Edge &e = G[v][i];
				if(not used[e.to] && e.cap > 0){
					int d = dfs(e.to, t, min(f, e.cap));
					if(d > 0){
						e.cap -= d;
						G[e.to][e.rev].cap += d;
						return d;
					}
				}
			}
			return 0;
		}
		int dfs_(int v, int t, int f){
			if(v == t) return f;
			for(int &i = iter[v]; i < G[v].size(); i++){
				Edge &e = G[v][i];
				if(e.cap > 0 && level[v] < level[e.to]){
					int d = dfs_(e.to, t, min(f, e.cap));
					if(d > 0){
						e.cap -= d;
						G[e.to][e.rev].cap += d;
						return d;
					}
				}
			}
			return 0;
		}
		void bfs(int s){
			memset(level, -1, sizeof(level));
			queue<int> que;
			level[s] = 0;
			que.push(s);
			while(not que.empty()){
				int v = que.front(); que.pop();
				rep(i,G[v].size()){
					Edge &e = G[v][i];
					if(e.cap > 0 && level[e.to] < 0){
						level[e.to] = level[v] + 1;
						que.push(e.to);
					}
				}
			}
		}
	public:
		void addEdge(int from, int to, int cap){
			G[from].push_back(Edge(to, cap, static_cast<int>(G[to].size())));
			G[to].push_back(Edge(from, 0, static_cast<int>(G[from].size() - 1)));
		}
		int fordFulkerson(int s, int t){
			int flow = 0;
			while(true){
				memset(used, 0, sizeof(used));
				int f = dfs(s, t, INF);
				if(f == 0) return flow;
				flow += f;
			}
		}
		int dinic(int s, int t){
			int flow = 0;
			while(true){
				bfs(s);
				if(level[t] < 0) return flow;
				memset(iter, 0, sizeof(iter));
				int f;
				while( (f = dfs_(s, t, INF)) > 0){
					flow += f;
				}
			}
		}
};

bool comp(pair<int, int> a, pair<int, int> b){
	return a.first < b.first and a.second < b.second;
}

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

	vector<pair<int, int>> a(n), b(n);
	rep(i,n){
		int x, y;
		cin >> x >> y;
		a[i] = make_pair(x,y);
	}
	rep(i,n){
		int x, y;
		cin >> x >> y;
		b[i] = make_pair(x,y);
	}

	Flow flow;
	int s = n * 2, t = s + 1;
	rep(i,n) flow.addEdge(s,i,1);
	rep(i,n) flow.addEdge(i + n,t,1);
	rep(i,n){
		rep(j,n){
			if(comp(a[i], b[j])){
				flow.addEdge(i, j + n, 1);
			}
		}
	}
	cout << flow.fordFulkerson(s,t) << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

int n;
vector<int> a;

bool check(int x, int d){
    int u = ub(a,x+d);
    int l = lb(a,x-d);
    return u-l <= n-u;
}

int main(void){
    int q;
    cin >> n >> q;
    a.resize(n);
    rep(i,n) cin >> a[i];
    vector<ll> sum(n+1), t_sum(n+1);
    rep(i,n){
        sum[i+1] = sum[i] + a[i];
        if (i % 2 != n % 2) {
            t_sum[i+1] = t_sum[i] + a[i];
        } else {
            t_sum[i+1] = t_sum[i];
        }
    }
    rep(_,q){
        int x;
        cin >> x;
        int l = 0, r = 1e9;
        while (l + 1 < r) {
            int m = (l+r)/2;
            if (check(x, m)) l = m;
            else r = m;
        }
        ll d = l;
        debug(x);
        debug(d);
        debug(a[ub(a,x+d)]);
        debug(a[lb(a,x-d)]);
        debug(n - ub(a,x+d));
        debug(ub(a,x+d) - lb(a,x-d));

        int dif = (n - ub(a,x+d)) - (ub(a,x+d) - lb(a,x-d));
        ll tmp = 0;
        if (dif == 2) {
            tmp = - a[(lb(a,x-d)-1)];
        } else if (dif == -1) {
            tmp = + a[n-1];
        }

        cout << sum[n]-sum[ub(a,x+d)]+t_sum[lb(a,x-d)] + tmp << endl;
    }

    return 0;
}


Measured memory_bytes: 3712
n, x, m = map(int, input().split())

ans = []
c = [0]*m
flag = False
for i in range(n):
    if c[x] == 1:
        flag = True
        break
    ans.append(x)
    c[x] = 1
    x = x**2 % m
if flag:
    p = ans.index(x)
    l = len(ans) - p
    d, e = divmod(n-p, l)
    print(sum(ans[:p]) + d*sum(ans[p:]) + sum(ans[p:p+e]))
else:
    print(sum(ans))


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

#ifndef DEBUG
#define endl '\n'
#define debug(...)
#else
#define debug(...) __VA_ARGS__
#endif
#define debugf(...) debug(printf(__VA_ARGS__);)

const int N = 1e5 + 5;



int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    while (a > 0 && c > 0) {
        c -= b;
        if (c <= 0) break;
        a -= d;
    }

    if (a > 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
%>

Measured memory_bytes: 3656
#include<stdio.h>
#include<algorithm>
using namespace std;
int n,cou,num,ans,str[2][10010];
int rest_count(int up,int down,int sum)
{
    if(up == 0 || down == cou)return sum;
    if(str[0][down + 1] == str[0][up - 1] && str[1][down + 1] + str[1][up - 1] >= 4)return rest_count(up - 1,down + 1,sum + str[1][down + 1] + str[1][up - 1]);
    return sum;
}
int main()
{
    while(scanf("%d",&n),n)
    {
        cou = -1;
        ans = n;
        for(int i = 0; i < n; i++)
        {
            scanf("%d",&num);
            if(i == 0 || num != str[0][cou])
            {
                cou++;
                str[0][cou] = num;
                str[1][cou] = 1;
            }
            else str[1][cou]++;
        }
        for(int i = 0; i < cou + 1; i++)
        {
            if(str[1][i] == 1)
            {
                if(str[0][i - 1] == str[0][i + 1] && str[1][i - 1] + str[1][i + 1] >= 3 && i != 0 && i != cou)ans = min(ans,n - rest_count(i - 1,i + 1,str[1][i - 1] + str[1][i + 1] + 1));
                if(str[1][i - 1] >= 3 && i != 0)ans = min(ans,n - rest_count(i - 1,i,1 + str[1][i - 1]));
                if(str[1][i + 1] >= 3 && i != cou)ans = min(ans,n - rest_count(i,i + 1,1 + str[1][i + 1]));
            }
            if(str[1][i - 1] >= 3 && i != 0)
            {
                str[1][i]--;
                ans = min(ans,n - rest_count(i - 1,i - 1,1 + str[1][i - 1]));
                str[1][i]++;
            }
            if(str[1][i + 1] >= 3 && i != cou)
            {
                str[1][i]--;
                ans = min(ans,n - rest_count(i + 1,i + 1,1 + str[1][i + 1]));
                str[1][i]++;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 2616
#include <iostream>
#include <algorithm>
using namespace std;
int n, q, c, x, y, z, size_, dat[266666];
inline void update(int pos, int x) {
    pos += size_; dat[pos] = x;
    while(pos != 1) {
        pos >>= 1;
        dat[pos] = min(dat[pos * 2], dat[pos * 2 + 1]);
    }
}
inline int query(int a, int b, int k, int l, int r) {
    if(r <= a || b <= l) return 2147483647;
    if(a <= l && r <= b) return dat[k]; k <<= 1;
    int lc = query(a, b, k, l, (l + r) / 2);
    int rc = query(a, b, k + 1, (l + r) / 2, r);
    return min(lc, rc);
}
int main() {
    cin >> n >> q;
    for(size_ = 1; size_ < n;) size_ *= 2;
    for(int i = 0; i < size_ * 2; i++) dat[i] = 2147483647;
    for(int i = 0; i < q; i++) {
        cin >> c >> x >> y;if(c==0)update(x,y);
        if(c==1)printf("%d\n", query(x, y + 1, 1, 0, size_));
    }
}

Measured memory_bytes: 4240
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
using ll = long long;

const long double PI = acos(-1);
const int MOD = 1e9 + 7;

int main() {
    long double a, b, x;
    cin >> a >> b >> x;


    long double ans;

    if(a*a*b <= 2 * x) ans = atan(2.0*(a*a*b - x) / (a*a*a)) * 180 / PI;
    else ans = atan((a*b*b)/(2*x)) * 180 / PI;


    cout << setprecision(15) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
A.append(0)
S=0
a=[]
c=[]
f=0

for n in range(N):
    S+=abs(A[n]-f)
    a.append(abs(A[n]-f))
    c.append(abs(A[n+1]-f))
    f=A[n]

S+=abs(A[n])
a.append(abs(A[n]))

for n in range(N):
    print(S-a[n]-a[n+1]+c[n])


Measured memory_bytes: 17172