akhauriyash/Code-Regression huggingface dataset:
n, m = map(int, input().split())
arr = [int(input()) for _ in range(m)]
broken = set(arr)

mod = 10 ** 9 + 7

dp = [0] * (n + 1)
dp[0] = 1


for i in range(1, n + 1):
    if i in broken:
        continue

    if i == 1:
        dp[1] = dp[0]
        continue

    dp[i] = dp[i - 1] + dp[i - 2]
    dp[i] %= mod

print(dp[n])


Measured memory_bytes: 13216
//最小費用流問題を解く
//計算量O(F|V||E|)
//参考 蟻本

#include<iostream>
#include<vector>
using namespace std;

typedef long long ll;

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

struct edge { 
    ll to;//行き先の頂点
    ll cap;//辺の容量
    ll cost;//１フローあたりのコスト
    ll rev;//逆辺のインデックス(G[e.to][e.rev]で逆辺にアクセスできる。)
};

#define MAX_V 1000
#define INF (1e18)

ll V;//頂点数 ここに頂点数をセットするのを忘れないように。
vector<edge> G[MAX_V];
ll dist[MAX_V];
ll prevv[MAX_V],preve[MAX_V]; // 直前の頂点と辺

void add_edge(ll from,ll to,ll cap,ll cost) {
    G[from].push_back((edge){to,cap,cost,(ll)G[to].size()});//辺の追加
    G[to].push_back((edge){from,0,-cost,(ll)G[from].size() - 1});//辺の逆辺
}

// 最小費用流を求める(sからt)
// 流せない場合はINFをかえす。

ll min_cost_flow (ll s,ll t,ll f) {
    ll ret = 0;

    while(f > 0) {
        //ベルマンフォード
        fill(dist,dist + V,INF);
        dist[s] = 0;
        bool update = true;
        while(update) {//最初に負の閉路があると無限ループになるので注意
            update = false;
            rep(v,V) {
                if(dist[v] == INF) continue;
                rep(i,G[v].size()) {
                    edge &e = G[v][i];
                    if(e.cap > 0 && dist[e.to] > dist[v] + e.cost) {//まだフローを流すことが出来、より距離が小さい
                        dist[e.to] = dist [v] + e.cost;//最小距離を更新
                        prevv[e.to] = v;//前の頂点を記録
                        preve[e.to] = i;//辺の添字を記録 求めたパスである頂点uに入る辺はG[prevv[u]][preve[u]]で表す
                        update = true;
                    }
                }
            }
        }

        if(dist[t] == INF) {
            //正のフローを流せるs-t道がなかった
            return -1;
        }

        // s-t間最短路に沿って目一杯流す
        ll d = f;//残りのフロー
        for(ll v = t;v != s;v = prevv[v]) {//t側から更新していく
            d = min(d,G[prevv[v]][preve[v]].cap);//パスの容量
        }
        f -= d;
        ret += d * dist[t];//総費用の更新
        for(ll v = t;v != s;v = prevv[v]) {//残余ネットワークの更新
            edge &e = G[prevv[v]][preve[v]];
            e.cap -= d;
            G[v][e.rev].cap += d;
        }
    }
    return ret;
}

ll E,F;

int main() {
    cin >> V >> E >> F;
    rep(i,E) {
        ll u,v,c,d;
        cin >> u >> v >> c >> d;
        add_edge(u,v,c,d);
    }
    cout << min_cost_flow(0,V-1,F) << endl;;
    return 0;
    
}


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

int main(){
    string s,t,u;
    int a,b;
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;

    if(u == s){
        a--;
    }

    else b--;

    cout<<a<<" "<<b<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i=0; i<(int)(n); i++)
#define REP2(i,x,n) for(int i=x; i<(int)(n); i++)
#define VSORT(v) sort(v.begin(), v.end());
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
int main(){
    int N;
    vector<int> A(200);
    cin >> N;
    REP(i,N){
        cin >> A[i];
    }

    int c = 0;
    bool odd = false;

    while(true){
    REP(i,N){
        if(A[i] %2 != 0){
            odd = true;
            break;
        }
    }
    
    if (odd == true){
            break;
    }
    REP(i,N){
        A[i] /= 2;
    }
    c++;
    }
    cout << c << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000
int A[MAX],n;
int partition(int p,int r){
	int x = A[r];
	int i = p - 1;
	for(int j=p;j<r;j++){
		if(A[j]<=x){
			i++;
			swap(A[i],A[j]);//用i来记录小于的部分 
		}
	} 
	swap(A[i+1],A[r]);
	return i+1;
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>A[i];
	int q = partition(0,n-1);
	for(int i=0;i<n;i++){
		if(i)
			cout<<" ";
		if(i==q)
			cout<<"[";
		cout<<A[i];
		if(i==q)
			cout<<"]";
	}
	cout<<endl;
	return 0;
} 


Measured memory_bytes: 3396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+20;
int main()
{
	ll x;
	while(cin>>x)
	{
		if(x<=11)
		{
			if(x<=6)
			cout<<1<<endl;
			else
			cout<<2<<endl;
		
			continue;
		}
		ll ans;
		int r=x%11;
		ans=x/11;
		ans=ans*2;
		if(r!=0)
		{
			if(r<=6)
			ans++;
			else
			ans=ans+(ll)2;	
		}
		cout<<ans<<endl;
		
		
	}
	return 0;
}

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

int main(){
  int K,X;
  cin >> K >> X;
  for(int i=K-1;i>0;i--){
    if(-1000000<=X-i&&X-i<=1000000){
      cout << X-i << " ";
    }
  }
  cout << X << " ";
  for(int i=1;i<K;i++){
    if(-1000000<=X+i&&X+i<=1000000){
      cout << X+i << " ";
    }
  }
    
}
  

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
int n;
cin >> n;
string w[n];
for(int i=0;i<n;i++)   cin >>w[i];
for(int i=0;i<n;i++){
  for(int j=i+1;j<n;j++){
    if(w[i]==w[j]) {
      cout <<"No"<<endl;
      return 0;
    }
  }
}
for(int i=1;i<n;i++){
  int ws=w[i-1].size();
  if(w[i][0]!=w[i-1][ws-1]){
    cout << "No"<<endl;
    return 0;
  }
}
cout <<"Yes"<<endl;

}


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

bool grid[1001][1001];
int dp[1001][1001];

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

    int n, m;
    cin >> n >> m;

    char c;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            cin >> c, grid[i][j] = (c == '#');

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            if (i == 1 && j == 1)
                dp[i][j] = 1;
            else if (grid[i][j])
                dp[i][j] = 0;
            else
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
    cout << dp[n][m] << '\n';

    return 0;
}


Measured memory_bytes: 8552
#include<bits/stdc++.h>
using namespace std;
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
char S[6];
int main(){
  rd(S);
  sort(S,S+4);
  if(S[0]==S[1] && S[1]!=S[2] && S[2]==S[3]){
    wt_L("Yes");
    wt_L('\n');
  }
  else{
    wt_L("No");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190630-1 [beta]

// --- original code ---
// char S[6];
// {
//   rd(S);
//   sort(S,S+4);
//   wt(if[S[0]==S[1]!=S[2]==S[3], "Yes", "No"]);
// }


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a)
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a)
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll sum(ll n) {
	return (1 + n) * n / 2;
}
//1から整数nまでの合計
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double m = sqrt(a);
	for (int i = 3; i <= m; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定

// ===============================================================

int main() {
	ll k, s; cin >> k >> s;
	ll ans = 0;
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j <= k; j++) {
			if (s - i - j <= k && s - i - j >= 0) {
				ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)

typedef long long ll;
typedef long long int lli;

stack<int> bins;

int calcBin(lli num) {
    if (num == 1) {
        bins.push(num);
        return 0;
    }
    if (num == 0) {
        bins.push(num);
        return 0;
    }
    lli solve = num / -2;
    int bin = num % -2;
    if (bin < 0 ) {
        bin = bin * -1;
        solve++;   
    }
    bins.push(bin);
    calcBin(solve);
    return 0;
}

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

    while(true) {
        if (bins.size() == 0) {
            break;
        }
        cout << bins.top();
        bins.pop();
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cstdio>

const double pi = 3.141592653589793238462643383279502884197;

using namespace std;

int main() {
  double d;
  cin >> d;

  double area = pi * d * d;
  double circumference = 2.0 * pi * d;
  printf("%.6f %.6f\n", area, circumference);
  fflush(stdout);
  return 0;
} 



Measured memory_bytes: 3192
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
    public static void main(String[] args) {
        FastScanner fsc = new FastScanner();
        long a = fsc.nextInt();
        long b = fsc.nextInt();
        int k = fsc.nextInt();
        while (true) {
            a /= 2;
            b += a;
            if (--k == 0) {
                break;
            }
            b /= 2;
            a += b;
            if (--k == 0) {
                break;
            }
        }
        System.out.println(a + " " + b);
    }
}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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

using namespace std;
using ll = long long;

int main() {
    int h,w;
    cin>>h>>w;
    vector<vector<int>> d(h,vector<int>(w));
    for(int i = 0;i < h;++i) {
        for(int j = 0;j < w;++j) {
            char c;
            cin>>c;
            if(c=='.')d[i][j]=1;
            else d[i][j]=0;
        }
    }
    vector<vector<int>> ans(h,vector<int>(w,0));
    for(int i = 0;i < h;++i) {
        if(d[i][0]==1)ans[i][0]=-1;
        else ans[i][0]=0;
    }
    for(int i = 0;i < h;++i) {
        for(int j = 1;j < w;++j) {
            if(d[i][j]==1)ans[i][j]=(ans[i][j-1]==-1?-1:ans[i][j-1]+1);
            else ans[i][j]=0;
        }
    }
    for(int i = 0;i < h;++i) {
        for(int j = 0;j < w-1;++j) {
            cout<<ans[i][j]<<" ";
        }
        cout<<ans[i][w-1]<<endl;
    }
    return 0;
}



Measured memory_bytes: 3244
let is_prime n = match n with
    2|3|5 -> true
    | n when n mod 2 = 0 -> false
    | n when n mod 3 = 0 -> false
    | n when n mod 5 = 0 -> false
    | n ->
       let rec loop i =
         if i*i > n then true
         else if n mod i = 0 then false
         else if n mod (i+2) = 0 then false
         else loop (i+6);
       in loop 5

let () =
  let n = read_int () in
  let rec read ct = function
      0 -> ct
    | i ->
       let m = read_int () in
       read (if is_prime m then ct+1 else ct) (i-1)
  in
  Printf.printf "%d\n" (read 0 n)

Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
typedef long long int llint;

int main(void){

  llint n, a, b;
  std::cin >> n >> a >> b;

  llint ab = a + b;
  llint ans = (n/ab)*a;
  llint nokori = n%ab;
  ans += std::min(nokori, a);
  std::cout << ans << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.awt.geom.Point2D;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;


public class Main {
	static ArrayList<Point2D.Double> points = new ArrayList<Point2D.Double>(); 
	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		
		Point2D.Double p1 = new Point2D.Double(0, 0);
		Point2D.Double p2 = new Point2D.Double(100, 0);
		points.add(p1);
		koch(n, p1, p2);
		points.add(p2);
		
		for(int i = 0; i < points.size(); i++){
			System.out.printf("%.8f %.8f\n", points.get(i).x, points.get(i).y);
		}
	}
	
	static void koch(int n, Point2D.Double p1, Point2D.Double p2){
		if(n <= 0){
			return;
		}
		
		//points.add(p1);
		
		Point2D.Double p3 = new Point2D.Double((p2.x + p1.x*2)/3, (p2.y + p1.y*2)/3);
		
		
		Point2D.Double p5 = new Point2D.Double((p2.x*2 + p1.x)/3, (p2.y*2 + p1.y)/3);
		Double dx = p5.x - p3.x;
		Double dy = p5.y - p3.y;
		///System.out.println(Math.cos(Math.PI/3));
		Point2D.Double p4 = new Point2D.Double(p3.x + dx*Math.cos(Math.PI/3)-dy*Math.sin(Math.PI/3),
				p3.y + dx*Math.sin(Math.PI/3)+dy*Math.cos(Math.PI/3));
		koch(n - 1, p1, p3);
		points.add(p3);
		koch(n - 1, p3, p4);
		points.add(p4);
		koch(n - 1, p4, p5);
		points.add(p5);
		koch(n - 1, p5, p2);
		//points.add(p2);
	}

}

Measured memory_bytes: 41804
import sys
from collections import defaultdict
d = defaultdict(str)
N = int(sys.stdin.readline())
S = sys.stdin.readline()

ans = 0
k = 'RGB'
for i in range(N):
	for j in range(i+1,N):
		if not S[i]==S[j]:
			tmp =k.replace(S[i],'')
			tmp = tmp.replace(S[j],'')
			if d[str(j+1)+tmp]=='':
				p = S[j+1:].count(tmp)
				d[str(j+1)+tmp] = p
				ans += p
				if 2*j-i<N and S[2*j-i]==tmp:
					ans-= 1
					
			else:
				ans +=d[str(j+1)+tmp]
				if 2*j-i<N and S[2*j-i]==tmp:
					ans -=1
print(ans)

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

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

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

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

bool prime(ll x){
	bool flag = true;
	int ran = sqrt(x) + 2;
	for(int i=2;i<ran;i++){
		if(x%i==0){
			flag = false;
			break;
		}
	}
	return flag;
}

int main(){
	ll N;
	cin >> N;
	ll tm = 1;
	vector<ll> res;
	while(N>0){
		if(prime(10*tm+1)){
			res.push_back(10*tm+1);
			N--;
		}
		tm++;
	}
	REP(i, res.size()-1) cout << res[i] <<" ";
	cout << res[res.size()-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
//#include<windows.h>
using namespace std;
 
//#define int ll
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
struct edge {int /*from,*/to,cost;};

signed main(){
    int n;
    cin >> n;
    int cx = 0, cy = 0,ct = 0;
    REP(i,n){
        int t,x,y;
        scanf("%d%d%d",&t,&x,&y);
        int dx = abs(cx-x), dy = abs(cy-y);
        if(dx+dy>t-ct){
            puts("No");
            return 0;
        } else if((t-ct-dx-dy)%2){
            puts("No");
            return 0;
        } else {
            ct = t;
            cx = x;
            cy = y;
        }
    }
    puts("Yes");

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mk make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
int main(){
    std::vector<bool> a(4,0);
    string s;
    std::cin >> s;
    rep(i,s.size()){
        if(s[i]=='N')a[0]=1;
        if(s[i]=='W')a[1]=1;
        if(s[i]=='S')a[2]=1;
        if(s[i]=='E')a[3]=1;
        
    }
    if(!(a[0]^a[2]) && !(a[1]^a[3]))std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
}

Measured memory_bytes: 256
A, B, Q = map(int, input().split())
s_list = [int(input()) for i in range(A)]
t_list = [int(input()) for i in range(B)]
x_list = [int(input()) for _ in range(Q)]

s_list.sort()
t_list.sort()
s_list = [-float("inf")] + s_list + [float("inf")]
t_list = [-float("inf")] + t_list + [float("inf")]
import bisect

ans = []
for x in x_list:
    tmp = float("inf")
    s_i = bisect.bisect_left(s_list, x)
    t_i = bisect.bisect_left(t_list, x)

    for s in (s_list[s_i - 1], s_list[s_i]):
        for t in (t_list[t_i - 1], t_list[t_i]):
            d1 = abs(s - x) + abs(t - s)
            d2 = abs(t - x) + abs(s - t)
            tmp = min(tmp, d1, d2)
    ans.append(tmp)
for a in ans:
    print(a)


Measured memory_bytes: 21556
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int h,w,n;
	cin>>h>>w>>n;
	vector<int> a(n);
	rep(i,n) cin>>a[i];
	vector<vector<int>> ans(h,vector<int>(w,-1));
	Pi now=Pi(0,0);
	rep(i,n){
		while(a[i]--){
			ans[now.fi][now.se]=i+1;
			if(now.fi%2==0){
				now.se++;
				if(now.se==w){
					now.se=w-1;
					now.fi++;
				}
			}else{
				now.se--;
				if(now.se==-1){
					now.se=0;
					now.fi++;
				}
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

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



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

const int MAX = 1e5+5;



int main() {
	int k;
	cin >> k;
	vector<int> a(k);
	for (int i = 0; i < k; i++) {
		cin >> a[i];
	}
	reverse(a.begin(), a.end());

	if (a[0] != 2) {
		cout << -1 << endl;
		return 0;
	}

	ll l = 2;
	ll r = 2;
	for(int i = 0;i<k;i++){
		ll x = (l / a[i]);
		if (l % a[i] != 0) {
			x++;
		}

		ll y = r / a[i];
		
		if (x > y) {
			cout << -1 << endl;
			return 0;
		}

		l = x * a[i];
		r = (y + 1) * a[i] - 1;

	}

	cout << l << " " << r << endl;


}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
// URDL
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
long long mod = 1e9+7;
//

int main(){
  int n; cin >> n;
  for(int i=1; i<=9; i++) {
    for(int j=1; j<=9; j++) {
      if(n == i*j) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;

  return 0;
}
// EOF


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

int main(){
  int n;
  cin >> n;
  int num;
  for(int i=1; ; ++i){
    int x = i *(i+1) /2; 
    if(x == n){
      num = i;
      break;
    }
    else if(x > n){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  cout << num +1 << endl;
  int r = 1;
  vector<queue<int>> vq(num);
  for(int i=0; i<num+1; ++i){
    printf("%d ", num);
    int k = 0;
    for(int j=0; j<num; ++j){
      if(k<i){
        printf("%d", vq[k].front());
        vq[k].pop();
        ++k;
      }else{
        printf("%d",r);
        vq[i].push(r);
        ++r;
      }
      if(j == num-1) cout << endl;
      else cout << " ";
    }
  }
}

Measured memory_bytes: 4204
n = int(input())
p = [int(i) - 1 for i in input().split()]
cnt_swap = 0
for i in range(n - 1):
    if p[i] == i:
        p[i], p[i + 1] = p[i + 1], p[i]
        cnt_swap += 1
print(cnt_swap if p[n - 1] != n - 1 else cnt_swap + 1)

Measured memory_bytes: 13880
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> prl;
typedef vector<ll> vcl;
typedef map<ll,ll> mapl;
typedef unordered_map<ll,ll> umap;
#define pb push_back
#define all(v) v.begin(), v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

//Binary_Indexed_Tree (Range_Sum_Query)
//(1-indexed)
const ll max_n = 1e6+5;
ll n, bit[max_n];
//i番目(1-indexed)までの和
ll sum(ll ii){
    ll sm = 0;
    while(ii > 0){
        sm += bit[ii];
        ii -= ii & -ii;
    }
    return sm;
}
//i番目(1-indexed)にxを加える
void add(ll ii, ll x){
    while(ii <= n){
        bit[ii] += x;
        ii += ii & -ii;
    }
}

int main() {
    // your code goes here
    ll q;
    cin >> n >> q;
    rep(i,1,n){
        ll x;
        cin >> x;
        add(i,x);
    }
    rep(i,1,q){
        ll a,b,c;
        cin >> a >> b >> c;
        if(a==0) add(b+1,c);
        else cout << sum(c)-sum(b) << endl;
    }
    return 0;
}

Measured memory_bytes: 8228
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    S = input()
    count = 0
    ans = 0
    ACGT = ['A','C','G','T']
    for s in S:
        if s in ACGT:
            count += 1
        else:
            ans = max(ans, count)
            count = 0
    ans = max(ans, count)

    print(ans)




if __name__ == '__main__':
    main()


Measured memory_bytes: 9136
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+5;

int main()

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

    int n;

    cin >> n;

    cout << n*n;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <limits>
using namespace std;
#define MOD 1000000007
#define INF 1000000009
#define ll long long
#define rep(i_, start, end) for(ll i_=(ll)start; i_<(ll)end; i_++)
#define print(a) cout << a << endl;
#define printarray(a, len) rep(ii,0,len) cout << a[ii] << " ";
#define printarray2(aa, len) rep(ij,0,len) printarray(aa[ij], aa[ij].size()); print("");
 
ll dp[100010][3] = {};
int main(){
  ll n, a, b, c;
  vector<ll> plan[100010];
  cin >> n;
  rep(i, 0, n){
    cin >> a >> b >> c;
    plan[i].push_back(a);
    plan[i].push_back(b);
    plan[i].push_back(c);
  }

  rep(i, 0, n){
    rep(j, 0, 3){
      rep(ki, 0, 3){
        if (ki != j) dp[i+1][j] = max(dp[i+1][j], dp[i][ki] + plan[i][j]);
      }
    }
  }
  print( max( dp[n][0], max(dp[n][1], dp[n][2]) ) );
  
  return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll r, d, x;
    cin >> r >> d >> x;
    rep(i, 10) {
        x = r * x - d;
        cout << x << endl;
    }
    return 0;
}


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

int main() {
    int N, x, y, b, p;
    cin >> N;
    
    for (int i = 0; i < N; i++) {
        cin >> x >> y >> b >> p;
        int sum = x * b + y * p;
        if ((b >= 5) && (p >= 2)) sum *= 0.8;
        
        if ((b >= 5) && (p < 2)) {
            int sum2 = x * b + y * 2;
            sum2 *= 0.8;
            if (sum > sum2) sum = sum2;
        } else if ((b < 5) && (p >= 2)) {
            int sum2 = x * 5 + y * p;
            sum2 *= 0.8;
            if (sum > sum2) sum = sum2;
        }
        
        cout << sum << endl;
    }
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int64_t INF = 1LL << 60;


int main() {
  string s;
  int64_t k;
  cin>>s>>k;
  for(int i=0;i<s.size();i++){
     if(i<k){if(s[i]!='1'){cout<<s[i]<<endl;return 0;}}
  }
  cout<<1<<endl;
  return 0;
  }

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

using namespace std;
using ll  = long long;
template <typename T> T In() {
    T t;
    cin >> t;
    return t;
}
template <typename T> vector<vector<T>> Vec2(int i, int j, T ini = 0) {
    vector<vector<T>> vec(i, vector<T>(i, ini));
    return move(vec);
}
template <typename T> vector<vector<vector<T>>> Vec3(int i, int j, int k, T ini = 0) {
    vector<vector<vector<T>>> vec(i, vector<vector<T>>(j, vector<T>(k, ini)));
    return move(vec);
}

int main() { 
    int N = In<int>();
    cout << N * N * N << endl;
}

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

using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI 3.14159265358979

lli flag[210];
map<lli,vector<lli>> d;
bool hei = false;

void func(lli now,lli cnt){
	if(hei)return;
	if(flag[now])return;
	flag[now] = cnt%2 + 1;

	for(auto e:d[now]){
		if(flag[e]>0 && flag[e] != (cnt+1)%2+1){
			hei=true;
			return;
		}
		if(flag[e])continue;
		func(e,(cnt+1)%2);
	}
}

signed main(){

	lli n;
	cin>>n;
	lli data[210][210];
	REP(i,0,210)REP(j,0,210)data[i][j]=INF;
	REP(i,0,210)flag[i]=0;
	if(DEBUG){
		REP(i,0,210)cout<<"i="<<i<<" flag[i]="<<flag[i]<<endl;
	}

	for(lli i=0;i<n;i++){
		for(lli j=0;j<n;j++){
			if(i==j)data[i][j]=0;
			char a;
			cin>>a;
			if(a=='1'){
				data[i][j]=1;
				//data[j][i]=1;
				d[i].push_back(j);
				//d[j].push_back(i);
			}
		}
	}
	func(0,0);
	if(hei){
		cout<<-1<<endl;
		return 0;
	}

	REP(k,0,n)REP(i,0,n)REP(j,0,n)data[i][j] = min(data[i][j],data[i][k]+data[k][j]);
	lli ans = 0;
	REP(i,0,n)REP(j,0,n){
		if(DEBUG)cout<<"i="<<i<<" j="<<j<<" data[i][j]="<<data[i][j]<<endl;
		ans = max(ans,data[i][j]);
	}
	cout<<ans+1<<endl;


	return 0;
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	string s;
	cin >> s;

	vector<int> vec;
	vector<char> sigh;

	int length = 1;
	char c = s[0];

	rep(i, s.length()){
		if(i == 0){
			
		}
		if(i == s.length() - 1){
			vec.push_back(length);
			sigh.push_back(c);
			break;
		}

		if(c != s[i + 1]){
			vec.push_back(length);
			sigh.push_back(c);

			length = 1;
			c = s[i + 1];
		}
		else{
			length++;
		}
	}
	
	long long int ans = 0;
	int max_depth = *max_element(all(vec));

	rep(i, vec.size()){
		if(i == 0 && sigh[0] == '>'){
			for(int j = 0; j <= vec[0]; j++){
 				ans += j;
			}
		}
		else if (i == vec.size() - 1 && sigh[i] == '<')
		{
			for (int j = 0; j <= vec[i]; j++)
			{
				ans += j;
			}

			break;
		}

		if(sigh[i] == '<'){
			for (int j = 0; j < vec[i]; j++)
			{
				// cout << "ans = " << ans << ", sigh[i] = " << sigh[i] << ", i = " << i << ", j =" << j << endl;
				ans += j;
			}
		}
		else if (i != 0 && sigh[i] == '>')
		{
			for (int j = 0; j < vec[i]; j++)
			{
				// cout << "ans = " << ans << ", sigh[i] = " << sigh[i] << ", i = " << i << ", j =" << j << endl;
				ans += j;
			}

			ans += max(vec[i], vec[i - 1]);
		}
	}

	// for(auto i : vec) cout << i << endl;
	// cout << *max_element(all(vec));

	cout << ans;
	return 0;
}

Measured memory_bytes: 2172
<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(" ", $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int)$this->next();
    }

    public function nextDouble()
    {
        return (double)$this->next();
    }
}

class out
{
    public static function printIn($str = "")
    {
        echo $str . PHP_EOL;
    }
}

$sc = new Scanner;

$N = $sc->nextInt();
$X = $sc->nextInt();
$leftover = $X;
$amounts = [];
/* max や sum を使って*/

for ($i = 0; $i < $N; $i++) {
    $amounts[] = $sc->nextInt();
}
$min = min($amounts);
$sum = array_sum($amounts);
$leftover -= $sum;
$count = $N;
while ($leftover - $min >= 0){
    $leftover -= $min;
    $count ++;
}

echo $count;
//for ($i = 0; $i < $N; $i++) {
//    $g = $sc->nextInt();
//    $amounts[] = $g;
//    $leftover -= $g;
//}
//sort($amounts);
//
//$count = count($amounts);
//while ($leftover - $amounts[0] >= 0) {
//    $leftover -= $amounts[0];
//    $count++;
//}
//
//echo $count;

Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF = 0x3f3f3f3f;
const ll mod  = 1e9 + 7;
const ll N = 1e6 + 5;

struct node{
	int l,r,no;
	bool operator < (const node& T) const{
		if(r==T.r) return l<T.l;
		else return r<T.r;
	}
}b[N];

int n,q,a[N],ans[N],bit[N],M[N];

inline void update(int pos,int val){
	int x=pos;
	while(x<=N){
		bit[x]+=val;
		x+=x&-x;
	}
}

inline int getsum(int pos){
	int cnt=0;
	while(pos){
		cnt+=bit[pos];
		pos-=pos&-pos;
	}
	return cnt;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>q;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=q;i++){
    	cin>>b[i].l>>b[i].r;
    	b[i].no=i;
    }
    sort(b+1,b+1+q);
    int r=0;
    for(int i=1;i<=q;i++){
    	while(r<b[i].r){
    		r++;
    		if(M[a[r]]) update(M[a[r]],-1);
    		M[a[r]]=r;
    		update(r,1);
    	}
    	ans[b[i].no]=getsum(b[i].r)-getsum(b[i].l-1);
    }
    for(int i=1;i<=q;i++) cout<<ans[i]<<'\n';
    return 0;
}

Measured memory_bytes: 17416
#include <cstdlib>
#include <iostream>

using namespace std;

const int LIMIT = 2019;

int n; //駒数
int x[101]; //各コマの状態
int m; //操作回数
//int a[101]; //操作対象

void object_move(int object_num){
    int tgt_pos = x[object_num] + 1;
    if(tgt_pos > LIMIT){
        return;
    }

    for(int i=0; i<m; i++){
        if(x[i] == tgt_pos){
            if(i != object_num){
                return;
            }
        }
    }

    x[object_num] += 1;
}

int main(){

    cin >> n;
    for(int i=0; i<n; i++){
        cin >> x[i];
    }
    cin >> m;
    for(int i=0; i<m; i++){
        int a;
        cin >> a;
        object_move((a-1));
    }


    for(int i=0; i<n; i++){
        cout << x[i] << endl;
    }

    return 0;

}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int a = max(A,C);
    int b = min(B,D);
    cout << max(b - a,0) << endl;
}


Measured memory_bytes: 3576
while True:
    m, f, r = map(int, input().split())
    score = m + f
    if m == f == r == -1:
        break
    elif m == -1 or f == -1:
        print('F')
    elif score >= 80:
        print('A')
    elif score >= 65:
        print('B')
    elif score >= 50 or (score >= 30 and r >= 50):
        print('C')
    elif score >= 30:
        print('D')
    else:
        print('F')

Measured memory_bytes: 7688
import sys
import math

input = sys.stdin.readline

a,b,x = list(map(int,input().split()))

if x>(a**2*b)/2.0:
	h = x/(a**2)
	sh = 2*h-b
	dh = b-sh

	theta = math.degrees(math.atan(dh/a))
else:
	h = (2.0*x)/(a*b)
	theta = math.degrees(math.atan(b/h))

print(theta)

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);
    string b; cin>>b;
    string ans;
    if (b=="A") ans="T";
    else if (b=="T") ans="A";
    else if (b=="C") ans="G";
    else if (b=="G") ans="C";
    cout << ans << endl;
}


Measured memory_bytes: 256
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>
#include <limits>

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

using namespace std;
//エイリアス
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

//定数
const int intmax = numeric_limits<int>::max();
const ll llmax = numeric_limits<ll>::max();
const ll mod = 1e9 + 7;
const double pi = M_PI;

int main()
{
  int n, m, x;
  cin >> n >> m >> x;
  v c(n, 0);
  vector<vector<int>> a(n, vector<int>(m, 0));
  rep(i, n) {
    cin >> c[i];
    rep(j, m) {
      cin >> a[i][j];
    }
  }
  int result = intmax;
  for(int i = 1; i <= 4096; i++) {
    v alg(m, 0);
    int cost = 0;
    for(int j = 0; j < n; j++) {
      if(i & (1 << j)) {
        rep(k, m) {
          alg[k] += a[j][k];
        }
        cost += c[j];
      }
    }
    bool ok = true;
    rep(k, m) {
      if(alg[k] < x) {
        ok = false;
      }
    }
    if(ok) {
      result = min(result, cost);
    }
  }
  if (result == intmax) {
    cout << -1 << endl;
  }else{
    cout << result << endl;
  }
}


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

int main(){
  int N,L;
  cin >> N >> L;
  
  int a=(2*L+N-1)*N/2;
  if(L<=0 && L+N-1 >=0){
    cout << a <<endl;
  }
  if(L>0){
    cout << a-L <<endl;
  }
  if(L+N-1<0){
    cout << a-L-N+1 <<endl;
  }
}

      

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

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	string s;
	while (cin >> s) {
		if (s == "-") break;
		int m; cin >> m;
		int h;
		REP(i, m) {
			cin >> h;
			s = s.substr(h, s.size() - h) + s.substr(0, h);
		}
		cout << s << endl;
	}
}

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



Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // ここにプログラムを追記
  int H,W,h,w;
  cin >> H >> W >> h >> w;
  //h行w列
  int black = h*W+w*H-h*w;
  cout << H*W-black <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int s[26];
int main(){
 long n, i, a=1;
 scanf("%ld", &n);
 for(i=0, getchar(); i<n; i++) s[getchar()-'a']++;
 for(i=0; i<26; i++) a=(s[i]+1)*a%(1000000000+7);
 printf("%ld", a-1);
 return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;

int main(void)
{
    char a[10],b[10];
    while(scanf("%s%s",a,b)==2)
    {
        if(a[0] == 'H')
        {
            printf("%s\n",b);
        }
        else
        {
            if(b[0] == 'H')
                printf("D\n");
            else
                printf("H\n");
        }
    }

    return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Data.List

makeList :: Int -> [Int]
makeList d = [x*x*d*d*d | x <- [1..600], x*d < 600]

integral :: (Num a) => [a] -> a
integral xs = foldl (\acc x -> acc + x) 0 xs

main = do
  n <- fmap (read :: String -> Int) . words <$> getContents
  mapM_ print (fmap integral (fmap makeList n))

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


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

Measured memory_bytes: 3620
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int A;
int ret[210000];
int dif[210000];
int sam[210000];
int s_a[210000];
int s_b[210000];
void gen(int a,int b,int c,int d){
	if(a==b){
		s_a[a]=c;
		return;
	}
	gen(a,(a+b)/2,c,d+1);
	gen((a+b)/2+1,b,c+(1<<sam[d]),d+1);
	reverse(s_a+(a+b)/2+1,s_a+b+1);
}
vector<int>gen2(int a){
	if(a==1){
		vector<int>ret;
		ret.push_back(0);
		ret.push_back(1<<dif[0]);
		return ret;
	}
	vector<int>tmp=gen2(a-2);
	vector<int>ret;
	for(int i=0;i<tmp.size();i++){
		ret.push_back(tmp[i]);
	}
	for(int i=0;i<tmp.size();i++){
		ret.push_back(tmp[tmp.size()-1-i]+(1<<dif[a-2]));
	}
	for(int i=0;i<tmp.size();i++){
		if(i%2==0){
			ret.push_back(tmp[i]+(1<<dif[a-1])+(1<<dif[a-2]));
			ret.push_back(tmp[i]+(1<<dif[a-1]));
		}else{
			ret.push_back(tmp[i]+(1<<dif[a-1]));
			ret.push_back(tmp[i]+(1<<dif[a-1])+(1<<dif[a-2]));
		}
	}
	return ret;
}
int main(){
	int n,a,b;scanf("%d%d%d",&n,&a,&b);
	A=a;
	a^=A;
	b^=A;
	if(__builtin_popcount(b)%2==0){
		printf("NO\n");return 0;
	}
	int D=0;
	int S=0;
	for(int i=0;i<n;i++){
		if(b&(1<<i)){
			dif[D++]=i;
		}else sam[S++]=i;
	}
	gen(0,(1<<S)-1,0,0);
	vector<int>tmp=gen2(D);
	for(int i=0;i<tmp.size();i++){
		s_b[i]=tmp[i];
	}
	int ind=0;
	for(int i=0;i<(1<<D);i++){
		if(i%2==0){
			for(int j=0;j<(1<<S);j++){
				ret[ind++]=s_a[j]+s_b[i];
			}
		}else{
			for(int j=0;j<(1<<S);j++){
				ret[ind++]=s_a[(1<<S)-1-j]+s_b[i];
			}
		}
	}
	printf("YES\n");
	for(int i=0;i<(1<<n);i++){
		if(i)printf(" ");
		printf("%d",ret[i]^A);
	}printf("\n");
}

Measured memory_bytes: 3200
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int n,maxa,ans,a,b;
int main(){
	scanf("%d",&n);
	fo(i,1,n){
		scanf("%d%d",&a,&b);
		if (a>maxa){
			maxa=a;
			ans=a+b;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128