akhauriyash/Code-Regression huggingface dataset:
//codeforces
#include <algorithm>
#include <vector>
#include <string>
#include <ctype.h>
#include <set>
#include <map>
#include<cstdio>
#include<queue>
#include<cstdlib>
#include<time.h>
#include<string>
#include<stack>
#include<cmath>
#include<iostream>
#include<cstring>
#include<complex>
#include<bitset>
#include <climits>
#include<tr1/unordered_set>
#include<tr1/unordered_map>


#define FOR(i,j,k) for(int i=j;i<k;i++)
#define FORD(i,j,k) for(int i=j;i>=k;i--)
#define ll long long
//Make sure no overflow problems
//#define int long long
#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define VAR(i,n) __typeof(n) i = (n)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();i++)
#define FORDEACH(i,c) for( VAR(i,(c).rbegin()),i!=(c).rend();i++)
#define REP(i,n) FOR(i,0,n)
#define ld long double
const int INF = 1e9+7;
const long long INFLL = (ll)INF * (ll)INF;
const ld EPS = 10e-9;

using namespace std;

class TrieNode{
    public:
    bool isword;
    char c;
    map<char,TrieNode*> m;
    string word;
    public:
    TrieNode(){}
    TrieNode(char ch){
        c=ch;
        isword=false;
    }
};

void insert(TrieNode* root,string word){
    TrieNode* temp=root;
    for(char c:word){
        if(temp->m.find(c)==temp->m.end())
            temp->m[c]=new TrieNode(c);
        temp=temp->m[c];
    }
    temp->isword=true;
    temp->word=word;
}

#pragma GCC optimize ("Ofast")
static auto _ = [] { std::ios::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0); std::cerr.tie(0); return 0; } ();

int main() {
    int n,W;
    cin>>n>>W;
    vector<int> v(n),w(n);
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
    }

    vector<vector<long long>> dp(n+1,vector<long long> (W+1,0));

    for(int i=1;i<=n;i++){
        for(int j=1;j<=W;j++){
            if(w[i-1]<=j)
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][W];

    return 0;
}


Measured memory_bytes: 83200
{-# LANGUAGE
    BangPatterns, MultiWayIf, TupleSections, TypeApplications #-}
{-# OPTIONS_GHC -O2 #-}


import Control.Arrow
import Control.Concurrent
import Control.Monad
import qualified Data.ByteString.Builder as B
import qualified Data.ByteString.Char8 as C
import Data.Complex
import Data.Char
import Data.Function
import Data.Function.HT
import qualified Data.IntMap.Strict as IM
import qualified Data.IntSet as IS
import Data.List
import Data.Monoid
import Data.Ord
import qualified Data.Sequence as Sq
import Data.Vector.Algorithms.Search
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import Debug.Trace
import System.IO


------------------
-- #   Read   # --
------------------

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

d :: Int -> Int -> Double
d x y = fromIntegral x / fromIntegral y


main :: IO ()
main = do
    [n,x,t] <- r'
    print $ ceiling (d n x) * t

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

#define N 200200

char s[N];

int main() {
    scanf("%s", s);
    int n = strlen(s), rlt = 0;
    for (int i = 0, j = 0; i < n; i = j) {
        for (; j < n && s[j] == s[i]; j ++);
        int m = j - i, k = m / 3;
        if (m == 3 * k) rlt += 2 * k;
        else if (m == 3 * k + 1) rlt += 2 * k + 1;
        else {
            rlt += 2 * k + 1;
            if (j < n) rlt ++, j ++;
        }
    }
    printf("%d\n", rlt);
}


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

using lint = long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && a != c || a == c && a != b || b == c && b != a)
    	cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long,long>> vpll;
typedef vector<pair<int,int>> vpii;
int main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	ini(n);
	ini(k);
	ins(a);
	int same = 0;
	int dif = 0;
	FOR(i,0,n-1){
		if(a[i] == a[i+1])same++;
		else dif++;
	}
	same+= min(dif,k*2);
	out(same);
	return 0;
}

Measured memory_bytes: 512
a,b,k=map(int,input().split())
x=[]
y=[]
if b-a<k:
    k=b-a+1
for i in range(a,a+k):
    x.append(i)
for i in range(b-k+1,b+1):
    x.append(i)
x=list(set(x))
x.sort()
for i in range(len(x)):
    print(x[i])

Measured memory_bytes: 9084
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>
using namespace std;
const int MAX_N = 100;
const int MAX_W = (int)1e5;
long long DP[MAX_N+1][MAX_W+1];
long long W[MAX_N+1], V[MAX_N+1];
signed main(){
    long long n, w;
    cin >> n >> w;
    for(long long i=1; i<=n; ++i) cin >> W[i] >> V[i];
    for(long long i=1; i<=w; ++i) DP[0][i] = 0;
    for(long long j=0; j<=n; ++j) DP[j][0] = 0;
    for(long long i=0; i<n; ++i){
        for(long long j=0; j<=w; ++j){
            DP[i+1][j] = max(DP[i+1][j], DP[i][j]);
            if(W[i+1]+j <= w) DP[i+1][j+W[i+1]] = max(DP[i+1][j+W[i+1]], DP[i][j]+V[i+1]);
        }
    }
    cout << DP[n][w] << endl;
    return 0;
}

Measured memory_bytes: 79104
import static java.util.Arrays.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	void solve() {
		int N = sc.nextInt();
		if (N == 0) return;
		int start = sc.nextInt() - 1;
		int goal = sc.nextInt() - 1;
		int D = sc.nextInt();
		char[][] s = new char[D][];

		for (int i = 0; i < D; i++) {
			s[i] = sc.next().toCharArray();
		}
		if (goal == sim(start, s)) {
			out.println(0);
			return;
		}
		for (int i = 0; i < D; i++) {
			for (int j = 0; j < N - 1; j++) {
				if (s[i][j] == '0') {
					if (j + 1 < N - 1 && s[i][j+1] == '1' ||
						j - 1 >= 0 && s[i][j-1] == '1') {
						;
					} else {
						s[i][j] = '1';
						if (goal == sim(start, s)) {
							out.println((i+1) + " " + (j+1));
							return;
						}
						s[i][j] = '0';
					}
				}
			}
		}
		out.println(1);
	}

	int sim(int pos, char[][] s) {
		int D = s.length;
		int N = s[0].length + 1;
		for (int i = 0; i < D; i++) {
			if (pos < N - 1 && s[i][pos] == '1') {
				pos += 1;
			} else if (pos > 0 && s[i][pos-1] == '1') {
				pos -= 1;
			}
		}
		return pos;
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
	}
}

Measured memory_bytes: 16992
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)

using namespace std;
using ll = long long;
using ii = pair<int,int>;

constexpr int MAXN = 14;
constexpr int INF = 1e9;
int a[MAXN], c[MAXN][MAXN], cc[MAXN];

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n,m,x,ans=INF;
  cin >> n >> m >> x;
  foi (i,0,n) {
    cin >> cc[i];
    foi (j,0,m) cin >> c[i][j];
  }
  foi (mask,0,1<<n) {
    fill(a, a + m, 0);
    int cost = 0;

    foi (i,0,n) {
      if (mask&(1<<i)) {
        cost += cc[i];
        foi (j,0,m) a[j] += c[i][j];
      }
    }
    bool ok = true;
    foi (j,0,m) {
      if (a[j] < x) {
        ok = false;
        break;
      }
    }
    if (ok) ans = min(ans, cost);
  }
  if (ans == INF) ans = -1;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>
#include <stdbool.h>

#define	BUFFER_LENGTH	(256)
#define	NCITY	(4)
#define	NPATH	(3)

int
main(int argc, const char *argv[])
{
	char buffer[BUFFER_LENGTH];
	int a;
	int b;
	int city[NCITY + 1];
	int i;
	bool isok;

	for (i = 1; i <= NCITY; i++) {
		city[i] = 0;
	}

	for (i = 0; i < NPATH; i++) {
		(void)fgets(buffer, sizeof(buffer), stdin);
		(void)sscanf(buffer, "%d %d\n", &a, &b);
		city[a]++;
		city[b]++;
	}

	isok = true;
	for (i = 1; i <= NCITY; i++) {
		if ((city[i] == 0) || (city[i] > 2)) {
			isok = false;
			break;
		}
	}

	(void)printf("%s\n", (isok) ? "YES": "NO");

	return 0;
}


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

long long calc(string s){
  int N = s.size();
  long long ret = stoll(s);
  //base case
  
  if(N==1)
    return ret;
  
  //recursive step
  for(int i=1;i<N;i++){
    string sl = s.substr(0,i);
    string sr = s.substr(i,N-i);
    ret += stoll(sl)*pow(2,sr.size()-1);
    ret += calc(sr);
  }
  
  return ret;
}

int main(){
  string s;
  cin >> s;
  cout << calc(s) << endl;
  
}

Measured memory_bytes: 4040
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

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

int main() {
	int a, b, c;
	bool flag = false;
	cin >> a >> b >> c;
	if (a == b && a != c) {
		flag = true;
	}
	if (a == c && a != b) {
		flag = true;
	}
	if (b == c && b != a) {
		flag = true;
	}
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;

#define DEBUG 0
#define REP(i, n) for (int i = 0; i < (n); i++) 
typedef long long ll;
typedef pair<int,int> pint;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

const int nMax = 8;
bool graph[nMax][nMax];

//dfs訪問済み
int dfs(int v, int n, bool visited[nMax])
{
    bool all_visited = true;
    for(int i = 0; i < n; ++i)
    {
        if(visited[i] == false)
        {
            all_visited = false;
        }
    }

    //すべて訪問していたら
    if(all_visited)
    {
        return 1;
    }
    int ret = 0;
    for(int i = 0; i < n; ++i)
    {
        //つながっていない
        if(graph[v][i] == false)continue;
        //訪問済み
        if(visited[i]) continue;

        //1次的に訪問済にする
        visited[i] = true;
        ret += dfs(i,n,visited);
        visited[i] = false;
    }
    return ret;
}

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

    for(int i = 0; i < m; ++i)
    {
        int a,b;
        cin >> a >> b;
        --a;
        --b;
        graph[a][b] = true;
        graph[b][a] = true;
    }

    bool visited[nMax];
    REP(i,n)visited[i] = false;

    visited[0] = true;
    int res = dfs(0,n,visited);

    cout << res << endl;
 
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

using namespace std;

int count_moji(char s[])
{
    int i = 0;
    while (s[i]){
        i++;
    }
    return i;
}

int main()
{
    char s[100];
    cin >> s;
    int c = 0;
    
    for (int i = 0;i < count_moji(s)/2;i++){
        if (s[i] != s[count_moji(s)-1-i]){
            c++;
        }
    }
    
    cout << c << endl;
    
}


Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let arr: Vec<u64> = sc.vec(n);
    let mut target = 0;
    for i in 2..n {
        target ^= arr[i];
    }

    // (a - x)^(b + x) == xor となるような x を見つければ良い

    let sum = arr[0] + arr[1];
    if (sum - target) % 2 == 1 {
        println!("-1");
        return;
    }
    let and = (sum - target) / 2;
    if and & target != 0 {
        println!("-1");
        return;
    }
    if and > arr[0] {
        println!("-1");
        return;
    }

    let mut y = 0;
    for i in (0..64).rev() {
        let bit = 1 << i;
        if bit & target == 0 {
            continue;
        }

        assert_eq!((y | bit) & and, 0);
        if ((y | bit) ^ and) > arr[0] {
            continue;
        }
        y |= bit;
    }
    let a = and ^ y;
    if a == 0 {
        println!("-1");
    } else {
        println!("{}", arr[0] - a);
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
string e, o;
cin >> e >> o;
for(int i= 0; i < e.size(); i++){
  cout << e[i] ;
  if(i < o.size())
  cout << o[i];
}

return 0;

}


Measured memory_bytes: 256
#define llong long long
#define REP(i, n) for (int i = 0; i < n; i++)
#include <iostream>
#include <algorithm>
using namespace std;
static const llong INF = 9999999999;

int main()
{
    int n, a;
    cin >> n >> a;
    cout << n * n - a;
}

Measured memory_bytes: 888
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F         first
#define S          second
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define hell        1000000007
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 1e9
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 10000;


using namespace std;
void solve();

void fastIO() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

bool comp(pair<ll,ll> a,pair<ll,ll> b);
bool comp(pair<ll,ll> a,pair<ll,ll> b){
  if(a.F!=b.F)
  return a.F<b.F;
  else
  return a.S<b.S;
}


void solve(){

  int n,m;
  cin>>n>>m;
  priority_queue<ll,vector<ll>> pq;
  forn(i,0,n)
  {
    ll a;
    cin>>a;
    pq.push(a);
  }

  forn(i,0,m){
    ll a=pq.top();
    pq.pop();
    a/=2;
    pq.push(a);
  }
  ll ans=0;
  while(!pq.empty()){
    ans+=pq.top();
    pq.pop();
  }
  cout<<ans;
}



///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll x,ll y){
  if(x==0)
  return y;
  else
  return gcd(y%x,x);
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1)%hell)*k%hell)%hell;
  else
  return ((pw(k,x/2)%hell)*(pw(k,x/2)%hell))%hell;
}

/*void sieve(){

  for(int i=2;i<=1000000;i++){
    if(prime[i]==true){
      for(int j=i*i;j<=1000000;j+=i)
      prime[j]=false;
    }
  }

}*/


Measured memory_bytes: 1400
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <set>

#define ll long long
#define pll pair<ll, ll>

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

using namespace std;

const int MOD = 1000000007;
const int N = 222222;

ll n;
ll a[N], b[N];

void init()
{
	cin >> n;
	rep(i, n)
	{
		cin >> a[i] >> b[i];
	}
}

ll gcd(ll a, ll b)
{
	while (1)
	{
		if (a < b)
			swap(a, b);
		if (!b)
			break;
		a %= b;
	}
	return a;
}

map<pll, ll> dict;
set<pll> used;

void solve()
{
	ll kai[N] = {0};
	kai[0] = 1;
	reps(i, 1, n + 1)
	{
		kai[i] = (kai[i - 1] * 2) % MOD;
	}

	ll zeroCount = 0;

	rep(i, n)
	{
		ll g = 1;
		if (a[i] != 0 && b[i] != 0)
		{
			g = gcd(abs(a[i]), abs(b[i]));
		}
		if (a[i] == 0 && b[i] == 0)
		{
			zeroCount++;
			continue;
		}
		if (a[i] == 0)
		{
			b[i] = 1;
		}
		if (b[i] == 0)
		{
			a[i] = 1;
		}

		ll aa = a[i] / g;
		ll bb = b[i] / g;

		if (aa < 0)
		{
			aa *= -1;
			bb *= -1;
		}

		pll p = pll(aa, bb);
		dict[p]++;
	}

	ll result = 1;

	for (map<pll, ll>::iterator it = dict.begin(); it != dict.end(); it++)
	{
		pll key = it->first;
		pll rev = pll(key.second, -key.first);
		if (rev.first < 0)
		{
			rev.first *= -1;
			rev.second *= -1;
		}
		if (rev.first == 0)
		{
			rev.second = 1;
		}
		if (rev.second == 0)
		{
			rev.first = 1;
		}

		if (dict.find(rev) != dict.end())
		{
			if (used.find(rev) == used.end())
			{
				ll acount = it->second;
				ll bcount = dict[rev];

				ll kaiPlus = (kai[acount] + kai[bcount] - 1) % MOD;

				result = (result * kaiPlus) % MOD;
				//cout << "cc " << kai[acount] << " " << kai[bcount] << " " << result << endl;

				used.insert(key);
				used.insert(rev);
			}
		}
		else
		{
			result = (result * kai[it->second]) % MOD;

			//cout << "dd " << kai[it->second] << " " << result << endl;
		}
	}

	result = (result + zeroCount) % MOD;

	result -= 1;
	if (result < 0)
	{
		result += MOD;
	}

	cout << result << endl;
}

int main()
{
	init();
	solve();
}


Measured memory_bytes: 20468
c=[[int(x) for x in input().split()] for _ in range(3)]
ans="No"
for a1 in c[0]:
    for a2 in c[1]:
        for a3 in c[2]:
            b1=c[0][0]-a1
            b2=c[1][1]-a2
            b3=c[2][2]-a3
            if a1+b2==c[0][1] and a1+b3==c[0][2] and a2+b1==c[1][0] and a2+b3==c[1][2] and a3+b1==c[2][0] and a3+b2==c[2][1]:
                ans = "Yes"
                break
        if ans=="Yes":break
    if ans=="Yes":break
print(ans)

Measured memory_bytes: 3064
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double x = sc.nextDouble();
		
		// 計算
		double result = 0;
		
		if(x <= a*a*b/2){
		    double t = (a*b*b)/(2*x);
		    result = atan(t)*180/Math.PI;
		}else{
		    double t = (2*a*a*b - 2*x)/(a*a*a);
		    result = atan(t)*180/Math.PI;
		}
		
		// 出力
		System.out.println(result);
		
	}
}

Measured memory_bytes: 25300
N = int(input())
h = [0] + list(map(int, input().split()))
dp = [10 ** 9] * (N + 1)
dp[1] = 0
for i in range(2, N + 1):
    if i == 2:
        dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
    else:
        dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]),
                    dp[i - 2] + abs(h[i] - h[i - 2]))
print(dp[-1])
# print(dp)


Measured memory_bytes: 85616
#include <stdio.h>

int main(void)
{
    char ch;
    int count[26] = {0};

    while (scanf("%c", &ch) != EOF)
    {
        if (ch >= 'A' && ch <= 'Z')
        {
            count[ch - 'A']++;
        }
        if (ch >= 'a' && ch <= 'z')
        {
            count[ch - 'a']++;
        }
    }

    int i = 0;
    char alphabet;
    for (alphabet = 'a'; alphabet <= 'z'; alphabet++)
    {
        printf("%c : %d\n", alphabet, count[i]);
        i++;
    }

    return 0;
}


Measured memory_bytes: 2732
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((-(b))+((a)))<EPS)

int main(){

	double d;
	while(cin>>d&&!EQ(d,-1)){
		int r = (int)d;
		double im=d-r;
		if(r>=256){
			cout<<"NA"<<endl;
			continue;
		}
		else{
			vector<int> v;
			while(r>0){
				v.push_back(r%2);
				r/=2;
			}
			// ÀÌZ
			bool match=false;
			int s;
			for(int i = 0; i < 16; i++){
				double d=0;
				for(int j = 0; j < 4; j++){
					if((i>>j)&1){
						d+=pow(0.5,j+1);
					}
				}
				if(EQ(d,im)){
					match=true;
					s=i;
					break;
				}
			}
			if(match){
				for(int i = 0; i < 8-v.size(); i++){
					cout<<0;
				}
				for(int i = 0; i < v.size(); i++){
					cout<<v[v.size()-1-i];
				}
				cout<<'.';
				// ¬_Ì\¦
				for(int i = 0; i < 4; i++){
					if((s>>i)&1)
						cout<<1;
					else
						cout<<0;
				}
				cout<<endl;
			}
			else
				cout<<"NA"<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define each(it,c) for(__typeof(c.begin()) it=c.begin(); it!=c.end(); it++)
#define INF 1<<30
#define mp make_pair
#define pb push_back

typedef vector<int> vi;

int main(){
	string s;
	cin>>s;
	vi t(s.size(),-1);
	int j = 0;
	rep(i,s.size()){
		if(s[i]=='0') t[j++]=0;
		if(s[i]=='1') t[j++]=1;
		if(s[i]=='B') {
			if(j==0) continue;
			t[--j]=-1;
		}
	}
	rep(i,s.size()){
		if(t[i]==-1) break;
		cout<<t[i];
	}
	cout<<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 repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N,K,Q;
    cin >> N >> K >> Q;
    vector<int> A(Q);
    rep(i,Q){
        cin >> A[i];
    }
    vector<int> point(N,0);
    rep(i,Q){
        point[A[i] - 1]++;
    }
    rep(i,N){
        if (K - Q + point[i] >= 1){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main()
{
int A,B,cost;
cin >> A ;
cin >> B ;
if (A >= 13){
    cost=B;
}
else if(A >= 6){
    cost=B/2;
}
else {
    cost=0;
}
cout << cost ;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
const int N=1e5+10;
vector<int> son[N];
int n,k,ans,h[N];

int dfs(int u)
{
	bool flag=false;
	for(int i=0;i<son[u].size();++i)
	{
		int ht=dfs(son[u][i]);
		if(ht>=k-1) ++ans; else h[u]=max(h[u],ht),flag=true;
	};
	if(flag) ++h[u];
	return h[u];
}

int main()
{
	scanf("%d %d",&n,&k);
	int x;scanf("%d",&x);if(x!=1) ++ans;
	for(int i=2;i<=n;++i) scanf("%d",&x),son[x].push_back(i);
	for(int i=0;i<son[1].size();++i) dfs(son[1][i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 10752
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e18+1e18;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

int main() {
	ll H, W;
	cin >> H >> W;

	ll ans = min(H, W);
	if (H % 3 == 0 || W % 3 == 0) { ans = 0; }

	repn(i, H - 1) {
		ll x = W * i;
		ll y = (W + 1) / 2 * (H - i);
		ll z = W / 2 * (H - i);

		ll now = max<ll>({ x,y,z }) - min<ll>({ x,y,z });
		ans = min(now, ans);
	}

	repn(i, W - 1) {
		ll x = H * i;
		ll y = (H + 1) / 2 * (W - i);
		ll z = H / 2 * (W - i);

		ll now = max<ll>({ x,y,z }) - min<ll>({ x,y,z });
		ans = min(now, ans);
	}

	cout << ans << endl;


}

Measured memory_bytes: 3532
import math
n=int(input()) #　a1
comb=[]

for i in range(1,int(math.sqrt(n))+1):
  if n % i==0:
    comb.append([i,n//i])

ans=float('inf')

for i in comb:
  if len(str(i[0])) > len(str(i[1])):
    pans=len(str(i[0]))
  else:
    pans=len(str(i[1]))


  ans=min(ans,pans)

print(ans)

Measured memory_bytes: 3188
code = r"""
#include <atcoder/segtree>
#include <cstdio>
#include <vector>

using namespace std;
using namespace atcoder;

int op(int a, int b) { return max(a, b); }

int e() { return -1; }

int target;

bool f(int v) { return v < target; }

int main() {
    int n, q;
    scanf("%d %d", &n, &q);
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &(a[i]));
    }

    segtree<int, op, e> seg(a);

    for (int i = 0; i < q; i++) {
        int t;
        scanf("%d", &t);
        if (t == 1) {
            int x, v;
            scanf("%d %d", &x, &v);
            x--;
            seg.set(x, v);
        } else if (t == 2) {
            int l, r;
            scanf("%d %d", &l, &r);
            l--;
            printf("%d\n", seg.prod(l, r));
        } else if (t == 3) {
            int p;
            scanf("%d %d", &p, &target);
            p--;
            printf("%d\n", seg.max_right<f>(p) + 1);
        }
    }
}
"""
import os
import sys
op = open("in.txt", "wt")
while True:
    try:
        op.write(input()+"\n")
    except EOFError:
        break
op.close()
open('a.cpp', 'w').write(code)
os.system('g++ -I /opt/atcoder-stl a.cpp')
os.system('./a.out < in.txt > out.txt')
op = open("out.txt", "r")
while True:
    tmp = op.readline()
    if tmp:
        print(tmp, end='')
    else:
        break
op.close()

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

int main(void){
    
    int N,K;
    cin >> N >> K;
    
    long long H[N];
    for(int i = 0; i < N; i++)cin >> H[i];
    sort(H,H+N,greater<int>());
    
    long long sum = 0;
    for(int i = 0; i < N ; i++){
        if(i > K - 1)sum += H[i];
    }
    cout << sum  <<endl;
    
    return 0;
    
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;
char cm[200][200];
int im[200][200];
 int W,H;
bool visited[200][200];
int sy,sx;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
typedef pair<int,int> P;
int maxx = 1;
int q = 1;

int dp(int x,int y){
 

  for(int i=0;i<4;i++)
    {
      int ny = y+dy[i],nx = x + dx[i];
      if(0 <= nx && nx < W && 0 <= ny && ny < H && cm[ny][nx] != '#' && !visited[ny][nx]){
	q++;
	im[ny][nx] = q;
	maxx = max(maxx,q);
	visited[ny][nx] = true;
	dp(nx,ny);
      }
    }
}


int main(){
 

  while(1)
    {
      cin >> W >> H;
      if(W == 0 && H == 0)break;
      maxx = 1;
      memset(im,0,sizeof(im));
      memset(visited,false,sizeof(visited));
      for(int i=0;i<H;i++)
	{
	  for(int j=0;j<W;j++)
	    {
	      cin >> cm[i][j];
	      if(cm[i][j] == '#'){
		im[i][j] = 0;
	      }
	      else if(cm[i][j] == '@')
		{
		  sy = i;
		  sx = j;
		}
	    }
	}

      im[sy][sx]=1;
      q = 1;
      visited[sy][sx] = true;
      dp(sx,sy);
      cout << maxx  << endl;
      /*          
 for(int i=0;i<H;i++){
	for(int j=0;j<W;j++)cout << im[i][j];
	cout << endl;
      }
      */

    }
}

Measured memory_bytes: 0
#include <utility>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <numeric>
#include <limits>
#include <queue>
#include <cstdint>
#define ll long long int
#define rep(i,rept) for (ll i = 0; i < rept; i++)
#define Yes(b) std::cout<< (b ? "Yes" : "No")<<std::endl
#define YES(b) std::cout<< (b ? "YES" : "NO")<<std::endl
#define fr first
#define se second
#define lolo 92233720368547757
#define susu 1000000007

using namespace std;
int main() {
	int k, count = 0, n = 0;
	cin >> k;
	for (ll j = 1; j <= k; j++) {
		for (ll i = 1; i <= j; i++) {
			if (j%i == 0) {
				count++;
			}
		}
		if (j % 2 == 1 && count == 8)
			n++;
		count = 0;
	}
	cout << n;
	return 0;
}

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

int main() {
  int N,A,X;
  cin >> N >> A;
  X = N % 500;
  if (X - A <= 0){
    cout << "Yes" << endl;
  }else if (X - A > 0){
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){

  int a,b,c;

  scanf("%d %d %d", &a,&b,&c);

  if(a<b && b<c){
    printf("Yes");  
  }
  
  else{
    printf("No");
  };
  
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define FOR(a,b,c) for(int a=b,___=c;a<=___;++a)
#define fordec(a,b,c) for(int a=b;a>=c;--a)
#define forv(a,b) for(auto &a:b)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define all(a) a.begin(),a.end()
#define reset(f,x) memset(f,x,sizeof(f))
#define vt vector<int>
#define vpi vector<pair<int,int>>
#define bit(x,i) (x>>(i-1)&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))
#define task ""
#define int long long
template<typename X,typename Y>void Min(X &x,Y y){x=(x>y)?y:x;}
template<typename X,typename Y>void Max(X &x,Y y){x=(x<y)?y:x;}
template<typename X>void read(X &x){x=0;int n=0;char c=getchar();for(;!isdigit(c);c=getchar())n+=(c=='-');for(;isdigit(c);c=getchar())x=x*10+c-'0';x=(n&1)?-x:x;}
template<typename X,typename... Y>void read(X &x,Y&... y){read(x);read(y...);}
const int N=505;
int n,m,k;
int a[N][N];
int ans[N][N],Ans;
vector<pair<int,int>> v;
#define rr(x) " "<<#x<<'='<<x<<" "
main()
{
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
   //freopen("b.inp","r",stdin);
    cin>>n>>m>>k;
    FOR(i,1,n) FOR(j,1,m)
    {
        char c;
        cin>>c;
        if(c=='#') v.pb({i,j});
    }
    sort(v.begin(),v.end());
    //forv(i,v) cout<<i.x<<" "<<i.y<<"\n";

    int las=0;
    FOR(i,0,v.size()-1) if(i==v.size()-1||v[i].x!=v[i+1].x)
    {
        int las2=las;
        //cout<<"====" rr(las) rr(i) "\n";
        FOR(j,las,i) if(j==i||v[j].y!=v[j+1].y)
        {
            //cout<<rr(las2) rr(j) "\n";
            ++Ans;
            FOR(ii,las==0?1:v[las-1].x+1,i==v.size()-1?n:v[i].x) FOR(jj,las2==las?1:v[las2-1].y+1,j==i?m:v[j].y)
            {
                ans[ii][jj]=Ans;
            }
            las2=j+1;
        }
        las=i+1;
    }
    FOR(i,1,n) FOR(j,1,m) cout<<ans[i][j]<<" \n"[j==m];
}


Measured memory_bytes: 3568
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

template<typename T> bool chmax( T &a, T b ) { if ( a < b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, T b ) { if ( a > b ) { a = b; return ( true ); } else { return ( false ); } }

using namespace std;

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

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp( a, b ) make_pair( a, b )
#define mt( ... ) make_tuple( __VA_ARGS__ )

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()

#define MOD ( 1e9 + 7 )


int main()
{
	ll N, Q;
	string S;
	cin >> N >> Q;
	cin >> S;

	vector<Pll> v( Q );
	rep( i, Q )
	{
		cin >> v[i].F >> v[i].S;
	}

	vector<ll> vv( N + 1 );
	vv[0] = 0;
	reps( i, N - 1 )
	{
		vv[i] = vv[i - 1];
		if ( S[i] == 'C' )
		{
			if ( S[i - 1] == 'A' )
			{
				vv[i] += 1;
			}
		}
	}

	rep( i, Q )
	{
		cout << ( vv[v[i].S - 1] - vv[v[i].F - 1] ) << endl;
	}

	return ( 0 );
}


Measured memory_bytes: 3392
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

public class Main {

    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String s = br.readLine();
            DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
            LocalDate date = LocalDate.parse(s, dateTimeFormatter);
            LocalDate date0430 = LocalDate.of(2019, 4, 30);
            if (date.isAfter(date0430)) {
                System.out.println("TBD");
            } else {
                System.out.println("Heisei");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}

Measured memory_bytes: 28372
n=int(input())
str_n=str(n)
list_n=list(str_n)
count=0
for i in range(1,n+1):
	if(i%3==0 or i%5==0):
		count+=0
	elif(i%3==0):
		count+=0
	elif(i%5==0):
		count+=0
	else:
		count+=i

print(int(count))
		


Measured memory_bytes: 9072
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
using Graph = vector<vector<int> >;
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; }
//#define int long long

const int MAX = 4000400;
//vector<bool> は bitset<N> で定数倍高速化可能(64倍) (N = 2000 で N^3も通るくらい速い)

void solve() {
	int n; cin >> n;
    vector<int> a(n);
    int sum = 0;
    //部分集合とその補集合を考えたとき、うまいこと1対1対応があるので、大きい方半分の最小値
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }
    //ナップサックのような部分和でO(N * NA)
    //配列の使い回しが可能
    bitset<MAX> dp;
    dp[0] = 1;
    rep(i, n) {
        dp |= (dp << a[i]);
    }
    ll res;
    for(res = (sum + 1) / 2; res < MAX; ++res) {
        if(dp[res]) break;
    }
    cout << res << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

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

public class Main {


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

        FastReader fs = new FastReader();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int a = fs.nextInt();
        int b = fs.nextInt();
        int c = fs.nextInt();
        int d = fs.nextInt();
int turn = 0 ;
String ans = "";
        while (true){

            if(turn==0){

                c = c - b;

                if(c<=0){
                    ans = "Yes";
                    break;
                }

                turn =1;
            }else{

                a = a -d;

                if(a<=0){
                    ans = "No";
                    break;
                }

                turn =0;
            }

        }

        out.println(ans);

        out.close();

    }

    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
    //--------------------------------------------------------
}


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




int main()
{
    string s,t;
    int n,m,i,j;
    cin>>s>>t;
    n=s.length();
    m=t.length();
    int dp[n+1][m+1];
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=m;j++)
        {
            if(i==0||j==0)
                dp[i][j]=0;
            else if(s[i-1]==t[j-1])
                dp[i][j]=1+dp[i-1][j-1];
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    int l=dp[n][m];
    char ans[l];
    i=n,j=m;
    while(i>0 && j>0)
    {
        if(s[i-1]==t[j-1])
        {
            ans[l-1]=s[i-1];
            i-=1;
            j-=1;
            l-=1;
        }
        else
        {
            if(dp[i-1][j]>dp[i][j-1])
                i-=1;
            else
                j-=1;
        }
    }
    for(i=0;i<dp[n][m];i++)
        cout<<ans[i];

    return 0;
}



Measured memory_bytes: 35456
n,m = map(int,input().split())
ac_list = [0]+[0]*n
wa_list = [0]+[0]*n
 
for _ in range(m):
    p,s = input().split()
    p = int(p)
    if s == 'AC':
        ac_list[p] = 1
    elif s == 'WA' and ac_list[p] == 0:
        wa_list[p] += 1
 
for i in range(1,n+1):
    if ac_list[i] == 0:
        wa_list[i] = 0
 
print(sum(ac_list),sum(wa_list))

Measured memory_bytes: 11168
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let n = read::<i64>();
  if n < 1000 {
    println!("ABC");
  } else {
    println!("ABD");
  }
}



Measured memory_bytes: 4352
#define _[2<<17]
n,i;A _,B _,T _,F _;long M,D _,P _,R _;
s(u,i,p){i?s(u,T[i],p),B[i]-p?s(B[i],F[B[i]],u),D[u]=D[u]*-~D[B[i]]%M:0,R[i]=R[T[i]]*(B[i]-p?-~D[B[i]]:1)%M:(D[u]=1);}
S(u,x,p,i,I){for(i=F[u];I=B[i];I-p?S(I,R[i]*x%M+1,u,0,0),x=x*-~D[I]%M:0)i=T[i];P[u]=x%M;}
//s(u,p,i,I){D[u]=1;for(i=F[u];I=B[i];i=T[i])I-p?s(I,u),D[u]=D[u]*-~D[I]%M:0;}
//S(u,x,p,i,I){for(m(i=F[u],p);I=B[i];I-p?S(I,R[i]*x%M+1,u,0,0),x=x*-~D[I]%M:0)i=T[i];P[u]=x%M;}
//m(i,p){i&&m(T[i],p);R[i]=R[T[i]]*(B[i]-p?printf("p: %d\n",p),-~D[B[i]]:1)%M;}
main(u,v){for(;~scanf("%d%d",&u,&v);)i++?A[i-1]=B[i]=u,B[i-1]=A[i]=v,i++:(n=u,M=v);for(;--i;F[A[i]]=i)T[i]=F[A[i]];
	s(*R=1,F[1],0);
	//s(*R=1,0,0,0,0);
	for(S(1,1,0);i++<n;)printf("%d ",P[i]);
}

Measured memory_bytes: 14592
use std::io;
use std::io::Read;

fn main() {
    let mut buffer = String::new();

    io::stdin().read_to_string(&mut buffer).unwrap();

    let a = buffer.split_whitespace().map(|s| s.parse::<f64>().unwrap()).collect::<Vec<f64>>();

    println!("{}", (a[0] / a[1]).ceil());
}


Measured memory_bytes: 4352
#include <stdio.h>
int main(void){
    
    int n,i,s=0;
    int a[200];
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
   
   for(i=0;i<n;i++){
       if(a[i]%2!=0)break;
       a[i]/=2;
       if(i==n-1){
           s++;
           i=0;
       }
       
   }
    
    printf("%d\n",s);
    
    
}


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

int n, q, c, b, temp, ans, l, r;
bool com;

int main() {
    cin >> n >> q;
    int f;
    if (n > 1) f= log2(n-1) + 2; else f = 1;
    int a[f][n];
    for (int i=0; i<n; i++) {
        for (int j=0; j<f; j++) a[j][i] = 0;
    }
    for (int i=0; i<q; i++) {
        cin >> com >> b >> c;
        if (!com) {
            temp = b-1;
            for (int j=0; j<f; j++) {
                a[j][temp] += c;
                temp /=2;
            }
        }
        else {
            l=b; r=c; ans = 0;
            for (int curr=0; curr < f; curr++) {
                if (l > r) break;
                if (l%2 == 0) ans+=a[curr][l-1];
                if (r%2 == 1) ans+=a[curr][r-1];
                if (l==r) break;
                l=l/2 + 1;
                r/=2;
            }
            cout << ans << endl;
            ans = 0;
        }
    }
}


Measured memory_bytes: 10308
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    long long N, M;

    scanf("%lld%lld", &N, &M);

    if(N == 1 && M == 1){
        printf("1\n");
    }else if(N == 1){
        printf("%lld\n", M - 2);
    }else if(M == 1){
        printf("%lld\n", N - 2);
    }else{
        printf("%lld\n", N * M - 2 * (N + M - 2));
    }

    return 0;
}

Measured memory_bytes: 1708
#include "bits/stdc++.h"
using namespace std;
void __dump(int x){cerr << x;}
void __dump(long long x){cerr << x;}
void __dump(long double x){cerr << fixed << setprecision(3) << x;}
void __dump(char x){cerr << '\'' << x << '\'';}
void __dump(const string &x){cerr << '"' << x << '"';}
void __dump(const char *x){cerr << '"' << x << '"';}
void __dump(bool x){cerr << (x ? "true" : "false");}
void _dump(){cerr << "\n";}
template <typename T, typename U> void __dump(const pair<T, U> &x){cerr << '{'; __dump(x.first); cerr << ','; __dump(x.second); cerr << '}';}
template <typename T, typename U, typename V> void __dump(const tuple<T, U, V> &x){cerr << '{'; __dump(get<0>(x)); cerr << ',';  __dump(get<1>(x)); cerr << ',';  __dump(get<2>(x)); cerr << '}';}
template <typename T> void __dump(const T& x){int f=0; cerr << '{'; for(auto&i:x) cerr << (f++ ? "," : ""), __dump(i); cerr << "}";}
template <typename T, typename ... U> void _dump(T t, U ... u){__dump(t); if(sizeof...(u)) cerr << ", "; _dump(u...);}
#define dump(x ...) cerr  <<  "|| "  <<  # x  <<  "  =  ", _dump(x) 
//#define int long long
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define size(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define ln '\n'
#define __ ' '
#define LL long long
#define LD long double
#define pii pair<int,int>
const int INF = 2e9;
const int NN = 1e5;
int x;
vector<pii> adj[NN+3];
set<pii> ss;
int dist[NN+3];

int main(){ FAST
	cin >> x;

	for(int u=0; u<x; ++u){
		int v1 = (u+1) %x;
		adj[u].emplace_back(v1, 1);

		int v2 = (u*10) %x;
		adj[u].emplace_back(v2, 0);
	}

	for(int u=0; u<x; ++u) dist[u] = INF;
	dist[1] = 1;

	for(int u=0; u<x; ++u) ss.insert({dist[u], u});
	while(!ss.empty()){
		int u, d;
		tie(d, u) = *ss.begin();
		ss.erase(ss.begin());

		if(d > dist[u]) continue;

		for(auto el: adj[u]){
			int v,w;
			tie(v,w) = el;
			if(dist[u] + w < dist[v]){
				dist[v] = dist[u] + w;
				ss.insert({dist[v], v});
			}
		}
	}

	cout << dist[0] << ln;

}

Measured memory_bytes: 13056
import sys
input = sys.stdin.readline
N,M = map(int,input().split())
lst=[int(input()) for i in range(M)]
t=0
ans=[0]*(N+1)
ans[0]=1
for j in range(N):
 if M!=0:
  if lst[t]==j+1:
   ans[j+1]=0
   t+=1
   t=min(M-1,t)
  else:
   ans[j+1]+=ans[j]
   if j!=0:
    ans[j+1]+=ans[j-1]
   ans[j+1]%=(10**9+7)
 else:
  ans[j+1]+=ans[j]
  if j!=0:
   ans[j+1]+=ans[j-1]
  ans[j+1]%=(10**9+7)
print(ans[N])

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


int main() {
  vector<int> v(100001,0);
  int n; cin>>n;
  ll sum=0;
  rep(i,n){
    int a; cin>>a;
    sum+=a;
    v[a]++;
  }
  int q; cin>>q;
  rep(i,q){
    int b,c; cin>>b>>c;
    sum+=v[b]*(c-b);
    cout<<sum<<endl;
    v[c]+=v[b];v[b]=0;
  }
}

Measured memory_bytes: 3668