akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int H, W, D;
int A[301][301];
const int MAX_N = (int)1e5;
int L[MAX_N], R[MAX_N];
vector<P> rev;	// 逆引き num -> pos
int main()
{
	memset(A, 0, sizeof(A));
	memset(L, 0, sizeof(L));
	memset(R, 0, sizeof(R));
	rev.clear();
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> H >> W >> D;
	rev.resize(H * W + 1);
	for (int i = 1; i <= H; ++i){
		for (int j = 1; j <= W; ++j){
			cin >> A[i][j];
			rev[A[i][j]] = P(i,j);
		} // end rep
	} // end rep
	vector<int> cum_sum(H * W + 1, 0);
	for (int i = 1; i <= H * W - D; ++i){
		int crow = rev[i].first;
		int ccol = rev[i].second;
		int nrow = rev[i+D].first;
		int ncol = rev[i+D].second;
		int curr = abs(crow - nrow) + abs(ccol - ncol);
		cum_sum[i+D] = cum_sum[i] + curr;
	} // end for
/*
	for (int i = 1; i <= H * W; ++i){
		cerr << "cum_sum[" << i << "]: " << cum_sum[i] << endl;
	} // end for
*/
	int Q; cin >> Q;
	rep (i, Q){
		cin >> L[i] >> R[i];
		int res = 0;
		res = cum_sum[R[i]] - cum_sum[L[i]];
/*		
		for(int s = L[i]; s + D <= R[i]; s += D){
			int crow = rev[s].first;
			int ccol = rev[s].second;
			int nrow = rev[s + D].first;
			int ncol = rev[s + D].second;
			res += abs(crow - nrow) + abs(ccol - ncol);
		} // end for
*/
		cout << res << endl;
	} // end rep
	
	return 0;
}

Measured memory_bytes: 3328
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double lb; 

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


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

    int ans[26];
    rep(i,26){
        ans[i] = 0;
    }

    for(ll i=0;i<S.size();i++){
        int num = S[i] - 'a';
        if(ans[num] == 1){
            cout << "no" << endl;
            return 0;
        }else{
            ans[num] = 1;
        }
    }

    cout << "yes" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int a=0,b=0,c=0;
    string s;
    cin>>s;
    rep(i,s.length()){
        if(s[i]=='a')a++;
        if(s[i]=='b')b++;
        if(s[i]=='c')c++;
    }
    int minv=min(a,min(b,c));
    a-=minv;
    b-=minv;
    c-=minv;
    YN(a<=1&&b<=1&&c<=1);
}

Measured memory_bytes: 3720
N, K, Q = map(int, input().split())

import numpy as np
P = np.ones(N)*K

for q in range(Q):
    P[int(input())-1] += 1

P[:]-=Q

for k in range(N):
    if P[k] > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 20496
from collections import deque

import sys
input = sys.stdin.readline

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

H, W = map(int, input().split())
A = [input() for _ in range(H)]
dist = [-1 for _ in range(H * W)]

queue = deque()

for x in range(H):
    for y in range(W):
        if A[x][y] == '#':
            z = x * W + y
            queue.append(z)
            dist[z] = 0

while queue:
    z = queue.popleft()
    x, y = divmod(z, W)
    for k in range(4):
        nx = x + dx[k]
        ny = y + dy[k]
        if not (0 <= nx < H and 0 <= ny < W):
            continue
        nz = nx * W + ny
        if dist[nz] != -1:
            continue
        dist[nz] = dist[z] + 1
        queue.append(nz)

print(max(dist))

Measured memory_bytes: 110828
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

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

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

int main()
{
	int x, y, z;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y;
}


Measured memory_bytes: 31488
open System

[<EntryPoint>]
let main argv =
  let a = Console.ReadLine() |> int in
  let b = Console.ReadLine() |> int in
  let c = Console.ReadLine() |> int in
  let x = Console.ReadLine() |> int in
  
  [ for i in [0..a] do
      for j in [0..b] do
        for k in [0..c] do
          yield i * 500 + j * 100 + k * 50 ]
  |> List.sumBy (fun y -> if y = x then 1 else 0)
  |> Console.WriteLine
  0


Measured memory_bytes: 21324
#include<bits/stdc++.h>  
using namespace std;
typedef pair< int, int > Pi;

struct edge{
  int to, cost;
};
typedef vector< vector< edge > > Graph;
const int INF = 1 << 30;

int main(){
  int N, M, K;
  cin >> N >> M >> K;
  Graph graph(N);
  for(int i = 0; i < M; i++){
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    graph[a].push_back((edge){ b, c});
    graph[b].push_back((edge){ a, c});
  }
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  vector< int> min_cost( N, INF);
  for(int i = 0; i < K; i++){
    int a;
    cin >> a;
    --a;
    que.push(make_pair( 0, a));
    min_cost[a] = 0;
  }
  while(!que.empty()){
    Pi p = que.top(); que.pop();
    if(min_cost[p.second] < p.first) continue;
    for(int i = 0; i < graph[p.second].size(); i++){
      edge& e = graph[p.second][i];
      if(min_cost[e.to] <= p.first + e.cost) continue;
      min_cost[e.to] = p.first + e.cost;
      que.push( make_pair( p.first + e.cost, e.to));
    }
  }
  
  int ret = 0;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < graph[i].size(); j++){
      edge& e = graph[i][j];
      if(min_cost[i] <= min_cost[e.to]){
        // この辺の真ん中あたりに最大値がありそう
        double sa = min_cost[e.to] - min_cost[i];
        ret = max( ret, (int)(min_cost[i] + sa + (e.cost - sa) / 2.0 + 0.5));
      }
    }
    ret = max( ret, min_cost[i]);
  }
  cout << ret << endl;
}

Measured memory_bytes: 4192
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0;i<n;i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);

        int k = 0;
        int Alice = 0;
        int Bob = 0;
        while(k < n){
            if(k%2==0){
                Alice += a[n - 1 - k];
            }else{
                Bob += a[n - 1 - k];
            }
            k++;
        }
        System.out.println(Alice - Bob);
        sc.close();
    }
}

Measured memory_bytes: 21076
#include <iostream>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;

// 入力
int N;
long long W, weight[110], value[110]; // 品物の個数は 100 個なので少し余裕持たせてサイズ 110 に

// DPテーブル
long long dp[110][100100] = {0};

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];

    // DPループ
    for (int i = 0; i < N; ++i) {
        for (int sum_w = 0; sum_w <= W; ++sum_w) {

            // i 番目の品物を選ぶ場合
            if (sum_w - weight[i] >= 0) {
                chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
            }

            // i 番目の品物を選ばない場合
            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }

    // 最適値の出力
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 81736
#include<stdio.h>

int main(void){
    int n,k;
    scanf("%d %d",&n,&k);
    int a[n];
    int i,j;
    for(i = 0; i <= n - 1 ; i++){
        scanf("%d",&a[i]);
    }
    int b = 0;

    for(j = k + 1,b; j <= n; j++){

        if(a[b] < a[j - 1]){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
        b++;
    }
    return 0;
}

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

#define int long long
#define rep(i,a,n) for(int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort((c).begin(), (c).end(), greater<int>());
#define fi first
#define se second
  
typedef pair<int,int> P;
typedef vector<int> vi;

int N,M;
vector<P> c;

signed main() {
    cin>>N>>M;
    rep(i,0,M) {
        int A,B; cin>>A>>B;
        c.pb(P(A,B));
    }

    sort(c.begin(),c.end());
    int left=c[0].fi,right=c[0].se,ctn=1;
    rep(i,1,M) {
        int x1=c[i].fi;
        int x2=c[i].se;

        
        if(x1<right and x2>=right) {
            left=x1;
        }else if(x2<right) {
            left=x1;
            right=x2;
        }else if(x1>=right) {
            left=x1;
            right=x2;
            ctn++;
        }
    }
    cout<<ctn<<endl;
    return 0;
}




    


Measured memory_bytes: 2420
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int payment = sc.nextInt();
        int yen = 1000;
        while(yen<payment){
            yen = yen + 1000;
        }
        System.out.println(yen - payment);
    }
}

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

int main() {
  int N,M;
  cin >> N;
  int k=0;
  
  vector<string> s(N),t(M);
  
  for(int i=0;i<N;i++)
    cin >> s.at(i);
  
  cin >> M;
  
  for(int i=0;i<M;i++)
    cin >> t.at(i);
  
  for(int i=0;i<N;i++){
    string str = s.at(i);
      int l=0;
    for(int j=0;j<N;j++){
      if(s.at(j) == str)
        l++;
    }
    for(int j=0;j<M;j++){
      if(t.at(j) == str)
        l--;
    }
    k = max(k,l);
  }
  cout << k << endl;
}


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

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

using namespace std;
using P = pair<int,int>;


void init(int*,int*,int);
int find(int*,int);
bool same(int*,int,int);
void unite(int*,int*,int,int);

int main()
{
    int N,K,L,*lp,*lrank,*tp,*trank;
    cin>>N>>K>>L;
    lp = new int[N];
    lrank = new int[N];
    tp = new int[N];
    trank = new int[N];
    init(lp,lrank,N);
    init(tp,trank,N);

    rep(i,K){
        int p,q;
        cin>>p>>q;
        unite(lp,lrank,p-1,q-1);
    }
    rep(i,L){
        int r,s;
        cin>>r>>s;
        unite(tp,trank,r-1,s-1);
    }

    map<P,int> m;
    rep(x,N){
        m[make_pair(find(lp,x),find(tp,x))]++;
    }

    rep(x,N){
        cout << m[make_pair(find(lp,x),find(tp,x))] << " ";
    }
    cout << endl;

    return 0;
}




void init(int *par, int *rank, int n)
{
    for(int i=0;i<n;i++){
        par[i]=i;
        rank[i]=0;
    }
}

int find(int *par, int x)
{
    if(par[x]==x){
        return x;
    }else{
        return find(par,par[x]);
    }
}

bool same(int *par, int x,int y)
{
    return find(par,x)==find(par,y);
}

void unite(int *par, int *rank, int x, int y)
{
    int par_x = find(par,x);
    int par_y = find(par,y);
    if(par_x==par_y){
        return;
    }else{
        if(rank[par_x]<rank[par_y]){
            par[par_x]=par_y;
        }else{
            par[par_y]=par_x;
            if(rank[par_x]==rank[par_y]){
                rank[par_x]++;
            }
        }
    }
}

Measured memory_bytes: 15104
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int[] lot_num = new int[w];
		int n = sc.nextInt();
		int a,b,swap;
		String str;

		for(int i=0; i<w; i++){
			lot_num[i] = i+1;
		}
		
		for(int i=0; i<n; i++){
			str = sc.next();
			String[] num = str.split(",");
 			a = Integer.parseInt(num[0]);
			b = Integer.parseInt(num[1]);
			swap = lot_num[a-1];
			lot_num[a-1] = lot_num[b-1];
			lot_num[b-1] = swap;
		}

		for(int i=0; i<w; i++){
			System.out.println(lot_num[i]);
		}
	}
}

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

#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<
#define int long long 
using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

int a[200000],b[200000],c[200000];

int dp[200000][3];

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i]>>b[i]>>c[i];
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	for(int i=1;i<n;i++){
		dp[i][0] = a[i] + max(dp[i-1][1],dp[i-1][2]);
		dp[i][1] = b[i] + max(dp[i-1][0],dp[i-1][2]);
		dp[i][2] = c[i] + max(dp[i-1][0],dp[i-1][1]);
	}
	cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
	return 0;
}

Measured memory_bytes: 8832
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<db> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 
typedef vector<pd> vpd; 

#define mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 
#define ft front() 
#define bk back()
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define lb lower_bound 
#define ub upper_bound 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MX  = 2e5+5; 
const int MOD = 1e9+7; // 998244353;
const ll  INF = 1e18; 
const ld  PI  = acos((ld)-1);

const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 

template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; 
}
template<class T> bool ckmax(T& a, const T& b) { 
	return a < b ? a = b, 1 : 0; 
} 

constexpr int pct(int x) { return __builtin_popcount(x); } // number of ones 
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) 
template<class T> T cdiv(T a, T b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 

int fstTrue(function<bool(int)> f, int lo, int hi) {
	hi++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true 
		int mid = (lo+hi)/2; 
		f(mid) ? hi = mid : lo = mid+1; 
	} 
	return lo;
}

template<class T> void remDup(vector<T>& v) { 
	sort(all(v)); v.erase(unique(all(v)),end(v)); 
}

// DEBUG
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << h; if (sizeof...(t)) cerr << ", ";
	DBG(t...); 
}
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)

// FILE I/O
void setIn(str S) { freopen(S.c_str(),"r",stdin); }
void setOut(str S) { freopen(S.c_str(),"w",stdout); }
void setIO(str S = "") {
	ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(S)) { setIn(S+".in"), setOut(S+".out"); } // for USACO
}

bool vis[MX];
vi adj[MX];

void bfs(int ind) {
    queue<int> todo; todo.push(ind);
    while(sz(todo)) {
        int u = todo.ft; todo.pop();
        vis[u] = 1;
        trav(x,adj[u]) if (!vis[x]) {
            todo.push(x);
        }
    }
}
	
int32_t main() { 
	
	setIO();

    int N,M; cin >> N >> M;

    F0R(i,M) {
        int u,v; cin >> u >> v; --u,--v;
        adj[u].pb(v); adj[v].pb(u);
    }

    int res = 0;
    F0R(i,N) if (!vis[i]) {
        res++; bfs(i);
    }

    cout << res-1 << "\n";

}	

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

long dp[100][100];

long nCr(int n, int r)
{
       if(n==r) return dp[n][r] = 1;
       if(r==0) return dp[n][r] = 1;
       if(r==1) return dp[n][r] = n;
       if(dp[n][r]) return dp[n][r];
       return dp[n][r] = nCr(n-1,r) + nCr(n-1,r-1);
}

int main () {
  int N, P, even = 0, odd = 0, a = 0;
  cin >> N >> P;
  int A[N];
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    A[i] % 2 ? odd++ : even++;
  }

  if(P == 1){
    for(int i = 1; i <= odd; i+=2){
      a += nCr(odd, i);
    }
  }else{
    for(int i = 0; i <= odd; i+=2){
      a += nCr(odd, i);
    }
  }
  long long ans = pow(2, even)*a;
  cout << ans << endl;

}


Measured memory_bytes: 384
#何もアルゴリズム感がないやつ。ただメソッド使うだけ。
n = int(input())
s = input()

#j=0は解なのは確定している。さらに大きくできるか、を調べる。
j = 1

for i in range(n):
    seq = s[i:i+j]
    while s[i+j:].find(seq) != -1:
        j += 1
        seq = s[i:i+j]

#ゆえに、－１すればいい。        
print(j-1)        

Measured memory_bytes: 3060
#include <bits/stdc++.h>
//#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<double,double> P;
const ll INF = 1e18;
const int MOD = 1000000007;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

int n;vector<string> ans;

void rec(string s, int v){
  if(s.length() == n){
    ans.push_back(s);return;
  }
  int l = 0;
  rep(i,10)if(v&(1<<i))l = i;
  rep(i,l+2){
    rec(s + (char)((int)'a'+i), v|(1<<i));
  }
}
signed main(){
  cin>>n;
  rec("a", 1);
  rep(i,ans.size())cout << ans[i] << endl;
}


Measured memory_bytes: 7796
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  int n,x;
  cin >> n >> x;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  ll p=0;
  int ans=1;
  rep(i,n){
    p+=l[i];
    if(p<=x) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

#define MOD (1000000007)
#define N_MAX (100000+10)

using namespace std;

typedef long long int Int;

int N,M;
bool visited[N_MAX];
vector<int> G[N_MAX];
vector<pair<int,int> > Edge;
vector<pair<int,int> > show_node;
int deg_counter[N_MAX];

class UnionFind {
    private:
        int par[N_MAX];
        int rank[N_MAX];
    public:
        UnionFind(int n) {
            for(int i = 1;i <= n;i++) {
                par[i] = i;
                rank[i] = 0;
            }
        }

        int root(int x) {
            return x == par[x] ? x : par[x] = root(par[x]);
        }

        bool same(int x,int y) {
            return root(x) == root(y);
        }

        void merge(int x,int y) {
            x = root(x);
            y = root(y);
            if(x == y)
                return;

            if(rank[x] < rank[y])
                par[x] = y;
            else {
                par[y] = x;
                if(rank[x] == rank[y])
                    rank[x]++;
            }
        }
};

void dfs(int prev, int current) {
    visited[current] = true;
    for(int i = 0;i < G[current].size();i++) {
        int u = G[current][i];
        if(visited[u])
            continue;
        dfs(current,u);
    }

    if(deg_counter[current] % 2 == 1) {
        show_node.push_back(make_pair(current,prev));
        deg_counter[current]++;
    } else {
        deg_counter[prev]++;
        show_node.push_back(make_pair(prev,current));
    }

    return;
}

void solve(void) {
    UnionFind ut(N);

    vector<pair<int,int> > left;
    for(int i = 0;i < M;i++) {
        int x = Edge[i].first;
        int y = Edge[i].second;
        if(ut.same(x,y)) {
            left.push_back(make_pair(x,y));
        } else {
            ut.merge(x,y);
            G[x].push_back(y);
            G[y].push_back(x);
        }
    }

    for(int i = 0;i < left.size();i++) {
        int u = left[i].first;
        int v = left[i].second;
        show_node.push_back(make_pair(u,v));
        deg_counter[u]++;
    }

    visited[1] = true;
    for(int i = 0;i < G[1].size();i++) {
        int v = G[1][i];
        if(visited[v])
            continue;
        dfs(1, v);
    }

    for(int i = 0;i < show_node.size();i++) {
        cout<<show_node[i].first<<" "<<show_node[i].second<<endl;
    }

    return;
}
int main(void) {
    cin>>N>>M;

    for(int i = 0;i < M;i++) {
        int a,b;
        cin>>a>>b;
        Edge.push_back(make_pair(a,b));
    }

    if(M % 2 == 1) {
        cout<<-1<<endl;

        return 0;
    }

    solve();

    return 0;
}


Measured memory_bytes: 16500
# coding: utf-8
# Your code here!
import sys
import itertools

def main():
    S = list(str(sys.stdin.readline()))
    
    # print(S)
    
    S_len = len(S)
    dp = [0]*(S_len+1)
    target = ["A", "C", "G", "T"]
    
    for i in range(1, S_len+1):
        if S[i-1] in target:
            dp[i] = max(1, dp[i-1]+1)
            
    print(max(dp))
                
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
n,m,l = gets.split(" ").map(&:to_i)

a = Enumerator.new {|y|
	n.times {
		y << gets.split(" ").map(&:to_i)
	}
}.to_a
b = Enumerator.new {|y|
	m.times {
		y << gets.split(" ").map(&:to_i)
	}
}.to_a

c = Enumerator.new {|mat|
	n.times {|i|
		mat << Enumerator.new {|line|
			l.times {|j|
				line << (0...m).map {|k|
					a[i][k]*b[k][j]
				}.inject(:+)
			}
		}.to_a
	}
}.to_a

c.each do |line|
	line.each_with_index {|v,idx|
		if idx == line.length-1
			p v
		else
			print v," "
		end
	}
end

Measured memory_bytes: 7660
#include<iostream>

long long modinv(long long a, long long n);
int mod_num = 1000000007;

int main(){
    int n, a, b;
    std::cin >> n >> a >> b;
    
    long long combin_num = 1;
    int mask = 1;
    long long n_2 = 2;
    for(int i=0; i<31; i++){
        if(n & mask){
            combin_num = combin_num * n_2 % mod_num;
        }
        mask *= 2;
        n_2 = n_2 * n_2 % mod_num;
    }
    
    combin_num = (combin_num - 1) % mod_num;
    if(combin_num < 0){ combin_num += mod_num;}
    
    long long combin_tmp = 1;
    int a_r = a <= n / 2 ? a : n - a;
    for(int i=n; i>n-a_r; i--){
        combin_tmp = combin_tmp * i % mod_num;
    }
    for(int i=2; i<=a_r; i++){
        combin_tmp = combin_tmp * modinv(i, mod_num) % mod_num;
    }
    combin_num = (combin_num - combin_tmp) % mod_num;
    if(combin_num < 0){ combin_num += mod_num;}
    
    combin_tmp = 1;
    int b_r = b <= n / 2 ? b : n - b;
    for(int i=n; i>n-b_r; i--){
        combin_tmp = combin_tmp * i % mod_num;
    }
    for(int i=2; i<=b_r; i++){
        combin_tmp = combin_tmp * modinv(i, mod_num) % mod_num;
    }
    combin_num = (combin_num - combin_tmp) % mod_num;
    if(combin_num < 0){ combin_num += mod_num;}
    
    std::cout << combin_num << std::endl;
    return 0;
}

long long modinv(long long a, long long n){
    long long b = n, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; std::swap(a, b);
        u -= t * v; std::swap(u, v);
    }
    u %= n; 
    if (u < 0) u += n;
    return u;
}


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

using namespace std;
using ll = long long;

int main() {
    int N = 0;
    cin >> N;

    vector<unsigned long long> A(90);
    A.at(0) = 2;
    A.at(1) = 1;
    for (size_t i = 2; i < 90; i++)
    {
        A.at(i) = A.at(i-1)+A.at(i-2);
    }
    cout << A.at(N) << endl;

    return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define mod 998244353
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int main() {
   fast();
  long long n,p;
  cin>>n>>p;
  long long d=sqrt(p);
  unordered_map<long long int,long long int> m;
 
  while(p%2==0){
      p=p/2;
      m[2]++;
  }
  long long l=p;
  for(long long i=3;i<=sqrt(l);i+=2){
    while(l%i==0){
      l=l/i;
      m[i]++;
    }
  }
  if(l>2){
    m[l]++;
  }
  long long ans=1;
  for(auto i:m){
    long long t=(i.second)/n;
    long long a=i.first;
    ans*=binpow(a,t);
  }
  cout<<ans<<"\n";
   




}


Measured memory_bytes: 3680
#include<stdio.h>
#include<stdlib.h>

int compare(const void *a, const void *b){
	int *A = (int *)a;
	int *B = (int *)b;
	if (*A > *B) return 1;
	if (*A < *B) return -1;
	return 0;
}

int main(){
	int N;
	scanf("%d",&N);
	int a[N];
	for(int i=0;i<N;i++)scanf("%d",&a[i]);
	qsort(a,N,sizeof(int),compare);
	printf("%d\n",a[N-1]-a[0]);
	return 0;
}

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

int main(){
  string s;
  cin >>s;
  int n = s.size();
  for(int i=0; i<n ; i++) s[i]='x';
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int N, K;
  cin >> N >> K;
  vll x(N);
  rep(i, N) {
    cin >> x[i];
  }
  
  //基本に忠実に！
  //連続するKについて！
  ll dist = INF;
  rep(i, N-K+1) {
    chmin(dist, x[i+K-1] < 0 ? abs(x[i]) : (x[i] > 0 ? x[i+K-1] : abs(x[i]) + x[i+K-1] + min(abs(x[i]), x[i+K-1])));
  }
  fin(dist);
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
const long long  pi = 1e9 + 7;
long long a, b, sumb = 1,suma = 0, ans = 0;
int main()
{
	scanf("%lld%lld",&a,&b);
	if(a > b){ long long  t = a; a = b; b = t;}
	if(b - a > 1) printf("0\n");
    else{
		for(long long i = 1; i <= b; i++){
			sumb *= i;
			sumb %= pi;
			if(i == a) suma = sumb;
        }
		if(b - a){
			ans =( suma * sumb )% pi;
			printf("%lld\n",ans);
		}
		else{
			ans = (suma * sumb) % pi;
			ans = (ans * 2) % pi;
			printf("%lld\n",ans);
		}
	}
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <stdio.h>
#include <set>
#include <map>
#include <vector>

using namespace std;

#define ll long long
#define rep(i, n) for (ll i = 1; i < (n+1); i++)
#define req(j, n) for (ll j = 1; j < (n+1); j++)
#define rer(k, n) for (ll k = 1; k < (n+1); k++)


int main()
{
    ll N;
    cin >> N;
    int arr[N];
    vector<int> A(N, 0);
    rep(i, N-1) {
        cin >> arr[i];
        A[arr[i]-1] += 1;
    }
    rep(k, N) {
        cout << A[k-1] << endl;
    }
}

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

#define reb(i,b,n) for(int i=(int)(b); i<(int)(n); i++)
#define rep(i,n) reb(i,0,n)
#define rreb(i,b,n) for(int i = b-1; i >= n; i--)
#define rrep(i,n) reb(i,n,0)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define reach(it,v) for(__typeof((v).rbegin()) it=(v).rbegin();it!=(v).rend();it++)
#define vall(x) (x).begin(), (x).end()
#define rvall(x) (x).rbegin(), (x).rend()
#define vsort(v) sort(vall(v))
#define rvsort(v) sort(rvall(v))
#define len(array) (sizeof (array) / sizeof *(array))
#define aall(x) x, x+len(x)
#define asort(x) sort(aall(x))
#define rasort(a, type) sort(aall(a), greater<type>())
#define afill(a, v) fill(aall(a), v)
#define afill2(a, v, type) fill((type *)a, (type *)(a + len(a)), v)
#define sz(x) (int)(x).size()
#define mp(a, b) make_pair(a, b)
#define fi first
#define se second
#define pb push_back
#define _USE_MATH_DEFINES
#define priArr(table, n) rep(i,n){cout<<table[i]<<' ';}cout<<'\n';
#define priAr2(table,W,H) rep(y,H){rep(x,W)cout<<table[y][x]<<' ';cout<<'\n';}
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = ["<<(x)<<"]"<<endl;

using namespace std;
using std::stringstream;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline std::string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class F, class T> inline void convert(const F &f, T &t){stringstream ss;ss<<f;ss>>t;}
template<class T> inline T sqr(T x) {return x*x;}

typedef long long ll; typedef unsigned long long ull;
typedef pair <ll, ll> P; typedef pair <int, P> PP;
typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<string> vs;
typedef vector<ll> vl; typedef vector<P > vP; typedef vector<char> vc;
typedef long double ld;

const static int INF = 0x3f3f3f3f;
const static ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const static double EPS = 1e-9;
const static ll MOD = 1000000007LL;

int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};
/* -------------------------------------------------------------------------- */


ll calcManhattan(P x, P y) {
    return abs(x.fi - y.fi) + abs(x.se - y.se);
}

int main(int argc, char *argv[])
{
    int n, m;
    P stu[50], pt[50];
    cin >> n >> m;

    for (int i=0; i<n; i++) {
        cin >> stu[i].fi >>  stu[i].se;
    }
    for (int i=0; i<m; i++) {
        cin >> pt[i].fi >>  pt[i].se;
    }

    for (int i=0; i<n; i++) {
        int res=0;
        ll min_dist=INFL;
        for (int j=0; j<m; j++) {
            ll now_dist = calcManhattan(stu[i], pt[j]);
            if (now_dist < min_dist) {
                min_dist = now_dist;
                res = j;
            }
        }
        cout << res+1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#整数の入力
N = int(input())
#文字列の入力
S = input()
#listを一文字ずつのlistに
S_list = list(S)

ans = ""
for i in range(len(S_list)):
  if(ord(S_list[i])+N<=90):
    #インクリンメント 次の文字を表示
    ans = ans + chr(ord(S_list[i]) + N)
  else:
    a = ord(S_list[i])+N - 90
    #print(a)
    ans = ans + chr(a+64)
  
print(ans)

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 61)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



string s;
void solve(){
	cin >> s;
	
	cout << s[0] << s[1] << s[2] << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <utility>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    if(a >= 13) ans = b;
    else if(a >= 6 && a <= 12) ans = b / 2;
    else ans = 0;
    cout << ans << endl;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
using namespace std;

const int B=999999937;
const int P=1000000007;

vector<long long> gen_hash(const string &s){
	vector<long long> hash(s.size());
	long long c=0;
	for(int i=0;i<s.size();i++){
		c=(c*B+s[i])%P;
		hash[i]=c;
	}
	return hash;
}
long long pow_binary_mod(long long x,long long y,long long mod){
	long long z=1;
	for(;y;y>>=1){
		if((y&1)!=0)z=z*x%mod;
		x=x*x%mod;
	}
	return z;
}

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

	string s;
	cin>>s;
	vector<long long> v=gen_hash(s);

	//int T;
	//for(cin>>T;T--;){
		string q;
		cin>>q;
		long long hash=gen_hash(q)[q.size()-1];
		long long Brev=pow_binary_mod(B,q.size(),P);
		vector<int> r;
		for(int i=q.size()-1;i<s.size();i++){
			long long h=((v[i]-(i==q.size()-1?0:v[i-q.size()])*Brev)%P+P)%P;
			if(h==hash)r.push_back(i-q.size()+1);
		}
		if(!r.empty()){
			for(int i=0;i<r.size();i++)printf("%d\n",r[i]);
			//puts("1");
		}else{
			//puts("0");
		}
	//}
}

Measured memory_bytes: 15916
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let abc: Vec<u64> = read_vec();
    let a = abc[0];
    let b = abc[1];
    let c = abc[2];

    if c <= a + b {
        println!("No");
    } else if 4 * a * b < (c - a - b) * (c - a - b) {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int64_t> L(N+1);
  L.at(0)=2;
  L.at(1)=1;
  for(int i=2;i<=N;i++)
    L.at(i)=L.at(i-1)+L.at(i-2);
  int64_t ans=L.at(N);
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
int main(){
    int w, h, x, y;
    scanf("%d%d%d%d", &w, &h, &x, &y);
    printf("%lf %d\n", double(w)*double(h) / 2, x + x == w&&y + y == h);
}

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

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

typedef long long ll;

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll LCM(ll x, ll y)
{
    return x * y / GCD(x, y);
}

int main()
{
    int n, k;
    cin >> n >> k;
    int r, s, p;
    cin >> r >> s >> p;

    string T;
    cin >> T;

    rep(i, n)
    {
        if (T.at(i) == 'r')
            T.at(i) = 'p';
        else if (T.at(i) == 's')
            T.at(i) = 'r';
        else if (T.at(i) == 'p')
            T.at(i) = 's';
    }

    for (int i = k; i < n; i++) {
        if (T.at(i) == T.at(i - k)) {
            T.at(i) = 'x';
        }
    }

    ll ans = 0;
    rep(i, n)
    {
        if (T.at(i) == 'r')
            ans += r;
        else if (T.at(i) == 's')
            ans += s;
        else if (T.at(i) == 'p')
            ans += p;
    }

    cout << ans << endl;
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-

def readInts():
  return [int(s) for s in input().split(" ")]

def main():
  N = readInts()[0]
  V = readInts()
  C = readInts()
  ans = 0
  for n in range(N):
    ans += max(0, V[n] - C[n])
  print(ans)

if __name__ == "__main__":
  main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define mk make_pair
#define fi first
#define se second

#define int long long
using namespace std;
main(){
  int a,b;
  cin>>a>>b;
  if(a>b)swap(a,b);
  if(abs(a-b)>1)cout<<0<<endl;
  else if(a==b){
    int sum=1;
    while(a>1){
      sum*=a;
      sum=sum%1000000007;
      a--;
    }
    while(b>1){
      sum*=b;
      sum=sum%1000000007;
      b--;
    }
    cout<<(sum*2)%1000000007<<endl;
  }
  else{
    int sum=1;
    while(a>1){
      sum*=a;
      sum=sum%1000000007;
      a--;
    }
    while(b>1){
      sum*=b;
      sum=sum%1000000007;
      b--;
    }
    cout<<(sum%1000000007)<<endl;
  }
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
// const ll mod = 1000000007;
const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

bool solve(){
    ll n;cin>>n;
    vector<ll>a(n),b(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];

    ll num=0;
    rep(i,n){
        if(a[i]<b[i])num+=(b[i]-a[i])/2;
    }
    rep(i,n){
        if(a[i]>b[i])num+=(b[i]-a[i]);
    }
    cout<<(num<0 ? "No" : "Yes")<<endl;

    return false;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(30);
    solve();
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

const int MAX = 6;

int in[MAX][MAX];
int Rec[2][MAX][MAX];

void input(){
  for(int i = 1; i < MAX; i++)
    for(int j = 1; j < MAX; j++)
      cin >> in[i][j];
}

void solve(){
  for(int i = 1; i < MAX; i++)
    for(int j = 1; j < MAX; j++)
      if(in[i][j]) Rec[0][i][j] = min(Rec[0][i-1][j-1],min(Rec[0][i][j-1],Rec[0][i-1][j]));



  for(int i = 1; i < MAX; i++)
    for(int j = 1; j < MAX; j++)
      if(in[i][j]) Rec[1][i][j] = Rec[1][i][j-1]+1;


  int ans = 0;

  for(int i = 1; i < MAX; i++)
    for(int j = 1; j < MAX; j++){
      int left = MAX;
      for(int k = i; k < MAX; k++){
	left = min(left,Rec[1][k][j]);
	if(in[k][j]) ans = max(ans,left*(k-i+1));
	else break;
      }
    }

  for(int i = 1; i < MAX; i++)
    for(int j = 1; j < MAX; j++)
      ans = max(ans,Rec[0][i][j]);
      
  cout << ans << endl;
}

void init(){
  memset(Rec,0,sizeof(Rec));
}

int main(){
  int N;
  cin >> N;
  while(N--){
    init();
    input();
    solve();
  }
  return 0;
}

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

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

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

struct Edge{
    ll dst;
    ll weight;
    Edge(ll dst, ll weight): dst(dst), weight(weight) {}
};

struct TmpDist{
    ll vertex;
    ll dist;
    TmpDist(ll vertex, ll dist): vertex(vertex), dist(dist) {}
    bool operator< (const TmpDist& right)const{
        return dist > right.dist;
    }
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
const ll INFLL = LLONG_MAX/3;

vector<ll> dijkstra(Graph &G, ll r){
    ll V = G.size();
    vector<ll> dist(V, INFLL);
    priority_queue<TmpDist> pq;
    vector<bool> check(V, false);
    TmpDist init(r, 0);
    pq.push(init);
    while(!pq.empty()){
        TmpDist td = pq.top();pq.pop();
        ll now = td.vertex;
        if(!check[now]){
            check[now] = true;
            dist[now] = td.dist;
            for (int i=0;i<(int)G[now].size();i++){
                if(dist[G[now][i].dst] > td.dist + G[now][i].weight){
                    TmpDist tdCandidate(G[now][i].dst, td.dist + G[now][i].weight);
                    pq.push(tdCandidate);
                }
            }
        }
    }
    return dist;
}

vector<ll> dx = {1, 0};
vector<ll> dy = {0, 1};

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

    ll H, W;
    cin >> H >> W;

    vector<string> S(H);
    REP(i, H) cin >> S[i];

    Graph G(H*W);
    REP(i, H){
    	REP(j, W){
    		REP(k, 2){
    			ll ni = i + dx[k];
    			ll nj = j + dy[k];
    			if(ni>=H) continue;
    			if(nj>=W) continue;
    			if(S[i][j]=='.' && S[ni][nj]=='#'){
    				Edge e = {ni*W+nj, 1};
    				G[i*W+j].push_back(e);
    			}else{
    				Edge e = {ni*W+nj, 0};
    				G[i*W+j].push_back(e);
    			}
    		}
    	}
    }
    auto res = dijkstra(G, 0);
    if(S[0][0]=='#') res[H*W-1]++;
    cout << res[H*W-1] << endl;
    return 0;
}

Measured memory_bytes: 1024