akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

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

    while(true) {
      int n = sc.nextInt();
      int r = sc.nextInt();
      int cards[] = new int[n];

      if(n == 0 && r == 0) {
        break;
      }

      for(int i = 0; i < n; i++) {
        cards[i] = n - i;
      }

      for(int i = 0; i < r; i++) {
        int p = sc.nextInt();
        int c = sc.nextInt();
        int temp[] = new int[c];

        for(int j = 0; j < c; j++) {
          temp[j] = cards[p - 1 + j];
        }
        for(int j = p - 2; j >= 0; j--) {
          cards[c + j] = cards[j];
        }
        for(int j = 0; j < c; j++) {
          cards[j] = temp[j];
        }
      }
      System.out.println(cards[0]);
    }
  }
}

Measured memory_bytes: 36672
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for (int i=0;i<N;i++){
    cin>>A.at(i);
  }
  bool finished = false;
  for(int i=0;i<N;i++){
    if(A.at(i)%2==0 & (A.at(i)%3!=0 & A.at(i)%5!=0)){
      finished = true;
      break;
    }
  }
  if(finished){
    cout<<"DENIED"<<endl;
  }
  else{
    cout<<"APPROVED"<<endl;
  }
}



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

int main(int argc, char **argv)
{
	int n;
	cin >> n;
	string s;
	cin >> s;

	int count{1};

	for (int i = 0; i < n-1; ++i)
	{
		if (s[i] != s[i+1])
			++count;
	}
	std::cout << count << std::endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

double S(double a, double b, double c) {
	double z = (a + b + c) / 2;
	return sqrt(z * (z-a) * (z-b) * (z-c));
}

int main() {
	int a, l, x;
	while (scanf("%d%d%d", &a, &l, &x) != EOF) {
		double b = (l+x) / 2.0;
		printf("%.8f\n", S(a, l, l) + 2 * S(l, b, b));
	}
}

Measured memory_bytes: 1224
#include<iostream>
#include<iomanip>
#include<string.h>
#include<algorithm>
#include<map>
using namespace std;
#define ll long long
char ch[110];
int main()
{
	cin>>ch;
	int len=strlen(ch);
	int l=0,r=len-1;
	int count=0;
	while(l<=r)
	{
		if(ch[l]!=ch[r])
		{
			count++;
			ch[l]=ch[r];
		}
		l++;
		r--;
	}
	cout<<count<<endl;
}

Measured memory_bytes: 256
N=int(input())
s=len(str(N))

ans=0
import itertools
b1=list(itertools.product("0357", repeat=s))
for k in b1:
    t=int(''.join(k))
    if N<t:break
    x=set(str(t))
    y=x-{'3','5','7'}
    if len(y)==0 and len(x-y)==3:
        ans+=1
print(ans)

Measured memory_bytes: 40336
#include "bits/stdc++.h"
 
#define int long long
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define sqr(x) ((x) * (x))

using namespace std;

int32_t main() {
    ios_base::sync_with_stdio(0);
    int n, c;
    cin >> n >> c;
    vector<int> x(n);
    forn (i, n) {
        cin >> x[i];
    }
    vector<pair<int, int>> st;
    vector<int> dp(n);
    dp[0] = 0;
    st.push_back({x[0], 0});
    for (int i = 1; i < n; i++) {
        int j = st[upper_bound(st.begin(), st.end(), make_pair(x[i], (int)(2e9))) - st.begin() - 1].second;
        dp[i] = dp[j] + sqr(x[i] - x[j]) + c;
        //cerr << x[i]     << " " << x[j] << " " << dp[i] << endl;
        while (st.size() && dp[st.back().second] + sqr(st.back().first - x[st.back().second]) >= dp[i] + sqr(st.back().first - x[i])) {
            st.pop_back();
        }
        if (st.size() == 0) {
            st.push_back({x[i], i});
        } else {
            j = st.back().second;
            int inter = (dp[i] - dp[j] + sqr(x[i]) - sqr(x[j]) + 2 * x[i] - 2 * x[j] - 1) / (2 * x[i] - 2 * x[j]);
            st.push_back({inter, i});
        }
        /*for (auto asdf: st) {
            cerr << asdf.first << " " << x[asdf.second] << endl;
        }*/
    }
    cout << dp[n - 1] << endl;
}


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

	int n;
	cin>>n;
	int a[10000];
	for(int i=0;i<n;i++) cin>>a[i];
	
	int mn = a[0], mx = a[0];
	long long sum = 0;
	for(int i=0;i<n;i++){
		mn = min(mn, a[i]);
		mx = max(mx, a[i]);
		sum += a[i];
	}

	cout<<mn<<" "<<mx<<" "<<sum<<endl;
	
	return 0;
}


Measured memory_bytes: 3116
/**
  * @brief atcoder
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

#define N 32
#define M 1024
#define Q 65536

char ans[Q][32];
int nans;

int one, zero, ebp, esp;

void pri(char ins, int c, int a, int b)
{
    sprintf(ans[nans++],"%c %d %d %d", ins, a, b, c);
}

void lt(int c, int a, int b)
{
    pri('<',c,a,b);
}

void add(int c, int a, int b)
{
    pri('+',c,a,b);
}

void set(int b, int a)
{
    add(b,zero,a);
}

void reset(int a)
{
    set(a,zero);
}

void leak(int res, int tar)
{
    int back_ebp = ebp;
    ebp = esp, esp -= 3;
    int base = esp+0, tao = esp+1, k=esp+2;
    reset(base);
    add(tao,tar,one);
    for(int i=N-1;i>=0;--i)
    {
        set(k,one);
        for(int j=0;j<i;++j) add(k,k,k);
        int t = res + i;
        add(k,base,k);
        lt(t,k,tao);
        set(k,t);
        for(int j=0;j<i;++j) add(k,k,k);
        add(base,base,k);
    }
    esp = ebp, ebp = back_ebp;
}

void and_op(int c, int a, int b)
{
    int back_ebp = ebp;
    ebp = esp, esp -= 1;
    int k = esp;
    add(k,a,b);
    lt(c,one,k);
    esp = ebp, ebp = back_ebp;
}

void mul(int res, int a, int b)
{
    int back_ebp = ebp;
    ebp = esp, esp -= N*2+1;
    int la = esp, lb = esp+N, t=esp+N*2;
    reset(res);
    leak(la,a);
    leak(lb,b);
    for(int i=0;i<N;++i)for(int j=0;j<N;++j)
    {
        and_op(t,la+i,lb+j);
        for(int k=0;k<i+j;++k) add(t,t,t);
        add(res,res,t);
    }
    esp = ebp, ebp = back_ebp;
}

int main()
{
    ebp = M, esp = ebp-2;
    one = esp, zero = esp+1;
    add(one,0,1);
    lt(one,zero,one);
    mul(2,0,1);
    printf("%d\n", nans);
    for(int i=0;i<nans;++i) puts(ans[i]);
    return 0;
}


Measured memory_bytes: 2720
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

int main()
{
  ll K, A, B; cin >> K >> A >> B;
  rep(i, A, B + 1) {
  	if (i % K == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  
}

Measured memory_bytes: 3568
import java.io.*;
class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		String[] str = buf.readLine().split(" ");
		String[] str1;
		int[] num = new int[6];
		int q;
		int top,front;
		int[] right;

		q = Integer.parseInt(buf.readLine());
		right = new int[q];
		for(int i=0; i<6; i++){
			num[i] = Integer.parseInt(str[i]);	
		}
		Saikoro sk = new Saikoro(num);
		for(int i=0; i<q; i++){
			str1 = buf.readLine().split(" ");
			top = Integer.parseInt(str1[0]);
			front = Integer.parseInt(str1[1]);		
			right[i] = sk.search_rigth(top,front);
		}
		for(int i=0; i<right.length; i++){
			System.out.println(right[i]);
		}

	}
}
class Saikoro{
	int[] num = new int[6];
	//?????????????????????
	//new???????????´????????????????????????????????????????????????????????????
	public Saikoro(int[] num){
		this.num[0] = num[0];
		this.num[1] = num[1];
		this.num[2] = num[2];
		this.num[3] = num[3]; 
		this.num[4] = num[4];
		this.num[5] = num[5];  
	}
	public int search_rigth(int top, int front){
		if(top == num[0]){
			if( front == num[1]) return num[2];
			if( front == num[2]) return num[4];
			if( front == num[3]) return num[1];
			if( front == num[4]) return num[3];
		}
		if(top == num[1]){
			if( front == num[0]) return num[3];
			if( front == num[2]) return num[0];
			if( front == num[3]) return num[5];
			if( front == num[5]) return num[2];
		}
		if(top == num[2]){
			if( front == num[0]) return num[1];
			if( front == num[1]) return num[5];
			if( front == num[4]) return num[0];
			if( front == num[5]) return num[4];
		}
		if(top == num[3]){
			if( front == num[0]) return num[4];
			if( front == num[1]) return num[0];
			if( front == num[4]) return num[5];
			if( front == num[5]) return num[1];
		}
		if(top == num[4]){
			if( front == num[0]) return num[2];
			if( front == num[2]) return num[5];
			if( front == num[3]) return num[0];
			if( front == num[5]) return num[3];
		}
		if(top == num[5]){
			if( front == num[1]) return num[3];
			if( front == num[2]) return num[1];
			if( front == num[3]) return num[4];
			if( front == num[4]) return num[2];
		}
		return 0;
	}

}

Measured memory_bytes: 24244
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import random

MAX = 10**9 + 7

def pow_mod_p(n, k, p):
  x = 1
  while k > 0:
    if k % 2 == 1:
      x *= n
      x %= p
    n **= 2
    n %= p
    k >>= 1
  return x

def comb_mod_p(n, k, p):
  x = 1
  for ik in range(k):
    x *= ((n-ik) * pow_mod_p(ik+1, p-2, p))
    x %= p
  return x

def main():
  n, k = map(int, input().strip().split())
  As = list(map(int, input().strip().split()))
  As.sort()
  min = 0
  max = 0
  x = comb_mod_p(n-1, k-1, MAX)
  for i in range(n-k+1):
    min += As[i]      * int(x)
    min %= MAX
    max += As[-(i+1)] * int(x)
    max %= MAX
    x *= (pow_mod_p(n-(i+1), MAX-2, MAX) * (n-(i+1)-(k-1)))
    x %= MAX
  print((max - min) % (MAX))

if __name__=='__main__':
  main()


Measured memory_bytes: 15692
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <tuple>
#include <array>

using namespace std;

constexpr long long mod = static_cast<long long>(1e9 + 7);

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

    long long path[10][10];

    for(int i = 0; i < 10; ++i){
        for(int j = 0; j < 10; ++j){
            cin >> path[i][j];
        }
    }

    vector<vector<int>> wall(H, vector<int>(W, 0));

    for(auto& vec: wall) {
        for(auto& val: vec){
            cin >> val;
        }
    }

    long long answers[10] = {};

    for(int i = 0; i < 10; ++i) {
        auto comp = [](auto x, auto y){return std::get<0>(x) > std::get<0>(y);};
        long long costs[10];
        fill(costs, costs + 10, -1);
        priority_queue<tuple<long long, int>, vector<tuple<long long, int>>, decltype(comp)> pque(comp);
        pque.push(make_tuple(0, i));

        while(!pque.empty()) {
            auto state = pque.top();
            pque.pop();
            auto cost = std::get<0>(state);
            auto pos = std::get<1>(state);

            costs[pos] = cost;
            if(pos == 1) break;
            for(int j = 0; j < 10; ++j) {
                if(costs[j] < 0 || cost + path[pos][j] < costs[j]) {
                    pque.push(make_tuple(cost + path[pos][j], j));
                }
            }
        }
        answers[i] = costs[1];
    }

    long long ans = 0;
    for(auto& vec: wall){
        for(auto val: vec) {
            if(val >= 0) ans += answers[val];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

string s;
int c;

int getInt() {
	int n = 0;
	while(s[c] != ']') {
		n = 10 * n + (s[c] - '0');
		c++;
	}
	c++;
	return n / 2 + 1;
}

int calc() {
	c++;
	if('0' <= s[c] && s[c] <= '9') {
		return getInt();
	}

	vector<int> v;
	while(s[c] != ']') {
		if(s[c] == '[') {
			v.push_back(calc());
		}
	}
	c++;
	sort(v.begin(), v.begin() + v.size());
	int sum = 0;
	for (int i = 0; i < v.size() / 2 + 1; i++) {
		sum += v[i];
	}
	return sum;
}



int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		c = 0;
		cin >> s;
		cout << calc() << endl;
	}
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> t(n);
  for (int i = 0; i < n; ++i) {
    cin >> s[i] >> t[i];
  }
  string x;
  cin >> x;
  int k = find(begin(s), end(s), x) - begin(s);
  int res = accumulate(begin(t) + k + 1, end(t), 0);
  cout << res << '\n';
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<long long>::max();
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, s, t, q, ans, sum, last, cnt, a[100];
struct Edge { LL to,cost; };
vector<Edge>vec[100];
string str;
bool f=0;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
LL dfs(LL v, LL p, bitset<8>bi = {}) {
	LL ss = 0;
	bool f = 0;
	bi[v-1] = 1;
	if (bi.count() == n)return 1;
	rep(i, vec[v].size()) {
		if (vec[v][i].to != p&&bi[vec[v][i].to-1]==0) {
			
			ss += dfs(vec[v][i].to, v, bi);
			f = 1;
		}
	}
	if (f == 0)return 0;
	return ss;
}
int main() {
	cin >> n >> m;
	rep(i, m) {
		LL x, y;
		cin >> x >> y;
		vec[x].push_back(Edge{ y,1 });
		vec[y].push_back(Edge{ x,1 });
	}
	cout << dfs(1,-1) << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <cstring>
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
    ll N, a;
    int i;

    cin >> N;

    vector <int> A(N, 0);

    for(i=0; i<N-1; i++) {
        cin >> a;
        A[a-1]++;
    }

    for(i=0; i<N; i++) {
        cout << A[i] << endl;
    }

}

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

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

int p[101];

int N;

void push_p(int n){
    int d = 2;
    while(n>1){
        while(n%d==0){
            p[d]++;
            n /= d;
        }
        d++;
    }
}

set<string> result;

void rec(vector<int> &v, int idx, map<int,bool> &used, set<string> res){
    if(idx == -1) {
        string s;
        for(auto r: res){
            s += r;
        }
        result.insert(s);
        return;
    }

    rep1(i,N){
        if(v[idx] <= p[i] && !used[i]) {
            used[i] = true;
            res.insert(to_string(i)+"^"+to_string(v[idx])+",");
            rec(v,idx-1,used,res);
            res.erase(to_string(i)+"^"+to_string(v[idx])+",");
            used[i] = false;
        }
    }
}

void calc(vector<int> v){
    int m = v.size();
    map<int,bool> used;
    set<string> res;
    rec(v, m-1, used, res);
}

int main(void){
    cin>>N;
    rep1(i,N) {
        push_p(i);
    }
    calc({2,4,4});
    calc({2,24});
    calc({4,14});
    calc({74});
    cout << result.size() << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int D = sc.nextInt();
        String s = "Christmas";
        for (int i = 0; i < 25 - D; i++) {
            s += " Eve";
        }
        System.out.println(s);
        sc.close();
    }
}

Measured memory_bytes: 21204
num = list(input())
ans = 7
for i in range(2 ** len(num)):
    total = 0
    ans_num = []
    ans_op = []
    for j in range(len(num)):
        if((i >> j) & 1):
            ans_num.append(num[j])
            if(j >= 1):
                ans_op.append('+')
            total += int(num[j])
        else:
            ans_num.append(num[j])
            if (j >= 1):
                ans_op.append('-')
            total -= int(num[j])
    if(total == ans):
        print(ans_num[0]+ans_op[0]+ans_num[1]+ans_op[1]+ans_num[2]+ans_op[2]+ans_num[3]+'=7')
        break

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include <tuple>
#include <utility>
#include<string>
#include <cmath>
#include <queue>
#define ll long long
using namespace std;

using Graph = vector <vector <int> >;

int main() {
    int ans =0;
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N+10);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // BFS のためのデータ構造
    vector<int> dist(N+10, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[1] = 0;
    que.push(1); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について前の頂点情報を更新してキューに追加する
            dist[nv] = v;
            que.push(nv);
        }
    }

    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    for (int v = 2; v <= N; ++v){
        if(dist[v] == -1) ans = -1;
    }
    if(ans == -1){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
        for (int v = 2; v <= N; ++v){
            cout << dist[v] << endl;
        } 
    }
}


Measured memory_bytes: 10272
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 5000000000000000
#define endl '\n'
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; }
using namespace std;

//power_mod
inline int Pow_mod(int x, int pow){
    if(pow==0) return 1;
    int a=Pow_mod(x, pow/2);
    a=a*a%mod;
    if(pow%2==1) a*=x;
    return a%mod;
}

//factorial_mod
int fact[200010];
inline int factorial_mod(int x){
    if(x==0)return 1;
    if(fact[x]!=0)return fact[x];
    return fact[x]=(x*factorial_mod(x-1))%mod;
}

//combination_mod
inline int nCr_mod(int n, int r){
    return factorial_mod(n)*Pow_mod(factorial_mod(r)*factorial_mod(n-r)%mod, mod-2)%mod;
}

//factorial_mod
inline int factorial_mods(int x){
    int res=1;
    for(int i=1; i<=x; i++){
        res=(res*i)%mod;
    }
    return res;
}

signed main(){
    int H,W,A,B; cin>>H>>W>>A>>B;
    vector<int> vec(W-B,0);
    for(int i=B+1; i<=W; i++){
        vec.at(i-B-1)=nCr_mod(H-A+i-2, H-A-1);
    }
    int ans=0;
    rep(i,vec.size()){
        int tmp=nCr_mod(A+W-B-i-2, A-1);
        ans=(ans+(vec.at(i)*tmp)%mod)%mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4352
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

su = 0
chokuzen = -5
for i in range(N):
  su += B[A[i] - 1]
  if A[i] == chokuzen + 1:
    su += C[A[i] - 2]
  chokuzen = A[i]
print(su)

Measured memory_bytes: 3064
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** 処理する年数 */
	private static final int N = 10;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int r = scanner.nextInt(), d = scanner.nextInt(), x = scanner.nextInt();
			IntStream.range(0, N).reduce(x, (first, second) -> {
				int newX = r * first - d;
				System.out.println(newX);
				return newX;
			});
		}
	}
}


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

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

	vector<string> sv;
	for(int i=0;i<a;i++){
		string s;
		cin>>s;
		sv.push_back(s);
	}

	for(int i=0;i<b+2;i++){
		cout<<"#";
	}
	cout<<endl;

	for(int i=0;i<a;i++){
		cout<<"#"<<sv[i]<<"#"<<endl;
	}

	for(int i=0;i<b+2;i++){
		cout<<"#";
	}
	cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define MAXN 52
#define MOD 1000000007
#define sz(a) static_cast<long long>(a.size())
#define INF 2000000000000000000
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pp;
int n,a[MAXN],dp[MAXN][MAXN*MAXN],ans=0,val;
main(){
	//ios::sync_with_stdio(false); cin.tie(0);
	//freopen("inp.txt","r",stdin); //freopen("out.txt","w",stdout);
	//freopen(".INP","r",stdin); freopen(".OUT","w",stdout);
	cin>>n>>val; int i,j,k;
	for (i=1;i<=n;i++) cin>>a[i];
	for (i=0;i<MAXN;i++){
		for (j=0;j<MAXN*MAXN;j++) dp[i][j]=0;
	}
	dp[0][0]=1;
	for (i=1;i<=n;i++){
		for (j=i-1;j>=0;j--){
			for (k=2500;k>=0;k--){
				if (k >= a[i] && dp[j][k-a[i]]>0)
					dp[j+1][k]+=dp[j][k-a[i]];
			}
		}
	}
	for (i=1;i<=n;i++) ans+=dp[i][val*i];
	cout<<ans;
}

Measured memory_bytes: 1280
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
#define MAX 120


int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(b-a==c-b) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
    const int N = 1e5+5;
    int n, a[N][5];
    long long dp [5][N], f, s;
int main()
{
    cin >> n ;
    for (int i=0; i<n; i++){
        for (int j=0;j <3; j++) cin >> a[i][j];
    }
    dp[0][n-1]= a[n-1][0],dp[1][n-1]= a[n-1][1], dp[2][n-1]= a[n-1][2];
    for (int i=n-2; i>=0; i--){
        for (int j=0; j<3; j++){
            if (j==0) {
                f= dp[1][i+1], s= dp[2][i+1];
            }
            if (j==1) {
                f= dp[0][i+1], s= dp[2][i+1];
            }
            if (j==2) {
                f= dp[1][i+1], s= dp[0][i+1];
            }
            dp[j][i]= max(s, f);
            dp[j][i]+= a[i][j];
        }
    }
    long long x = dp[0][0], y =dp[1][0], z=dp[2][0];
    long long ans = max (x, y);
    ans = max (ans , z);
    cout << ans;
    return 0;
}


Measured memory_bytes: 6144
##a = int(stdin.readline().rstrip())
##b, c = [int(x) for x in stdin.readline().rstrip().split()]
##s = stdin.readline().rstrip()
##a = list(set(b))  重複を削除
##a = list(map(int,[int(x) for x in stdin.readline().rstrip().split()])) a[0, 1, 2, ...]
##a = [[0] * 2 for _ in range(n)]  a[0,0]
##v = [s[i: i+2] for i in range(0, len(s), 2)]
##  s="12345678" を v=["12","34","56","78"] にするイメージ
##s = "".join(list)リストを文字列に変換[""]は区切り文字
##a.sort(key=itemgetter(1))リストをソートできるよ(from operator import itemgetterが必要)
##sort_p = sorted(p) 昇順ソート

# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
import numpy as np
import random
import bisect
import copy
# stdin = open("sample.txt")


MOD = 1000000007
INF = float('inf')
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

def keta(kazu): # 入力されたintを桁ごとに分解，リストで出力
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers): # 最小公倍数
    return reduce(math.gcd, numbers)

def combination(m,n): # mCn
    
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def pow_k(x,n):  # (x**n)の計算の高速化
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
    return K * x

def fact(n): # nの素因数分解の結果を辞書で出力 fuct(24) → {2: 3, 3: 1}
    arr = {}
    temp = n
    for i in range(2,int(n**0.5)+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt
    if temp != 1:
        arr[temp] = 1
    if arr == {}:
        arr[n] = 1
    return arr


    
def main():
    n = int(stdin.readline().rstrip())
    a = list(map(int,[int(x) for x in stdin.readline().rstrip().split()]))
    ans = 0
    for i in range(n):
        if (i+1) % 2 == 1 and a[i] % 2 == 1:
            ans += 1
    print(ans)
main()

Measured memory_bytes: 27248
#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f, MOD = 1000000007;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*-----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int a, b; cin >> a >> b;
  if (a + b >= 10) cout << "error\n";
  else cout << a + b << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    long long L[N+1];
    L[0] = 2;
    L[1] = 1;
    
    // L2 = L0 + L1; 
    // L3 = L1 + L2;
    if (N == 0) {
        cout << 2 << endl;
    }else if (N == 1){
        cout << 1 << endl;
    } else {
        for (int i = 2; i <= N; i++) {
            L[i] = L[i-1] + L[i-2];
        }
        cout << L[N] << endl;
    }
  
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<set>
#include<algorithm>
#include<iomanip>

using namespace std;

int main() {
    int L;
    cin >> L;
    cout << fixed << setprecision(15) << (double)L * L * L / 27 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int t = 0;
    double a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        t += a[i];
    }
    int c = 0;
    double cc = (double)t / (4 * (double)m);
    for (int i = 0; i < n; i++) {
        if (a[i] >= cc) {
            c++;
        }
    }
    if (c >= m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define int long long
using namespace std;

int p10[20];
int n;

signed main() {
	int i;
	
	cin >> n;
	p10[0] = 1;
	for (i = 1; i < 20; i++) p10[i] = p10[i - 1] * 10;
	for (i = 0; p10[i] <= n; i++);
	if ((n + 1) % p10[i - 1] != 0) cout << (i - 1) * 9 + (n / p10[i - 1] - 1) << endl;
	else cout << (i - 1) * 9 + (n / p10[i - 1]) << endl;
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int zeroCount = 0;
    int oneCount = 0;
    for (int i = 0; i <= n - 1; i++) {
        if (s[i] == '0') zeroCount++;
        else oneCount++;
    }
    cout << min(oneCount, zeroCount) * 2 << '\n';
    return 0;
}

Measured memory_bytes: 3784
import java.lang.reflect.Array;
import java.util.*;


public class Main {
    race[] raceArray = new race[8];
    race[] raceArrays = new race[6];
    
	void doIt(){
		String a, b;
		int p = 0;
		Scanner sc = new Scanner(System.in);
		for(int m = 0; m < 3; m++){
			for(int i = 0; i < 8; i++){
				a = sc.next();
				b = sc.next();
				raceArray[i] = new race(a,b);
			}
			Arrays.sort(raceArray);
			for(int k = 0; k < 2; k++){
				System.out.println(raceArray[k].number + " " + raceArray[k].time);
			}
			for(int l = 2; l < 4; l++){
				raceArrays[p] = raceArray[l];
				p = p + 1;
			}
		}
		Arrays.sort(raceArrays);
		for(int i = 0; i < 2; i++){
			System.out.println(raceArrays[i].number + " " + raceArrays[i].time);
		}
	}
	

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().doIt();
	}
	class race implements Comparable<race>{
		String number;
		String time;
		race(String racenum, String racetime){
			this.number = racenum;
			this.time = racetime;
		}
		@Override
		public int compareTo(race p){
			return time.compareTo(p.time);
		}

	}

}

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

int main() {
    int N; cin >> N;
    set<string> st;
    for(int i = 0; i < N; ++i) {
        string s; cin >> s;
        st.insert(s);
    }
    cout << st.size() << '\n';
    return 0;
}


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

int main() {
  string S, T;
  cin >> S >> T;
  
  if (T.size() != S.size() + 1) {
    cout << "No" << endl;
    return 0;
  }
  
  for (int i = 0; i < S.size(); i++) {
    if (S[i] != T[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;  
  return 0;
}

Measured memory_bytes: 3628
import java.util.*;
class Main {
    static int count = 0;
    static long N = 0;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        System.out.println(f("0"));
    }

    static int f(String S) {
        if(Long.parseLong(S) > N) return 0;
        else {
            if(S.contains("7")&&S.contains("5")&&S.contains("3")) count++;
            f(S + "7");
            f(S + "5");
            f(S + "3");
            return count;
        }
    }
}

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

int main() {
	int N; cin >> N;
	char s[110];
	for(int i=0; i<N; ++i) cin >> s[i];
	int p;
	for(p=0; p<N && s[p]!='Y'; ++p){}
	if(p<N) cout << "Four" << endl;
	else cout << "Three" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;

int N;
string s;
ll R, G, B;
int main(void){
    cin >> N;
    cin >> s;
    REP(i, s.length()){
        if(s[i] == 'R') R++;
        else if (s[i] == 'G') G++;
        else B++;
    }
    ll total = R*G*B;
    for(int d=1;d <= (s.length()-1)/2;d++){
        int i = 0;
        while(i+d*2 < s.length()){
            if(s[i] != s[i+d] and s[i] != s[i+2*d] and s[i+d] != s[i+2*d]) total--;
            i++;
        }
    }
    cout << total << endl;
    return 0;
}



Measured memory_bytes: 3636
import java.io.*;
    
class Main{
   
static final PrintWriter out=new PrintWriter(System.out);
static final int MOD=10007;
    
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] pic=new int[n];
line=br.readLine();
for(int i=0;i<n;i++) pic[i]=bit(line.charAt(i));
int[][] dp=new int[n][1<<3];
for(int i=0;i<1<<3;i++) if((i&(1<<0))!=0&&(i&pic[0])!=0) dp[0][i]=1;
for(int i=1;i<n;i++)
for(int j=1;j<(1<<3);j++)
for(int k=1;k<(1<<3);k++)
if((k&pic[i])!=0){
if((j&pic[i])!=0) dp[i][k]+=dp[i-1][j];
else if((j&k)!=0) dp[i][k]+=dp[i-1][j];
dp[i][k]%=MOD;
}
int ans=0;
for(int i=1;i<1<<3;i++) ans+=dp[n-1][i];
out.println(ans%MOD);
out.flush();
}
}
  
public static int bit(char c){
if(c=='J') return 1<<0;
else if(c=='O') return 1<<1;
else return 1<<2;
}
}

Measured memory_bytes: 18600
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
#define int long long
int par[200020];
int siz[200020];
int ans[200020];
int a[100010], b[100010];
int root(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = root(par[x]);
	}
}
signed main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		par[i] = i;
		siz[i] = 1;
	}
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
	}
	ans[m] = (n - 1) * n / 2;
	for (int i = m - 1; i > 0; i--) {
		int x, y;
		x = root(a[i]);
		y = root(b[i]);
		int co = siz[x] * (siz[x] - 1) / 2 + siz[y] * (siz[y] - 1) / 2;
		if (x != y) {
			par[y] = x;
			siz[x] += siz[y];
			siz[y] = siz[x];
			ans[i] = ans[i + 1] - siz[x] * (siz[x] - 1) / 2 + co;
		}
		else {
			ans[i] = ans[i + 1];
		}
	}
	for (int i = 1; i <= m; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 7520
from fractions import gcd
from math import sqrt, ceil

A, B = map(int, input().split())
gcd_ = gcd(A, B)

count = 1
for i in range(2, ceil(sqrt(gcd_)) + 1):
    if gcd_ % i == 0:
        count += 1
        while gcd_ % i == 0:
            gcd_ /= i

if gcd_ != 1:
    count += 1

print(count)


Measured memory_bytes: 5432
program sample
    implicit none
    character(100)::s,t
    integer(8) :: i,j,k,m,n
    integer(8)::a,b,c,d
    integer(8),allocatable::x(:),y(:)
  
    read(*,*) n
    allocate(x(n))
    do i=1,n
    read(*,*)x(i)
    end do
    a=x(1)
    m=a
    do i=2,n
        b=max(a,x(i))
        a=min(a,x(i))
        do j=1,1000000000
            if(mod(b,a)==0)then
                exit
            else
                c=mod(b,a)
                b=a
                a=c
            end if
        end do
        m=m*(x(i)/a)
        a=m
    end do

    write(*,*)m
    stop
end program sample
  



Measured memory_bytes: 2828
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/


int main(){
int N;
ld K;
cin>>N>>K;
ll ans=0;
ans+=max((ll)0,N-(ll)K+1);
K-=1e-9;
int memo[20];
ld ans2=0;

rep(i,20){
    int Ki=K;
    memo[i]=min(Ki,N);
    K/=2;


}
rep(i,19){
    memo[i]=memo[i]-memo[i+1];
}
int count=0;
bool swit=false;
if(memo[0]==0)swit=true;
rep(i,20){
    if(memo[i]!=0)swit=false;
    if((!swit)&&(memo[i]==0)){
        count=i;
        break;
    }
}
rep(i,count){
    ans2+=memo[i]*(ll)powl(2,count-1-i);
}

ans*=(ll)powl(2,count);
cout(10)<<(ans2+ans)/(powl(2,count)*N)<<endl;
return 0;
}

Measured memory_bytes: 3852
N=int(input())

A=list(map(int,input().split()))

mod=10**9+7
summy=[]
a=0
for i in range(N):
    a += A[i]
    a %= mod
    summy.append(a)

ans=0
for i in range(N-1):
    ans += summy[N-2-i]*A[N-1-i]
    ans %= mod
print(ans)

Measured memory_bytes: 107076
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,m,type[13][600005],pw[13],res[600005];
char t[200005];
bool flag;
void debug()
{
	printf("flag=%d\n",flag);
	for(int i=0;i<n;i++)
	{
		printf("%d:",i);
		for(int j=0;j<pw[i];j++)printf("%d ",type[i][j]);
		printf("\n");
	}
}
int main()
{
	scanf("%d",&n);
	pw[0]=1;
	for(int i=1;i<=n;i++)pw[i]=pw[i-1]*3;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<pw[i];j++)
		  type[i][j]=0;
	}
	scanf("%s",t+1);
	m=(int)strlen(t+1);
	for(int i=1;i<=m;i++)
	{
		if(t[i]=='S')
		{
			flag^=1;
			continue;
		}
		int now=0;
		for(int b=0;b<n;b++)
		{
			if(flag==0)
			{
				int v=now+pw[b]*((type[b][now]+2)%3);
				type[b][now]=(type[b][now]+2)%3;
				now=v;
			}
			else
			{
				int v=now+pw[b]*((type[b][now]+1)%3);
				type[b][now]=(type[b][now]+1)%3;
				now=v;
			}
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<pw[n];j++)
		{
			int b=(j/pw[i])%3-type[i][j%pw[i]]+3;
			b%=3;
			if(flag)b=(3-b)%3;
			res[j]+=b*pw[i];
		}
	}
	for(int i=0;i<pw[n];i++)printf("%d ",res[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 7216
N, M = map(int, input().split())
A = [None]*M
for i in range(M):
    A[i] = int(input())
A = [-1] + A + [N+1]

def fibonacci(n):
    if n == 1 or n == 2:
        return 1
    else:
        a, b = 1, 1
        for _ in range(n-2):
            a, b = b, a + b
        return b

ans = 1
for i in range(M+1):
    dansuu = (A[i+1]-1)-(A[i]+1)
    if dansuu == -1:
        ans *= 0
        break
    else:
        ans *= fibonacci(dansuu + 1)

print(ans%1000000007)

Measured memory_bytes: 48984
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,i,a[5];
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	while(n)a[++i]=n%10,n/=10;
	for(i=1;i<=2;i++)if(a[i]==a[i+1] && a[i+1]==a[i+2] && a[i]==a[i+2])rc("Yes");
	rc("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(auto it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
void solve()
{
  int n,m,k,i,j;
  cin>>n>>m>>k;
  string s[n];
  rep(i,0,n)cin>>s[i];
  int ans=0;
  for(i=0;i<1<<(n);i++)
  {
    for(j=0;j<1<<m;j++)
    {
      int cnt=0;
      for(int x=0;x<n;x++)
      {
        for(int y=0;y<m;y++)
        {
          if(s[x][y]=='#')
          {
            if((1&(i>>x))==0 && (1&(j>>y))==0)
              cnt++;
          }
        }
      }
      if(cnt==k)ans++;
    }
  }
  cout<<ans;
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  t=1;
  //cin>>t;
  while(t--)
  solve();
  TIME
  return 0;
}

Measured memory_bytes: 3840
s = str(input())

t = str(input())

n = len(s)
m = len(t)

c = m
for i in range(n-m+1):
    d = 0
    for j in range(m):
        if t[j] != s[i + j]:
            d += 1
    c = min(c,d)

print(c)


Measured memory_bytes: 9048
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define ALL(v) v.begin(),v.end()
string calc(string a,string b){
  reverse(ALL(a));
  reverse(ALL(b));
  while(a.size() < b.size())a += '0';
  while(b.size() < a.size())b += '0';
  int c=0;
  string res;
  for(int i=0;i<a.size();i++){
    c = c+a[i]-'0'+b[i]-'0';
    res += c%10+'0';
    c /= 10;
  }
  if(c)res += c+'0';
  if(res.size() > 80)return "overflow";
  reverse(ALL(res));
  return res;
}
int main(){
  int n;
  string a,b;
  cin>>n;
  while(n--){
    cin>>a>>b;
    cout<<calc(a,b)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3104
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
#include <algorithm>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
//#define cocount cout << count << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define Cinint(n) int n;\
cin >> n;
#define Cinvecint(a, n) vector<int> a(n);\
for (int i = 0; i < (int)(n); i++) {\
  int num;\
  cin >> num;\
  a.at(i) = num;\
}

  

int main() {
  Cinint(k);
  //cout << k << endl;
  //cout << __gcd(1,__gcd(1, 1)) << endl;
  int count = 0;
  rep1(i, k+1) {
    rep1(j, k+1) {
      rep1(l, k+1) {
        //cout << i << j << l << endl;
        int num = __gcd(i, __gcd(j, l));
        count += num;
        //cout << num << endl; 
      }
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
	int n;
	string s;
	cin>>n>>s;
	int ans=0;
	for(int i=0;i<=n-3;i++){
		if(s.substr(i,3)=="ABC") ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1]*n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]


import sys
sys.setrecursionlimit(10**7)

n,m=map(int, input().split())
uf=UnionFind(n)
for i in range(m):
    a,b=map(int, input().split())
    uf.union(a-1,b-1)

ans=0
for i in range(n):
    ans=max(ans, uf.size(i))
print(ans)


Measured memory_bytes: 14544
#include <bits/stdc++.h>
#define  ll  long long
#define  pii pair<ll,ll>
#define  pll pair<ll , ll>
#define  debug cout << "this far" << endl;
#define  For(i, n) for(int i = 0; i < (n); ++i)
#define  lsb(x) ((x) & (-x))
#define  PI acos(-1)
#define  line cout << endl;
#define  getbit(n, i) (((n) & (1LL << (i))) != 0)
#define  resetbit(n, i) ((n) & (~(1LL << (i))))
#define  setbit(n, i) ((n) | (1LL << (i)))
#define  togglebit(n, i) ((n) ^ (1LL << (i)))
#define  gap " "
#define printall(container) for(auto val  : container) cout << val << gap ; line ; 
using namespace std;
const int N = 2e5 + 10;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string s; cin >> s;
    if (s[0] == s[1] && s[1] == s[2] && s[0] == 'R') cout << "3";
    else if (s[0] == s[1] && s[0] == 'R') cout << "2";
    else if (s[1] == s[2] && s[1] == 'R') cout << "2";
    else if (s[1] == 'R' || s[2] == 'R' || s[0] == 'R') cout << "1";
    else cout << "0";
}

Measured memory_bytes: 3584
import           Control.Applicative ((<$>))
import qualified Data.Set            as S

main :: IO ()
main = do
    _ <- getLine
    s <- S.fromList . map read . words <$> getLine :: IO (S.Set Int)
    _ <- getLine
    t <- S.fromList . map read . words <$> getLine :: IO (S.Set Int)
    print $ S.size $ S.intersection s t

Measured memory_bytes: 6056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int k;
    cin>>k;
    int num=7;
    for(int i=1;i<=k;i++){
        if(num%k==0){
            cout<<i<<endl;
            return 0;
        }
        num*=10;
        num+=7;
        num%=k;
    }
    cout<<-1<<endl;
}

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

#define int             long long int
#define ff              first
#define ss              second
#define pb              push_back

#define vi              vector <int>
#define pii             pair <int, int>

#define loop(i,s,e)     for(int i=s;i<e;i++)
#define rloop(i,e,s)    for(int i=e;i>=s;i--)
#define mset(a,f)       memset(a,f,sizeof(a))

#define endl            "\n"
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl



template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;


void solve()
{
	int n; cin >> n;
	int a[n];
	loop(i, 0, n) cin >> a[i];

	int ans = 0, x, y, z;
	loop(i, 0, n)
	{
		x = a[i];
		loop(j, i + 1, n)
		{
			y = a[j];
			loop(k, j + 1, n)
			{
				z = a[k];
				set<int>s;
				s.insert(x);
				s.insert(y);
				s.insert(z);
				int sz = s.size();
				if (sz == 3)
				{
					if (x + y > z and y + z > x and z + x > y)
					{
						ans++;
					}
				}
			}
		}
	}
	cout << ans << endl;

}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt",  "r",  stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t = 1;
	//cin >> t;
	while (t--) solve();

	return 0;
}

Measured memory_bytes: 3660
scores = [[0] * 51 for i in range(1001)]

while(1):
    try:
        n,m = (int(x) for x in input().split())
        if n == 0:break
        for i in range(0,m):
            scores[i] = list(int(x) for x in input().split())
            
        maxSum = 0
        for i in range(0,n):
            sum = 0
            for j in range(0,m):
                sum += scores[j][i]
            maxSum = max(maxSum,sum)
        print(maxSum)
    except:
        break


Measured memory_bytes: 8164