akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#include <iterator> 
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);


#define PI 3.14159265

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
//~ const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};



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




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

using namespace std;

int make_keta_number(int number){
  int keta = 0;
  while(number != 0){
    keta++;
    number/=10;
  }
  return keta;
}

int main(){
  int n;
  cin>>n;
  int ans =0;
  for(int i=1;i<=n;i++){
    if(make_keta_number(i) % 2 == 1) ans++;
  } 
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main() {
  string s, t;
  cin >> s >> t;
  cout << t << s << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (sc.next().equals(s))System.out.println((a-1)+" "+b);
        else System.out.println(a+" "+(b-1));
    }
}


Measured memory_bytes: 38724
while True:
    n = int(input())
    if n == 0:
        break
    d = {}
    for _ in range(n):
        a, b = input().split()
        d[a] = b
    m = int(input())
    ans = ""
    for _ in range(m):
        a = input().strip()
        try:
            ans += d[a]
        except:
            ans += a
    print(ans)

Measured memory_bytes: 7776
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <cmath>
#include <algorithm>
#include <map>
#include <list>

using namespace std;

#define FOR( i, k, n ) for ( int i = ( k ); i < ( int )( n ); ++i )
#define REP( i, n ) FOR( i, 0, n )

#define MAX_R 10
#define MAX_C 10000

typedef pair< int, int > P;

int main()
{
	int R, C;
	while( cin >> R >> C, R || C ) {
		bool is_failed[ MAX_R ][ MAX_C ];
		REP( i, R ) REP( j , C ) cin >> is_failed[ i ][ j ];

		int ans = 0;
		REP( k, ( 1 << MAX_R ) ) {
			int tmp[ MAX_R ][ MAX_C ];
			// 行をひっくり返す
			REP( i, R ) {
				if( k & ( 1 << i ) ) { REP( j, C ) tmp[ i ][ j ] = !is_failed[ i ][ j ]; }
				else { REP( j, C ) tmp[ i ][ j ] = is_failed[ i ][ j ]; }
			}
			// 列をひっくり返す（カウント）
			int cnt = 0;
			REP( j, C ) {
				int cnttmp = 0;
				REP( i, R ) if( !tmp[ i ][ j ] ) { ++cnttmp; }
				cnt += max( cnttmp, R - cnttmp );
			}
			ans = max( ans, cnt );
		}

		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int x;
    cin >> x;
    cout << x*x*x << endl;
    return 0;
}


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

// @@ !! LIM(f:updMaxMin)
// --> f:updMaxMin
// ---- inserted function updMaxMin from util.cc
template<typename T>
bool updMax(T& tmax, const T& x) {
  if (x > tmax) { tmax = x; return true;  }
  else          {           return false; }
}
template<typename T>
bool updMin(T& tmin, const T& x) {
  if (x < tmin) { tmin = x; return true;  }
  else          {           return false; }
}
// ---- end updMaxMin
// @@ !! LIM  -- end mark --

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);


  ll N, M; cin >> N >> M;
  ll big = ll(1e5 + 10) * (M + 10);
  vector<ll> val(1<<N, big);
  val[0] = 0;
  for (ll i = 0; i < M; i++) {
    vector<ll> prev(val);
    ll a, b; cin >> a >> b;
    ll x = 0;
    for (ll j = 0; j < b; j++) {
      ll c; cin >> c; c--;
      x |= (1 << c);
    }
    for (ll y = 0; y < (1<<N); y++) {
      updMin(val[y | x], prev[y] + a);
    }
  }
  ll k = val[(1<<N) - 1];
  cout << (k >= big ? -1 : k) << endl;

  return 0;
}



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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        if (A+B<=16 && A<=8 && B<=8) System.out.println("Yay!");
        else System.out.println(":(");
    }
}

Measured memory_bytes: 22484
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;

int main() {
    double a, b, c, d;
    double f, g;

    cin >> a >> b >> c >> d;
    f = pow((c - a),2);
    g = pow((d - b),2);
    printf("%lf\n", sqrt(f+g)); 
}




Measured memory_bytes: 3148
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define C(x) std::cout << #x << " : " << x << std::endl
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;

template<typename T>
class hashmap64 {
	std::vector<std::pair<uint64, T>> map;
	uint64 mask, count, temp;
	uint64 hash64(uint64 key) {
		key = ~key;
		key ^= key << 13;
		key ^= key >> 19;
		return key ^ (key << 17);
	}
public:
	hashmap64() :map(8192, std::make_pair(~static_cast<std::uint_fast64_t>(0), T())) {
		mask = 8191; count = 0;
	}
	hashmap64(size_t s){
		s |= s << 1;
		s |= s >> 2;
		s |= s >> 4;
		s |= s >> 8;
		s |= s >> 16;
		s |= s >> 32;
		mask = s;
		count = 0;
		map.resize(s + 1, std::make_pair(~static_cast<std::uint_fast64_t>(0), T()));
	}
	T &operator[](uint64 suf) {
		temp = mask&hash64(suf);
		while (map[temp].first != suf) {
			temp = mask&(temp + 1);
		}
		return map[temp].second;
	}
	void insert(uint64 key, const T &value) {
		temp = mask&hash64(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				map[temp].second = value;
				return;
			}
			temp = mask&(temp + 1);
		}
		map[temp] = std::make_pair(key, value);
		++count;
		if ((count << 1) > mask) {
			std::pair<uint64, T> mkey;
			mask = mask << 1 | 1;
			map.resize(mask + 1, std::make_pair(~static_cast<std::uint_fast64_t>(0), T()));
			for (uint64 t = 0;t <= mask >> 1;++t) {
				if (!~map[t].first) {
					mkey = map[t];
					map[t].first = ~0;
					temp = mask&hash64(mkey.first);
					while (~map[temp].first) {
						temp = mask&(temp + 1);
					}
					map[temp] = mkey;
				}
			}
		}
		return;
	}
	bool find(uint64 key) {
		temp = mask&hash64(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				return true;
			}
			temp = mask&(temp + 1);
		}
		return false;
	}
	bool empty(void) {
		return !count;
	}
	size_t size(void) {
		return count;
	}
};

int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	hashmap64<uint32> map(200001);
	uint32 n;
	std::cin >> n;
	int64 a, sum = 1e15;
	uint32 ans = 0;
	map.insert(sum, 0);
	rep(i, 0, n) {
		std::cin >> a;
		sum += a;
		if (map.find(sum)) {
			ans = std::max(ans, i + 1 - map[sum]);
		}
		else {
			map.insert(sum, i + 1);
		}
	}
	std::cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 10900
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;


int n,k;
int a[200005];


int main()
{
    cin >> k >> n;
    int ans = 0;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a,a+n);
    for (int i = 0; i < n-1; i++) ans = max(ans,a[i+1] - a[i]);
    ans = max(ans, k - a[n-1] + a[0]);
    cout << k -ans;
    return 0;
}


Measured memory_bytes: 1024
extern crate core;

use std::str::FromStr;
use std::fmt;

struct Istream {
    line: Vec<String>,
    position: usize
}
type Parse<T: FromStr> = Result<T, T::Err>;
impl Istream {
    fn new() -> Istream {
        Istream {line:vec![], position: 0}
    }
    fn read_word(&mut self) -> &String {
        if self.position == self.line.len() {
            let mut line= String::new();
            std::io::stdin().read_line(&mut line).ok();
            self.line = line.split_whitespace().map(|x|x.to_string()).collect();
            self.position = 0
        }
        let result = &self.line[self.position];
        self.position += 1;
        result
    }
    fn read(&mut self) -> String {
        self.read_word().to_string()
    }
    fn get<T: FromStr>(&mut self) -> T {self.read_word().parse().ok().unwrap()}
    fn read_usize(&mut self) -> usize {self.get()}
    fn read_int(&mut self) -> i32 {self.get()}
    fn read_long(&mut self) -> i64 {self.get()}
    fn read_double(&mut self) -> f64 {self.get()}
}
macro_rules! iterate {
    ($generator:expr; $count:expr; $type:ty) => {{
        let mut vec = Vec::<$type>::with_capacity($count);
        for i in 0 .. $count {
            vec.push($generator);
        }
        vec
    }}
}
macro_rules! yields {
    ($count:expr; $block:block) => {{
        let mut vec = Vec::with_capacity($count);
        for _ in 0 .. $count {
            vec.push($block);
        }
        vec
    }}
}
fn main() {
    let mut input = Istream::new();
    let mut greatest_prime_factor = vec![0 as i32; 1000001];
    let mut sum_prime_factor = vec![0 as i32; 1000001];
    greatest_prime_factor[0] = 0;
    for i in 2 .. 1000001 {
        if greatest_prime_factor[i] == 0 {
            let mut j = i;
            while j <= 1000000 {
                sum_prime_factor[j] += greatest_prime_factor[j];
                greatest_prime_factor[j] = i as i32;
                j += i;
            }
        }
    }
    loop {
        let a = input.read_usize();
        let b = input.read_usize();
        if a == 0 && b == 0 {
            break
        }
        if greatest_prime_factor[a] - sum_prime_factor[a] > greatest_prime_factor[b] - sum_prime_factor[b] {
            println!("a")
        }else {
            println!("b")
        }
    }
}


Measured memory_bytes: 13124
#include <stdio.h>

int bubbleSort(int *, int);

int main(){
  int n, number[100], a, count;
  scanf("%d",&n);
  for(a = 0; a < n; a++){
    scanf("%d",&number[a]);
  }

  count = bubbleSort(number, n);
  for(a = 0; a < n-1; a++){
    printf("%d ",number[a]);
  }
  printf("%d\n",number[a]);
  printf("%d\n",count);
  return 0;
}

int bubbleSort(int *p, int n){
  int flag=1, a=0, b, temp, count=0;
  while(flag == 1){
    flag = 0;
    for(b = n-1; b > a; b--){
      if(*(p+b) < *(p+(b-1))){
	temp = *(p+b);
	*(p+b) = *(p+(b-1));
	*(p+(b-1)) = temp;
	flag = 1;
	count++;
      }
    }
    a++;
  }
  return count;
}



Measured memory_bytes: 2104
import java.io.*;

class Main
{
   public static void main(String[] args) throws IOException
   {

      BufferedReader br =
         new BufferedReader (new InputStreamReader(System.in));

      String str = br.readLine();
      int x = Integer.parseInt(str);

      //System.out.println(x~3);
      //System.out.println(x*x*x);
      //System.out.println(Math.pow(x,3) );
      System.out.println( (int)Math.pow(x,3) );

   }
}

Measured memory_bytes: 24336
fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(&mut std::io::stdin(), &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => {
            get().parse::<$t>().unwrap()
        };
        () => {
            get!(i64)
        };
    }

    let (x, y, z) = (get!(), get!(), get!());
    println!("{} {} {}", z, x, y);
}


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

using namespace std;

vector<pair<int,int> > persons[20];
int n;

int check(int mask){
    for(int i=0;i<n;++i)
        if((mask & (1<<i)) != 0)
            for(int j=0;j<persons[i].size();++j){
                pair<int,int> p = persons[i][j];
                if((!p.second and (mask & (1<<p.first)) != 0) or (p.second and (mask & (1<<p.first)) == 0))
                    return 0;
            }
    return __builtin_popcount(mask);
}

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;

    int t; 
    for(int i=0;i<n;++i){
        cin >> t;

        int x, y;
        while(t--){
            cin >> x >> y;
            x--;
            persons[i].push_back(make_pair(x,y));
        }
    }

    int sol = 0;
    for(int mask=0;mask<(1<<n);++mask)
        sol = max(sol, check(mask));
    
    cout << sol << '\n';    

    return 0;
}

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

using namespace std;

const int MAX = 10E+6;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {

    COMinit();

    int n;
    cin >> n;
    vector<int> a(n+1);
    for(int i=0; i<n+1; i++) {
        cin >> a[i];
    }

    int l = -1;
    int r = -1;
    vector<bool> check(n+2, false);
    for(int i=0; i<n+1; i++) {
        if(check[a[i]] == true) {
            int target = a[i];
            for(int j=0; j<n+1; j++) {
                if(a[j] == target && l == -1) {
                    l = j;
                }
                else if(a[j] == target) {
                    r = j;
                }
            }
            break;
        }
        else {
            check[a[i]] = true;
        }
    }

    l++;
    r++;


    for(int k=1; k<=n+1; k++) {
        cout << (COM(n+1, k) - COM(l+n-r, k-1)+MOD)%MOD << endl;
    }

    return 0;
}

Measured memory_bytes: 236032
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int count = 1;
		int result = 0;
		while (count < b) {
			--count;
			count += a;
			++result;
		}
		System.out.println(result);
	}
}


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

int main() {
  int N;
  cin >> N;
  int count = 0;
  int answer = 0;
  //それぞれ２で最大何回割れるか考える
  
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    while (x % 2 == 0) {
      count += 1;
      x /= 2;
    }
    if (i == 0) {
      answer = count;
      count = 0;
      continue;
    }
    
    if (answer > count) {
      answer = count;
      count = 0; //countリセット
    }
    count = 0;
  }
  cout << answer << endl;
}
    

Measured memory_bytes: 256
#include <iostream>
#include<set>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn =1e5+10;
int a[maxn];
multiset<int> q;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i=1;i<=n;i++)
        cin >> a[i];
    for(int i=1;i<=n;i++)
    {
        multiset<int>:: iterator it =q.lower_bound(a[i]);
        if(it==q.begin())
            q.insert(a[i]);
        else
        {
            it--;
            q.erase(it);
            q.insert(a[i]);
        }
    }
    cout << q.size();
    return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
int main(){
    string s, t, u;
    LL a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if(u == s) {
        a--;
    }else if(u == t){
        b--;
    }
    cout << a << " " << b << endl;

    return 0;
}

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

int main(void) {
    string a, b;
    cin >> a >> b;
    int n = stoi(a + b);
    for (int i = 0; i <= 1000; i++) {
        if (i * i == n) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3568
/*********************
 * @author: I_Love_Thuy_Linh
 *
 *********************/

#include <bits/stdc++.h>
#define all(s) (s).begin(),(s).end()
using namespace std;
int H, W, M;

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> H >> W >> M;
    //vector<vector<int>> grid(H,vector<int> (W,0));
    vector<int> row(H);
    vector<int> col(W);
    map<pair<int,int>,int> grid;
    for (int i = 0; i < M; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        grid.insert(pair<pair<int,int>,int>({x,y},1));
        row[x]++;
        col[y]++;
    }
    
    int max_row = *max_element(all(row));
    int max_col = *max_element(all(col));

    vector<int> row_idx;
    vector<int> col_idx;

    for (int i = 0; i < H; i++) 
        if (row[i] == max_row) row_idx.emplace_back(i);

    for (int i = 0; i < W; i++)
        if (col[i] == max_col) col_idx.emplace_back(i);


    for (int r: row_idx)
        for (int c: col_idx)
            if (grid.find(pair<int,int>(r,c)) == grid.end()){
                cout << max_row + max_col;
                return 0;
            }
   cout << max_row + max_col - 1;
    return 0;
}


Measured memory_bytes: 28452
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int a,b;  //定义
int main()
{
    cin>>a>>b;  //输入a,b
    if(a%3==0||b%3==0||(a+b)%3==0)  //这里就是判断
        cout<<"Possible\n";  //输出可能
    else
        cout<<"Impossible\n";  //否则输出不可能
    return 0;
}

Measured memory_bytes: 256
D = [[-1, -1], [-1, 0], [0, 1], [1, 1], [1, 0], [0, -1]]
loop do
  t, n = gets.split.map(&:to_i)
  break if t == 0
  fld = 128.times.map{ [0] * 128 }
  n.times{ c, r = gets.split.map(&:to_i); fld[r + 64][c + 64] = false }
  sx, sy = gets.split.map(&:to_i).map{ |a| a + 64 }
  pts = 2.times.map{ [] }
  pts[0] << [sy, sx]
  fld[sy][sx] = 1
  t.times do
    pts[0].each do |y, x|
      D.each do |mx, my|
        p, q = y + my, x + mx
        if fld[p][q] == 0
          pts[1] << [p, q]
          fld[p][q] = 1
        end
      end
    end
    pts[0], pts[1] = pts[1], []
  end
  p fld.flatten.count{ |f| f == 1 }
end

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int ten[2222][2222];
int tatehenn[2222][2222];
int yokohenn[2222][2222];

int main(){
	
	int seica,chan,dayo;cin >> seica >> chan >> dayo;
	
	for(int i = 1; i <= seica;i++){
		string moziretu;cin >> moziretu;
		for(int j = 1;j <= chan;j++){
			if(moziretu[j-1] == '1')ten[i][j] = 1; 
		}
	}
	
	for(int i = 1; i <= seica;i++){
		for(int j = 1;j <= chan;j++){
			if(ten[i][j]){
				tatehenn[i][j] = ten[i-1][j];
				yokohenn[i][j] = ten[i][j-1];
			}
		}
	}
	
	for(int i = 1; i <= seica;i++){
		for(int j = 1;j <= chan;j++){
			ten[i][j+1] += ten[i][j];
			tatehenn[i][j+1] += tatehenn[i][j];
			yokohenn[i][j+1] += yokohenn[i][j];
		}
	}
	
	for(int i = 1; i <= seica;i++){
		for(int j = 1;j <= chan;j++){
			ten[i+1][j] += ten[i][j];
			tatehenn[i+1][j] += tatehenn[i][j];
			yokohenn[i+1][j] += yokohenn[i][j];
		}
	}
		
	REP(i,dayo){
		int neko, ni, nari, tai;
		cin >> neko >> ni >> nari >> tai;
		int ten_no_kazu = ten[nari][tai] - ten[neko-1][tai] - ten[nari][ni-1] + ten[neko-1][ni-1];
		int tatehen_no_kazu = tatehenn[nari][tai] - tatehenn[neko][tai] - tatehenn[nari][ni-1] + tatehenn[neko][ni-1];
		int yokohen_no_kazu = yokohenn[nari][tai] - yokohenn[neko-1][tai] - yokohenn[nari][ni] + yokohenn[neko-1][ni];
		int hen_no_kazu = tatehen_no_kazu + yokohen_no_kazu;
		cout << ten_no_kazu - hen_no_kazu << endl;
	}

	return 0;
}

Measured memory_bytes: 59136
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    ll x; cin >> x;
    ll ans = 0;
    for(ll i=1;;i++) {
        if(x <= i*(i+1)/2) {
            ans = i;
            break;
        }
    }
    cout << ans;
}


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

int main(){
  int N;
  cin>>N;
  int x=0;
  vector<pair<int,int>> score(N);
  for(int i=0;i<N;i++){
    cin>>score.at(i).first;
    x+=score.at(i).first;
    score.at(i).second=score.at(i).first%10;
  }
  sort(score.begin(),score.end());
  if(x%10!=0) cout<<x<<endl;
  else{
    bool finished=false;
    for(int i=0;i<N;i++){
      if(score.at(i).second!=0){
        finished=true;
        cout<<x-score.at(i).first<<endl;
        break;
      }
    }
    if(finished==false) cout<<0<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}


int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	// freopen("settling.in", "r", stdin);
	// freopen("settling.out", "w", stdout);

	string a, b;
	cin >> a >> b;

	int n = a.size(), m = b.size();
	int ans = 1e9;

	for(int i = 0; i + m - 1 < n; i++){
		int cnt = 0;
		for(int j = i, pos = 0; j <= i + m - 1; j++, pos++)
			if(a[j] != b[pos])
				cnt++;
		ans = min(ans, cnt);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3600
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;

int main(){
	string a,s,c;
	cin >> a >> s >> c;
	char b = s.front();
	cout << "A" << b << "C" << "\n";
		return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
using namespace std;
int n, a[101], br1, br2;
bool nest(int a, int b){
return a>=b;
}
int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a, a + n, nest);
    for(int i = 0; i < n; i+=2){
        br1 += a[i];
    }
    for(int i = 1; i < n; i+=2){
        br2 += a[i];
    }
    cout << br1 - br2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

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

    int res = 0;
    for (int i = 0; i < n; i++)
    {
        int a = x[i];
        int b = k - x[i];
        res += min(a, b) * 2;
    }

    cout << res << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int math(int a,int b);
int main(void){
    int A=0;
    int B=0;
    int ans=0;
    scanf("%d %d",&A,&B);
    ans=math(A,B);
    printf("%d",ans);
    return 0;
}

int math(int a,int b){
    int ANS=0;
    if(b%a==0){
        ANS=a+b;
    }else{
        ANS=b-a;
    }
    return ANS;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<map>
#define int long long
#define ll long long
using namespace std;
signed main() {
	int a, b, k;
	cin >> a >> b >> k;
	if (a + k - 1 < b - k + 1) {
		for (int i = a; i < a + k; i++)cout << i << endl;
		for (int j = b - k + 1; j <= b; j++)cout << j << endl;
	}
	else for (int k = a; k <= b; k++)cout << k << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
ns = [list(map(int, input().split())) for _ in range(N)]
ms = [list(map(int, input().split())) for _ in range(M)]
for n in ns:
  dmin = 2002002002
  num = -1
  for i, m in enumerate(ms):
    d = abs(n[0]-m[0])+abs(n[1]-m[1])
    if d < dmin:
      dmin = d
      num = i
  print(num+1)

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		try (Scanner scn = new Scanner(System.in)) {
			final int N = scn.nextInt();
			final char[] S = scn.next().toCharArray();

			Set<Double> bs = new HashSet<>(4000);
			for (int b = 0; b < N; b++) {
				if (S[b] != 'B')
					continue;
				bs.add((double) b);
			}

			List<Integer> gs = new ArrayList<>(4000);
			for (int g = 0; g < N; g++) {
				if (S[g] != 'G')
					continue;
				gs.add(g);
			}

			long sum = 0;
			for (int r = 0; r < N; r++) {
				if (S[r] != 'R')
					continue;
				for (int g = 0; g < gs.size(); g++) {
					double max = Math.max(r, gs.get(g));
					double min = Math.min(r, gs.get(g));
					sum += bs.size()
							- (bs.contains(max - (max - min) * 2) ? 1 : 0) //bnx
							- (bs.contains(max - (max - min) / 2) ? 1 : 0)//nbx
							- (bs.contains(max + (max - min)) ? 1 : 0)//nxb
					;
				}
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 46496
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
void solve(); int main() { solve(); return 0; }

void solve() {
  char c; cin >> c;
  cout << (char)(c+1) << endl;
}


Measured memory_bytes: 3628
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

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

signed main() {
    int n;
    string s;
    cin>>n>>s;
    int count=0;
    REP(i,n-2){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
            count++;
        }
    }
    cout<<count<<endl;
    

    // cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
    A - Calc
    https://atcoder.jp/contests/abc172/tasks/abc172_a
*/

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define ll long long // 10 ^ 18
#define forn(i, s, n) for (int i = s; i < n; i++)
#define whilen(val, n) while(n-- && cin >> val)
#define r_1(v) cin >> v
#define r_2(v1, v2) cin >> v1 >> v2

int main() {
    // ios::sync_with_stdio(0);
    // cin.tie(0);
    int a;
    r_1(a);
    cout << a + (a * a) + (a * a * a);
    return 0;
}

Measured memory_bytes: 3584
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var si = bufio.NewScanner(os.Stdin)

func readInt() int {
	si.Scan()
	r, _ := strconv.Atoi(si.Text())
	return r
}
func main() {
	si.Split(bufio.ScanWords)
	si.Buffer(make([]byte, 0), 10000000)
	N, T := readInt(), readInt()
	ret := 0
	l := readInt()
	r := l + T

	for i := 1; i < N; i++ {
		t := readInt()
		if t > r {
			ret += (r - l)
			l = t
			r = t + T
		}
		r = t + T
	}

	fmt.Println(ret + (r - l))

}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)

int main() {
  string O, E;
  cin >> O >> E;
  rep(i, 0, E.size()) {
    cout << O[i] << E[i];
  }
  if(O.size() != E.size()) cout << O.back();
  cout << endl;
  return 0;
}


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

int main(){
	string S;
	long long K;
	cin>>S>>K;
	int pos = S.find_first_not_of('1');
	if(pos == string::npos){
		pos = 0;
	}
	else{
		if(K < pos+1) pos = 0;
	}
	cout<<S[pos] <<endl;
}


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

int main(){
  int64_t A,B;
  cin >> A >> B;
  if (A > 0 && B > 0){
    cout << "Positive" << endl;
  }
  else if (A < 0 && B < 0){
    cout << ((B - A + 1) % 2 == 0 ? "Positive" : "Negative") << endl;
  }
  else {
    cout << "Zero" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    for (int i = 0; i < n - 2; i++) {
        if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>


main()
{
int h,w;
while(1){
	scanf("%d %d",&h,&w);
	if((h|w)==0)break;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			printf("%c",j==0||j==w-1||i==0||i==h-1?'#':'.');
		}
		printf("\n");
	}
	printf("\n");
}
}


Measured memory_bytes: 2052
n=int(input())
li = list(map(int,input().split()))

dp = n* [10**9]
#print(dp)
dp[0]=0
dp[1]=abs(li[1]-li[0])
for i in range(2, n):
    dp[i]=min(dp[i-1] + abs(li[i] - li[i-1]),dp[i-2] + abs(li[i] - li[i-2]) )
#print(dp)
print(dp[-1])

Measured memory_bytes: 13924
#include<iostream>
using namespace std;
int b;
int main()
{
	string a;
	cin>>a;
	int l=a.size();
	for(int i=0;i<l;i++)
	{
		if(a[i]=='S')
		{
			b=0;
			for(int i=0;i<l;i++)
			{
				if(a[i]=='N')
				{
					b=1;
					break;
				}
			}
			if(b==0)
			{
				cout<<"No"<<'\n';
				return 0;
			}
		}
		if(a[i]=='N')
		{
			b=0;
			for(int i=0;i<l;i++)
			{
				if(a[i]=='S')
				{
					b=1;
					break;
				}
			}
			if(b==0)
			{
				cout<<"No"<<'\n';
				return 0;
			}
		}
		if(a[i]=='E')
		{
			b=0;
			for(int i=0;i<l;i++)
			{
				if(a[i]=='W')
				{
					b=1;
					break;
				}
			}
			if(b==0)
			{
				cout<<"No"<<'\n';
				return 0;
			}
		}
		if(a[i]=='W')
		{
			b=0;
			for(int i=0;i<l;i++)
			{
				if(a[i]=='E')
				{
					b=1;
					break;
				}
			}
			if(b==0)
			{
				cout<<"No"<<'\n';
				return 0;
			}
		}
	}
	cout<<"Yes"<<'\n';
	return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
N=int(input())
F=[int(input().replace(' ',''),2) for _ in range(N)]
P=[list(map(int,input().split())) for _ in range(N)]

ans=-10**18
for i in range(1,2**10):
  cnt=0
  for j in range(N):
    cnt+=P[j][bin(F[j] & i).count('1')]
  ans=max(ans,cnt)
print(ans)

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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int INF=8e18;

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

    int t;
    cin>>t;
    while(t--)
    {
        int n,a,b,c,d;
        cin>>n>>a>>b>>c>>d;
        set<pii> s;
        map<int,int> dist;
        s.insert({0,n});
        dist[n]=0;
        int ans=INF;
        while(!s.empty())
        {
            int v=s.begin()->y,
                cur=s.begin()->x;
//            cout<<v<<" : "<<cur<<endl;
            s.erase(s.begin());
            if(!v||(INF-cur)/d/v)
                ans=min(ans,cur+d*v);
            int k,to,len;

            k=2,len=a;
            to=v/k,len+=v%k*d+cur;
            if(!dist.count(to)||dist[to]>len)
                s.erase({dist[to],to}),
                dist[to]=len,
                s.insert({len,to});

            k=3,len=b;
            to=v/k,len+=v%k*d+cur;
            if(!dist.count(to)||dist[to]>len)
                s.erase({dist[to],to}),
                dist[to]=len,
                s.insert({len,to});

            k=5,len=c;
            to=v/k,len+=v%k*d+cur;
            if(!dist.count(to)||dist[to]>len)
                s.erase({dist[to],to}),
                dist[to]=len,
                s.insert({len,to});

            k=2,len=a;
            to=v/k+1,len+=(k-v%k)*d+cur;
            if(!dist.count(to)||dist[to]>len)
                s.erase({dist[to],to}),
                dist[to]=len,
                s.insert({len,to});

            k=3,len=b;
            to=v/k+1,len+=(k-v%k)*d+cur;
            if(!dist.count(to)||dist[to]>len)
                s.erase({dist[to],to}),
                dist[to]=len,
                s.insert({len,to});

            k=5,len=c;
            to=v/k+1,len+=(k-v%k)*d+cur;
            if(!dist.count(to)||dist[to]>len)
                s.erase({dist[to],to}),
                dist[to]=len,
                s.insert({len,to});
        }
        cout<<ans<<"\n";
    }
}


Measured memory_bytes: 4828
from collections import Counter


def main():
    n, m = map(int, input().split())
    a = Counter(list(map(int, input().split())))
    cards = []
    for i, v in a.items():
        cards.append([i, v])
    for _ in range(m):
        cards.append(list(map(int, input().split()))[::-1])
    cards.sort(key=lambda x: x[0], reverse=True)
    ans = 0
    for i, v in cards:
        ans += i * min(v, n)
        n -= min(v, n)
    print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 45148
#include <iostream>
using namespace std;
char ch[1002],set[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
	int i;
	while(1){
		char out[1002];
		for(i=0;i<1002;i++){
			ch[i] = '\0';
			out[i] = '\0';
		}
		cin >> ch;
		if(cin.eof()) break;
		for(i=0;;i++){
			if(ch[i] == '\0') break;
			else {
				if(ch[i] == 'A' || ch[i] == 'B' || ch[i] == 'C'){
					if(ch[i] == 'A') out[i] = 'X';
					else if(ch[i] == 'B') out[i] = 'Y';
					else if(ch[i] == 'C') out[i] = 'Z';
				}
				else{
					int a = (int)(ch[i]-'D');
					out[i] = set[a];
				}
			}
		}
		cout << out << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long LL;

unordered_map<int,int>cnt; 

int main()
{
	int N,M;
	scanf("%d",&N);
	bool ok = true;
	int tmp;
	for (int i=1;i<=N;i++)scanf("%d",&tmp),cnt[tmp]++;
	scanf("%d",&M);
	for (int i=1;i<=M;i++){scanf("%d",&tmp);if (cnt[tmp]-- == 0) ok = false;}
	puts(ok?"YES":"NO"); 
}

Measured memory_bytes: 8520
N = int(input())
listH = [int(i) for i in input().split()]
right = listH[0]
result = "Yes"
for i in range(N-1):
    if right - listH[i+1] > 1:
        result = "No"
    elif listH[i] < listH[i+1]:
        right = listH[i+1]
print(result)

Measured memory_bytes: 14396
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int maxn=100000+100;
int main()
{
    string s;
    cin>>s;
    string t;
    t.clear();
    int ls=s.length();
    for(int i=0;i<ls;i++)
        if(s[i]!='x')
        t.push_back(s[i]);
    int lt=t.length();
    for(int i=0;2*i<lt;i++)
    if(t[i]!=t[lt-1-i]){
        cout<<"-1";
        return 0;
    }
    int aa=0;
    int bb=ls-1;
    int ans=0;
    while(aa<bb){
        int cnt1=0;
        int cnt2=0;
        while(s[aa]=='x'){
            cnt1++;
            aa++;
        }
        while(s[bb]=='x'){
            cnt2++;
            bb--;
        }
        ans+=abs(cnt1-cnt2);
        aa++;
        bb--;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int K=stdIn.nextInt();
		long sum[]=new long[N+2];
		long ans=0;
		for(int i=2;i<N+2;i++){
			sum[i]=sum[i-1]+i;
		}
		for(int i=K;i<N+2;i++){
			ans+=(sum[N+1]-sum[N+1-i]-sum[i])%1000000007;
			ans%=1000000007;
		}
		System.out.println(ans+1);
	}
}


Measured memory_bytes: 37704
n,m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
start = []
goal = []
for a,b in ab:
    if a == 1: start.append(b)
    elif b == n: goal.append(a)
print("POSSIBLE" if list(set(start) & set(goal)) else "IMPOSSIBLE")

Measured memory_bytes: 54608
#include <bits/stdc++.h>
using namespace std;
int main(){
	int k;
	vector<int> a(5);
	for(auto &x:a){
		cin >> x;
	}
	cin >> k;
	for(auto x:a){
		for(auto y:a){
			if(abs(x-y)>k){
				cout << ":(" << endl;
				return 0;
			}
		}
	}
	cout << "Yay!" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}*/

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

	int n;
	cin >> n;
	vector<vector<vector<int>>> f(n, vector<vector<int>>(5, vector<int>(2)));
	
	rep(i, n) {
		rep(j, 5) {
			rep(k, 2) {
				cin >> f[i][j][k];
			}
		}
	}

	vector<vector<int>> p(n, vector<int>(11));
	rep(i, n) {
		rep(j, 11) {
			cin >> p[i][j];
		}
	}

	// やっと問題の意味理解できた

	int ans = -inf;

	// 100 * 2^10 * 10 := 1e6

	Rep(bit, 1, 1 << 10) { // 1か0の10桁の数
		int tmp = 0;

		rep(i, n) { // すべての店で考える
			int num = 0;
			rep(j, 5) { // 被ってる店の数を数える
				rep(k, 2) {
					if (bit & 1 << (j * 2 + k)) {
						if(f[i][j][k])
							num++;
					}
				}
			}
			tmp += p[i][num];
		}
		ans = max(ans, tmp);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
def solve():
    N = int(input())
    counters = []

    for i in range(N):
        counter = defaultdict(int)
        S = input()
        for ch in S:
            counter[ch] += 1

        counters.append(counter)
    
    ans = ""
    for ch_code in range(ord('a'), ord('z')+1):
        ch = chr(ch_code)
        mn = float('inf')
        for counter in counters:
            mn = min(mn, counter[ch])

        ans += ch * mn
    
    print(ans)
    
if __name__ == '__main__':
    solve()

Measured memory_bytes: 3316
#include <iostream>

using namespace std;

int main() {
  string s;
  cin >> s;
  
  int res = 0;
  for (int i = 0; i < 3; ++i) {
    if (s[i] == '1') { ++res; }
  }
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Abra_Ka_Dabra ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;

const long long mod = 1e9 + 7;
const double PI = acos(-1);
const double EPS = 1e-9;

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif

	Abra_Ka_Dabra

	string x, y;
	cin >> x >> y;
	if (x[0] == '-') x.erase(x.begin());
	if (y[0] == '-') y.erase(y.begin());
	if (x.size() > y.size()) cout << "GREATER\n";
	else if (x.size() < y.size()) cout << "LESS";
	else {
		for (int i = 0; i < x.size(); i++) {
			if (x[i] > y[i]) {
				cout << "GREATER\n";
				return 0;
			} else if (x[i] < y[i]) {
				cout << "LESS";
				return 0;
			}
		}
		cout << "EQUAL\n";
	}

	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

template<class T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

int main() {
    ll n,m;
    cin>>n>>m;
    string s,t;
    cin>>s>>t;
    ll ans = n*m/gcd(n,m);
    map<ll,ll> po;

    for(int i=1;i<=n;i++){
        int p = (i-1)*(ans/n)+1;
        po[p]=i;
    }

    for(int i=1;i<=m;i++){

        int p = (i-1)*(ans/m)+1;

        if(po[p]!=0){
            int k = po[p]-1;
            if(s[k]!=t[i-1] ){
                cout<<-1<<endl;
                return 0;
            }
        }
    }

    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 10880
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;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 FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;


int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int a, int b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	int d, n;
	scanf("%d%d", &d, &n);
	int tmp = 1;
	while (d--) tmp *= 100;
	int ans = 0;
	while (n--) {
		ans += tmp;
		if (ans / tmp % 100 == 0)ans += tmp;
	}
	PRINTD(ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
    bool p[100001];
    int c[100001], q, l, r;
    for (int i = 0; i < 100001; i++)
    {
        p[i] = false;
        c[i] = 0;
    }
    for (int i = 2; i < 100001; i++)
    {
        if (p[i] == false)
            for (int j = i * 2; j < 100001; j += i) p[j] = true;
    }
    for (int i = 3; i < 100001; i++)
        if (p[i] == false && p[(i + 1) / 2] == false) c[i]++;
    for (int i = 3; i < 100001; i++) c[i] += c[i - 1];
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        cin >> l >> r;
        cout << c[r] - c[l - 1] << endl;
    }
}

Measured memory_bytes: 4124
#include <bits/stdc++.h>
using namespace std;
int main(void){
    double inf=0.0000001;
    int t, n, m;
    double v, r, pv, pr;
    double dice[15];
    cin >> t;
    for(int i=0; i<t; i++){
        cin >> n >> m;
        dice[i]=0;
        pv=0;
        pr=0;
        for(int j=0; j<m; j++){
            cin >> v >> r;
            dice[i]+=v*r;
            pv+=v;
            pr+=r;
        }
        dice[i]/=pr;
        //cout << dice[i] << "\n";
    }
    int p, q;
    cin >> p >> q;
    dice[t]=0;
    pv=0;
    pr=0;
    for(int i=0; i<q; i++){
        cin >> v >> r;
        dice[t]+=v*r;
        pv+=v;
        pr+=r;
    }
    dice[t]/=pr;
    //cout << dice[t] << "\n";
    
    bool tf=false;
    for(int i=0; i<t; i++){
        if(dice[i]>dice[t]+inf){
            tf=true;
            break;
        }
    }
    cout << (tf ? "YES" : "NO") << "\n";
    
    return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
  string s;
  cin>>s;
  int sum=0;
  r(i,s.size()){
    if(s[i]=='-')sum--;
    else sum++;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	char str[20] = { 0 };
	int i;
	
	scanf("%s", str);

	for(i = 20; i > 0; i--){
		printf("%c", str[i - 1]);
	}
	
	putchar('\n');
	
	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <vector>
#include <cctype>

using namespace std;

int main()
{
	string S;
	cin >> S;
	int N = S.size();
	vector<string> s(N);
	for (int i = 0; i < N; i++)
	{
		s[i] = S.substr(i, 1);
	}
	
	bool isAC = true;
	if (s[0] != "A")
	{
		isAC = false;
	}
	
	int CCount = 0;
	for (int i = 1; i < N; i++)
	{
		// 大文字の場合
		if (isupper(*s[i].c_str())) {
			// i = 1で、先頭文字の次が大文字の場合と
			// i = N - 1で、最後の文字が大文字の場合と
			// C以外の大文字の場合
			if (i == 1 ||
			    i == N - 1 ||
			    s[i] != "C")
			{
				isAC = false;
			}
			
			CCount++;
		}
	}
	
	// Cが1より大きいの場合
	if (CCount != 1)
	{
		isAC = false;
	}
	
	if (isAC == true)
	{
		cout << "AC" << endl;
	}
	else {
		cout << "WA" << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256