akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.IOException;
import java.io.FileReader;
import java.io.FileWriter;

import java.util.*;
import java.util.stream.LongStream;

public class Main {
    // 標準入力
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // 標準入力数値配列用 int
    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    /* 標準入力数値配列用 long */
    static long[] inputLongArr() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        long[] longarray = new long[strarray.length];
        for (int i = 0; i < longarray.length; i++) {
            longarray[i] = Long.parseLong(strarray[i]);
        }
        return longarray;
    }

    // 標準入力数値リスト用 int
    static List<Integer> inputIntList() throws Exception {
        List<String> strList = Arrays.asList(br.readLine().trim().split(" "));
        List<Integer> intList = new ArrayList<Integer>();
        for (String elem : strList){
            intList.add(Integer.parseInt(elem));
        }
        return intList;
    }

    // 標準入力数値配列用 integer 降順ソート用
    static Integer[] inputvalInteger() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        Integer[] intarray = new Integer[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    /*標準入力long*/
    static long inputLong() throws Exception {
        return Long.parseLong(br.readLine());
    }

    /*標準入力long*/
    static int inputInt() throws Exception {
        return Integer.parseInt(br.readLine());
    }




    public static void main(String[] args) throws Exception {
        // write your code here
        int n = inputInt();
        long [] al = inputLongArr();
        int kCnt = 0;
        for (long a : al){
            kCnt+= a % 2;
        }
        if (kCnt %2 == 0){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }

    }

}



Measured memory_bytes: 46884
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

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

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

// End of template.

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin.read(buf, sizeof buf); // 注意: ./a.out < in か pbp | ./a.out で入力すること

    int n, k, h[200200];
    cin >> n >> k;
    rep(i, n) cin >> h[i];

    int64 ans = 0;
    sort(begin(h), begin(h) + n);
    rep(i, n - k) ans += h[i];
    print(ans);

    return 0;
}



Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int x = sc.nextInt();
		
		int min=x-(k-1);
		int max=x+(k-1);
		
		for(int i=min;i<max+1;i++) {
			System.out.print(i);
			System.out.print(" ");
		}
	
		
		
	}
}


Measured memory_bytes: 23252
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A < C && C < B || A > C && C > B) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> s(h);
	rep(i,h) cin >> s[i];
	int ans = 0;
	rep(H,(1<<h)){
		rep(W,(1<<w)){
			int cnt = 0;
			rep(i,h){
				rep(j,w){
					if((H>>i & 1) && (W>>j & 1)){
						if(s[i][j] == '#') ++cnt;
					}
				}
			}
			if(cnt == k) ++ans;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void)
{
  string input;

  cin >> input;

  sort(input.begin(), input.end());
  if (input == "abc"){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back
 
int main(){
	fast;
	string s;
  	cin >> s;
	deque<char> dq;
	for(int i; i< s.size(); i++) dq.pb(s[i]);
	bool rev = false;
	int q;
  	cin >> q;
	while(q--){
		int t;
      	cin >> t;
		if(t == 1)rev ^= 1;
		else{
			int f;
          	cin >> f;
			char c;
          	cin >> c;
			if(rev){
				if(f == 1)dq.pb(c);
				else dq.push_front(c);
			}
			else {
				if(f == 1)dq.push_front(c);
				else dq.pb(c);
			}
		}
	}
	string ans;
	while(!dq.empty()){
		ans += dq.front();
		dq.pop_front();
	}
	if(rev) reverse(ans.begin(), ans.end());
	cout << ans;
	return 0;
}

Measured memory_bytes: 1368
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int input, max_num, sum;
	cin >> input;
	max_num = input;
	sum = input;
	cin >> input;
	max_num = max(input, max_num);
	sum += input;
	cin >> input;
	max_num = max(input, max_num);
	sum += input;
	cout << sum - max_num <<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int n,num;cin>>n>>num;
    int check=num,cnt=1,ans=0,last=0;
    for(int i=1;i<n;i++){
        cin>>num;
        if(num==check){
            cnt++;
            if(i==n-1)last=1;
        }else{
            ans+=(cnt)/2;
            cnt=1;
            check=num;
        }
    }
    if(last==1)ans+=(cnt)/2;
    cout<<ans<<endl;
    
}


Measured memory_bytes: 256
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

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

#define all(x) (x).begin(),(x).end()

typedef long long LL;
typedef long double LD;

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < a.second;
    }
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

long acm(vector<long> A) {
    long ret = 0;
    for (int i = 0; i < A.size(); i++)
        ret += A[i];

    return ret;
}

int main()
{
    int N;
    long ans;
    cin >> N;
    vector<long> A(N, 0);
    for (int i = 0; i < N; i++)
        cin >> A[i];

    sort(all(A));
    int neg, zer, pos = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] == 0) zer++;

        if (A[i] > 0) {
            pos = N - i;
            break;
        }
    }
    neg = N - zer - pos;

    if (zer) {
        for (int i = 0; i < neg; i++)
            A[i] *= (-1);

        ans = acm(A);
    } else  if (neg && pos) {
        int times = neg / 2;
        for (int i = 0; i < 2*times; i++)
            A[i] *= (-1);

        if (-A[2*times] > A[2*times + 1]) {
            A[2*times] *= (-1);
            A[2*times + 1] *= (-1);
        }

        ans = acm(A);
    } else if (neg) {
        int times = neg / 2;
        for (int i = 0; i < 2*times; i++)
            A[i] *= (-1);

        ans = acm(A);
    } else {
        ans = acm(A);
    }

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


Measured memory_bytes: 1792
'''
　 ∧_,,∧    究極奥義「WAがACになーれ！！」
　（`・ω・)つ━☆・*。
　⊂　　 ノ 　　　・゜+.
　 し’´Ｊ　　*・ 
'''
import sys
input = sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
ans=1
cnt=0
i=0
while i<n-1 and cnt<2:
    if a[i]==a[i+1]:
        ans*=a[i]
        i+=2
        cnt+=1
    else:
        i+=1
if cnt==2:
    print(ans)
else:
    print(0)


Measured memory_bytes: 85384
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int Q = sc.nextInt();
        int H = sc.nextInt();
        int S = sc.nextInt();
        int D = sc.nextInt();
        int N = sc.nextInt();

        int Hmin = Q*2 < H ? Q*2 : H;
        int Smin = Hmin*2 < S ? Hmin*2 : S;
        int Dmin = Smin*2 < D ? Smin*2 : D;
        
        long price = (long) N/2 * Dmin + N%2 * Smin;
        System.out.println(price);
    }
}


Measured memory_bytes: 23764
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int main(){
	int N;
	vi A;
	cin >> N;
	for (int i = 0; i < N; i++){
		int a;
		cin >> a;
		A.push_back(a);
	}
	int mincost = 200 * 200 * 100;
	for (int i = -100; i <= 100; i++){
		int cost = 0;
		for (int j = 0; j < N; j++){
			cost += (A[j] - i)*(A[j] - i);
		}
		mincost = min(mincost, cost);
	}
	cout << mincost << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <functional>

int main() {
  size_t n;
  std::cin >> n;

  // std::map<int, int, std::greater<int>> v[2];  // (出現数, 要素)
  // 出現数の降順で並んでほしいです．冷静に考えてこれ map で
  // 持つ必要無くないですか？ vector に突っ込んでいい気がする
  // というかそうしないとだめで，同じ出現数の要素が複数あるときにこわれる．
  // multimap というものがあって云々？
  std::vector<std::pair<int, int>> v[2];
  {
    std::map<int, int> tmp[2];  // (要素, 出現数)
    for (size_t i=0; i<n; i+=2)
      for (size_t j=0; j<2; ++j) {
        int v_i;
        std::cin >> v_i;
        ++tmp[j][v_i];
      }
    for (size_t j=0; j<2; ++j) {
      for (const auto& p: tmp[j])
        v[j].emplace_back(p.second, p.first);
      std::sort(v[j].begin(), v[j].end(), std::greater<>());
    }
  }

  // 偶奇で分けたとき，各々のうちで最も多く出現する値とその数（へのイテレータ）
  // *f0 の型は std::pair<int, int> のはず
  auto f0=v[0].begin();
  auto f1=v[1].begin();

  if (v[0].size() == 1 && v[1].size() == 1) {
    // 各グループの種類数がどちらも 1 のとき
    if (f0->second == f1->second) {
      // それらが同じなら半分を変える必要があります
      std::cout << n/2 << std::endl;
    } else {
      // 異なっていれば何も変える必要がありません
      std::cout << "0\n";
    }
    return 0;
  }

  if (f0->second != f1->second) {
    // 最も多く出現する値が異なっていれば，それら以外を変えます
    std::cout << n-(f0->first+f1->first) << std::endl;
    return 0;
  }

  // どちらも同じ場合はどうしますか？
  // 出現数が少ない方は二番目に多く出現する値に変えます
  auto g0=std::next(f0);  // vector になったので，ここは
  auto g1=std::next(f1);  // gi=fi+1 でいいですね
  if (f0->first != f1->first) {
    // 要素数が 1 のとき，std::next(foo.begin()) の要素を取得することは
    // できませんが，今回は問題設定の関係からそうした状況は避けられます．
    // 要素数が 1 だった場合，出現数は n/2 のはずで，相手のグループがそれを
    // 上回ることはできないからです．
    if (f0->first > f1->first) {
      std::cout << n-(f0->first+g1->first) << std::endl;
    } else {
      std::cout << n-(g0->first+f1->first) << std::endl;
    }
    return 0;
  }

  // タイの場合はどうしますか？
  // 二番目に多く出現する値の出現数が大きい方のグループは，
  // その値に変えることにし，そうでない方のグループは一番多く出現する
  // 値に変えることにします．それでも同じなら適当に選びます
  std::cout << n-(f0->first+std::max(g0->first, g1->first)) << std::endl;
}

Measured memory_bytes: 6136
#include<stdio.h>
#include<stdio.h>
int main()
{
    int n, i;
    scanf("%d", &n);
    int p[n],count[n+1];
    for(i=1; i<n+1; i++){
        count[i]=0;
    }
    for(i=1; i<n; i++){
        scanf("%d", &p[i]);
    }
    for(i=1; i<n; i++){
        count[p[i]]++;
    }
    for(i=1; i<n+1; i++){
        printf("%d\n", count[i]);
    }
    return 0;

}


Measured memory_bytes: 3252
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int dsu[200005]; 
int main(){
	int n,q;
	cin>>n>>q;
	rep(i,n){
		dsu[i]=i;
	}
	rep(i,q){
		int a,b,c;
		cin>>a>>b>>c;
		int num1=b,num2=c;
		while(dsu[num1]!=num1){
			num1=dsu[num1];
		}
		dsu[b]=num1;
		while(dsu[num2]!=num2){
			num2=dsu[num2];
		}
		dsu[c]=num2;
		if(a){
			if(num1==num2){
				cout<<1<<endl;
			}
			else{
				cout<<0<<endl;
			}
		}
		else{
			dsu[num1]=num2;
		}
	}
	re 0;
}

Measured memory_bytes: 4332
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL maxn=1e6+10;
const LL mod=1e9+7;
int mp[maxn];
int n;
int a[maxn];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        mp[a[i]]++;
    }
    int res=0;
    for(int i=1;i<=n;i++){
            int f=0;
        for(int j=1;j*j<=a[i];j++){
            if(a[i]%j==0){
                if(j!=a[i]){
                    if(mp[j]){
                        f++;
                        break;
                    }
                }
                else{
                    if(mp[j]>1){
                        f++;break;
                    }
                }
                int pre=a[i]/j;
                if(pre!=a[i]){
                    if(mp[pre]){
                        f++;break;
                    }
                }
                else{
                    if(mp[pre]>1){
                        f++;break;
                    }
                }
            }
        }
        if(f==0){
            res++;
        }
    }
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 8492
#include <bits/stdc++.h>
#define ll long long int
#define pll pair<ll, ll>
#define pii pair<int, int>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int k, a, b;
    cin >> k >> a >> b;
    int x = (a / k) * k;
    bool bo = 0;
    if (x >= a && x <= b)
    {
        bo = 1;
    }
    x += k;
    if (x >= a && x <= b)
    {
        bo = 1;
    }
    if (bo)
    {
        cout << "OK\n";
    }
    else
    {
        cout << "NG\n";
    }

    return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int h  = stdIn.nextInt();
		int w = stdIn.nextInt();
		
		char[][]s = new char[h+2][w+2];
		
		for(int i = 1; i <= h; i++) {
			String ss = stdIn.next();
			
			for(int j = 1; j <=w; j++) {
				s[i][j] = ss.charAt(j-1);
			}
			
		}
		
		/*for(char[] a: s) {
			for(char b: a) {
				System.out.print(b);
			}
			System.out.println();
		}*/
		
		/*for(int i = 0; i < h+2; i++) {
			for(int j = 0; j < w+2; j++) {
				System.out.print(s[i][j]);
			}
			System.out.println();
		}*/
		
		
		
		boolean flag = false;
		
		for(int i = 1; i <= h; i++) {
			for(int j = 1; j <=w; j++) {
				
				if(s[i][j]=='#' && s[i][j-1] == '.' && s[i][j+1] == '.' && s[i-1][j] == '.' && s[i+1][j] == '.') {
					flag = true;
				}
				
				
			}
		}
		
		if(flag) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
		
		
	}

}


Measured memory_bytes: 23764
N = int(input())
G = [[int(x) for x in input()] for k in range(N)]
es = [[] for k in range(N)]

for k in range(N):
    for l in range(N):
        if G[k][l] == 1:
            es[k].append(l)

#
# 二部グラフ判定by prdさん
#

#n個の頂点の色を初期化。0:未着色、1:黒、-1:白
colors = [0 for i in range(N)]

#頂点vをcolor(1 or -1)で塗り、再帰的に矛盾がないか調べる。矛盾があればFalse
def dfs(v,color):
    #今いる点を着色
    colors[v] = color
    #今の頂点から行けるところをチェック
    for to in es[v]:
        #同じ色が隣接してしまったらFalse
        if colors[to] == color:
            return False
        #未着色の頂点があったら反転した色を指定し、再帰的に調べる
        if colors[to] == 0 and not dfs(to, -color):
            return False
    #調べ終わったら矛盾がないのでTrue
    return True

#2部グラフならTrue, そうでなければFalse
def is_bipartite():
    return dfs(0,1) # 頂点0を黒(1)で塗ってDFS開始

if is_bipartite() == False:
    print(-1)
    exit(0)

# ワーシャルフロイドで距離を求める
D = [[float("inf") for k in range(N)] for l in range(N)]
for k in range(N):
    for l in range(N):
        if k == l:
            D[k][l] = 0
        elif G[k][l] == 1:
            D[k][l] = 1

for p in range(N):
    for q in range(N):
        for r in range(N):
            D[q][r] = min(D[q][r],D[q][p]+D[p][r])
ans = 0
for k in range(N):
    for l in range(N):
        ans = max(ans, D[k][l]+1)

print(ans)


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

const ll MOD = 1E+9 + 7;

int main() {
    ll N, M;
    cin >> N >> M;

    ll ans;
    if (abs(N - M) > 1) ans = 0;
    else {
        ans = 1;
        for (int n=N; n>=1; n--) {
            ans *= n;
            ans %= MOD;
        }
        for (int m=M; m>=1; m--) {
            ans *= m;
            ans %= MOD;
        }
        if (M == N) {
            ans *= 2;
            ans %= MOD;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        int n = sc.nextInt();
//        n = (char)n;
        String s = sc.next();

        char[] arr = s.toCharArray();

        char[] 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','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'};

        String str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

        for (int i=0; i<s.length(); i++){
            char tmp = arr[i];
            int idx = str.indexOf(tmp);
            idx += n;
            arr[i] = alpha[idx];
        }
        StringBuilder sb = new StringBuilder();
        for (int i=0; i<s.length(); i++){
            sb.append(arr[i]);
        }
        System.out.println(sb);

    }
}

Measured memory_bytes: 23636
#include <iostream>

using namespace std;

int main(void) {
    int w, h;
    
    while(1){
        cin >> h >> w;
        
        if(w == 0 && h == 0){
            break;
        }
        
        for(int i = 0;i < h; ++i){
            for(int j = 0;j < w; ++j){
                if(i == 0 || i == h - 1 || j == 0 || j == w - 1){
                    cout << "#";
                } else {
                    cout << ".";
                }
            }
            cout << "\n";
        }
        cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 1120
import math
x = int(input())
r = [1]
for y in range(2, int(math.sqrt(x)) + 1):
    z = 2
    tmp = 1
    while math.pow(y, z) <= x:
        tmp = int(math.pow(y, z))
        z += 1
    r.append(tmp)
print(max(r))

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

using namespace std;

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

  string s;
  cin >> s;
  for (int i = 0; i < 3; ++i) {
    if (i == 1) {
      cout << char(s[i] ^ 'R' ^ 'B');
    } else {
      cout << s[i];
    }
  }

  return 0;
}


Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int t[4],u[4],v[4];

int main(){
  int h,b;
  while(cin>>t[0]){
    for(int i=1;i<4;i++)cin>>t[i];
  for(int i=0;i<4;i++)cin>>u[i];
    h=b=0;
    for(int i=0;i<4;i++){
      if(t[i]==u[i])h++;
      else{
    for(int j=0;j<4;j++){
      if(t[i]==u[j])b++;
    }
      }
    }
    cout<<h<<' '<<b<<endl;
  }
  return 0;
}


Measured memory_bytes: 3060
n,m=map(int,input().split())
s=[list(map(int,input().split()))for _ in range(m)]
s.sort(key=lambda x:x[0])
c=a=0
while c<m:
    i=1
    t=s[0][1]
    while i<len(s)and s[i][0]<t:
        t=min(t,s[i][1])
        i+=1
    c+=i
    s=s[i:]
    a+=1
print(a)

Measured memory_bytes: 29140
using namespace std;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int n;
    cin >> n;
    int tmp;
    tmp = n/100 * 100 + n/100 * 10 + n/100;
    if (tmp >= n) {
        cout << tmp << endl;;
    }
    else {
        n = n/100 + 1;
        cout <<  n * 100 + n * 10 + n << endl;
    }

}


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



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    ll h[n+2];
    for(ll i=1;i<=n;i++) cin>>h[i];
    ll stone[n+2];
    stone[n]=0;stone[n+1]=1000000000;
    for(ll i=n-1;i>=0;i--)
    {
        stone[i]=min(stone[i+1]+abs(h[i+1]-h[i]),stone[i+2]+abs(h[i+2]-h[i]));
    }
    cout<<stone[1];
    return 0;
}
    

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

int main() {
  int N, M;
  cin >> N >> M;
  priority_queue<double> A_cal;
  for (int i = 0; i < N; i++) {
    int n;
    cin >> n;
    A_cal.push(n);
  }
  
  for (int i = 0; i < M; i++) {
    double maximum = A_cal.top();
    A_cal.push(maximum / 2);
    A_cal.pop();
  }
  
  int64_t sum = 0;
  for (int i = 0; i < N; i++) {
    double d = A_cal.top();
    sum += (int64_t)d;
    A_cal.pop();
  }
  
  cout << sum << endl;
  // A_calの最大を1/2して追加、最大を消すのをM回
  // その後intにキャスト
}

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

using namespace std;
struct UnionFind {
  int n;
  vector<int> parent, size;
  UnionFind(int n) {
    this->n = n;
    parent = vector<int>(n);
    size = vector<int>(n, 1);
    for (int i = 0; i < n; ++i)
      parent[i] = i;
  }

  int find(int idx) {
    if (parent[idx] == idx)
      return idx;
    return parent[idx] = find(parent[idx]);
  }

  void connect(int a, int b) {
    int fa = find(a), fb = find(b);
    if (fa != fb) {
      if (size[fa] > size[fb]) {
        parent[fb] = fa;
        size[fa] += size[fb];
      } else {
        parent[fa] = fb;
        size[fb] += size[fa];
      }
    }
  }
};

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> pts(n);
  vector<int> dict(n);
  for (int i = 0; i < n; ++i) {
    cin >> pts[i].first >> pts[i].second;
    dict[pts[i].first - 1] = i;
  }
  sort(pts.begin(), pts.end());
  UnionFind uf(n);
  vector<bool> vis(n);
  set<pair<int, int>> s;
  for (int i = 0; i < n; ++i)
    s.emplace(pts[i].second, i);
  for (int i = 0; i < n; ++i) {
    int y = pts[i].second;
    s.erase(make_pair(y, i));
    int idx = -1, hi = -1;
    while (!s.empty() && s.rbegin()->first > y) {
      hi = max(hi, s.rbegin()->first);
      idx = max(idx, s.rbegin()->second);
      uf.connect(i, s.rbegin()->second);
      s.erase(*s.rbegin());
    }
    if (idx != -1) {
      s.emplace(hi, idx);
      pts[idx].second = hi;
    }
  }
  vector<int> ans(n);
  for (int i = 0; i < n; ++i)
    ans[dict[i]] = uf.size[uf.find(i)];
  string output;
  for (int i : ans)
    output += to_string(i) + "\n";
  cout << output;
}

Measured memory_bytes: 16728
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

string K[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    rep(i, 7) {
        if (S == K[i]) cout << 7 - i << endl;
    }

    return 0;
}


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

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

    int K, a, b;
    cin >> K >> a >> b;
    int lb = b % K;
    if ((b - lb) >= a)
    {
        cout << "OK" << endl;
    }
    else
    {
        cout << "NG" << endl;
    }
    return 0;
}


Measured memory_bytes: 3656
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 114514191
#define MOD 1000000007
inline void chmax(int &x, int v) { if (x < v) x = v; }

int N;
set<int> G[100000];
char C[100001];
bool dead[100000];
int W[100000];

void erase(int x) {
  dead[x] = true;
  for (int t : G[x]) if (!dead[t]) {
    G[t].erase(x);
    if (G[t].size() == 1 && C[t] == 'B') erase(t);
  }
}
int ans = 0;
int dp0[100000], dp1[100000];
void dfs(int x, int p) {
  chmax(dp0[x], W[x]);
  chmax(dp1[x], 0);
  int maxdp0 = -INF, maxdp1 = -INF;
  for (int t : G[x]) if (t != p) {
    dfs(t, x);
    chmax(ans, dp0[t]);
    chmax(dp0[x], dp0[t] + W[x]);
    chmax(dp1[x], dp1[t] + W[x]);
    chmax(ans, W[x]+maxdp0+dp1[t]);
    chmax(ans, W[x]+maxdp1+dp0[t]);
    chmax(maxdp0, dp0[t]);
    chmax(maxdp1, dp1[t]);
  }
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N-1) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    G[x].insert(y);
    G[y].insert(x);
  }
  cin >> C;
  rep(i, N) if (G[i].size() == 1 && C[i] == 'B') erase(i);
  int root = -1, V = 0;
  rep(i, N) if (!dead[i]) root = i, V++;
  if (root == -1) {
    cout << 0 << "\n";
    return 0;
  }
  int sum = 0;
  rep(i, N) if (!dead[i]) {
    W[i] = ((C[i] == 'B') ^ ((int)G[i].size()%2)) == 0;
    sum += W[i];
  }
  int cost = 2*(V-1) + sum;
  rep(i, N) dp0[i] = dp1[i] = -INF;
  dfs(root, -1);
  cost -= 2*ans;
  cout << cost << "\n";
  return 0;
}


Measured memory_bytes: 26240
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
//change null_type here for map/set
typedef tree<int,null_type,less<int>,rb_tree_tag,
            tree_order_statistics_node_update> indexed_set;
typedef long long int  ll;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define F first
#define S second

template<class T>inline bool read(T &x){
    int c=getchar();int sgn=1;
    while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}
    for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
    x*=sgn; return ~c;
}
///START HERE
///indexed_set pbd;
//pbd.insert()
//auto x = pbd.find_by_order(2);
//int od=pbd.order_of_key(7)
///rope<int> rp;
//rp.push_back()
//RandomAccess like vector
//mutable_begin, mutable_end()

int main(){
    ///read()+printf
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //fast;
    int n,k;
    cin>>n>>k;
    int ar[n];
    for(int i=0;i<n;i++){
        cin>>ar[i];
    }
    sort(ar,ar+n);
    int s=0;
    for(int i=0;i<k;i++){
        s+=ar[i];
    }
    cout<<s<<endl;

    return 0;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=INF,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,R;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>n>>m>>R;
      vector<ll> r(R);
      rep(i,R)cin>>r[i];
      ll flo[201][201];
      rep(i,n+1){
        rep(j,n+1){
          if(i==j)flo[i][j]=0;
          else flo[i][j]=INF;
        }
      }
      rep(i,m){
        cin>>a>>b>>c;
        a--;b--;
        flo[a][b]=c;
        flo[b][a]=c;
      }
     rep(i,n){
       rep(j,n){
         rep(k,n){
           flo[j][k]=min(flo[j][k],flo[j][i]+flo[i][k]);
         }
       }
     }

     sort(all(r));

     do{
       rep(i,R-1){
         cnt+=flo[r[i]-1][r[i+1]-1];
       }
       ans=min(ans,cnt);
       cnt=0;
     }while(next_permutation(all(r)));

     Cout(ans);
       
return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int LR[500+1][500+1] = {};
int C[500+1][500+1] = {};
int p[100001] = {};
int q[100001] = {};
int ans[100001] = {};

int main() {
	int N, M, Q;
	cin >> N >> M >> Q;

	int l,r;
	for (int i = 0; i < M; ++i) {
		cin >> l >> r;
		LR[l][r]++;
	}
	for (int i = 1; i < N+1; ++i) {
		for (int j = i; j < N+1; ++j) {
			C[i][j] += LR[i][j];
			C[i][j] += C[i][j-1];
		}
	}

	for (int i = 0; i < Q; ++i) {
		cin >> l >> r;
		for (int j = l; j <= r; ++j) {
			ans[i] += (C[j][r] - C[j][j-1]);
		}
	}

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

	return 0;
}

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

int main() {
	
	string a, b;
	cin >> a >> b;
	string ans = "NO";
	if(a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) ans = "YES";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#w1<=wi<w1+3
from itertools import product
n,w_max = map(int, input().split( ))
w = {}
w1,v1 = map(int, input().split( ))
w[w1] = [v1]
w2 = w1+1
w3 =w2+1
w4 = w3+1
w[w2] = [0]
w[w3] = [0]
w[w4] = [0]
for i in range(n-1):
    wi,vi=map(int, input().split( ))
    w[wi].append(vi)

for wi in w:
    w[wi].sort(reverse = True)
#print(w)
ans = 0
l1 = len(w[w1])+1
l2 = len(w[w2])+1
l3 = len(w[w3])+1
l4 = len(w[w4])+1
for i1,i2,i3,i4 in product(range(l1),range(l2),range(l3),range(l4)):
    if w1*i1+w2*i2+w3*i3+w4*i4<=w_max:
        ans = max(ans,sum(w[w1][:i1])+sum(w[w2][:i2])+sum(w[w3][:i3])+sum(w[w4][:i4]))###

print(ans)



Measured memory_bytes: 55384
#include <iostream>
#include <cstdio>

using namespace std;

long long calc(long long x) {
	long long ret = 0;

	for (int i = 39; i > 0; i--) {
		long long mask = 1LL << i;
		if ((x & mask) && (x % 2 == 0)) {
			ret |= mask;
		}
	}
	if (x % 4 == 1 || x % 4 == 2) {
		ret |= 1;
	}
	return ret;
}

long long calc2(long long x) {
	long long ret = 0;
	for (long long i = 0; i <= x; i++) {
		ret ^= i;
	}
	return ret;

}

int main() {
	long long a, b;

	// cin >> a;
	// for (int i = 0; i <= a; i++) {
	// 	auto ret1 = calc(i);
	// 	auto ret2 = calc2(i);
	// 	printf("%3d: %4lld %4lld\n", i, ret1, ret2);
	// }
	// return 0;

	cin >> a >> b;
	if (a == 0) {
		cout << b << endl;
		return 0;
	}


	long long ans = calc(a - 1) ^ calc(b);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    int n;
    ll k;
    cin >> n >> k;

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

    ll ans = 0LL;
    for (int i = 40; i >= -1; i--) { // i桁目でkと変わる
        if (i != -1 && !(k & (1LL << i))) {
            continue;
        }

        ll tmp = 0LL;
        for (int j = 40; j >= 0; j--) {
            ll mask = 1LL << j;
            int count = 0;
            for (int l = 0; l < n; l++) {
                if (a[l] & mask) {
                    count++;
                }
            }

            if (j > i) {
                if (k & mask) {
                    tmp += mask * (n - count);
                } else {
                    tmp += mask * count;
                }
            } else if (j == i) {
                tmp += mask * count;
            } else {
                tmp += mask * max(count, n - count);
            }
        }

        ans = max(ans, tmp);
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  char X;
  cin>>X;
  if(X=='A') cout<<"T"<<endl;
  else if(X=='T') cout<<"A"<<endl;
  else if(X=='C') cout<<"G"<<endl;
  else cout<<"C"<<endl;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
using namespace std;
string t = "CODEFESTIVAL2016";
int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.length(); ++i)
    if (s[i] != t[i])
      ++ans;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
long long mod = 1000000007;
long long f[100010];
long long get_pow(long long x, long long k, long long mod) {
    long long res = 1;
    while (k) {
        if (k & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        k >>= 1;
    }
    return res;
}
int main() {
    int n, k, i, j;
    long long ans = 0;
    scanf("%d%d", &n, &k);
    for (i = 1; i <= k; i++) {
        f[i] = get_pow(k / i, n, mod);
    }
    for (i = k; i >0; i--) {
        for (j = i+i; j <= k; j += i) f[i] = (f[i]-f[j]+mod) % mod;
    }
    for (i = 1; i <= k; i++) {
        ans = (ans + i * f[i]) % mod;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 2480
<?php
$n = (int)trim(fgets(STDIN));
$input = explode(' ', trim(fgets(STDIN)));

$csum = [];
$csum[0] = 0;
for ($i=0; $i < $n; $i++) { 
	$csum[$i+1] = $csum[$i] + (int)$input[$i]; 
}
$total = $csum[$n];

$min = INF;
for ($i=1; $i <= $n; $i++) { 
	$min = min($min, abs($total - ($csum[$i] * 2)));
}
echo $min;

Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
int main(){
	int H,W,A,B;
	cin>>H>>W>>A>>B;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(j>=A&&i<B){
				cout<<1;
			}else if(i>=B&&j<A){
				cout<<1;
			}else{
				cout<<0;
			}
		}
		cout<<""<<endl;
	}
}
	

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

int main(void){
    ll Maxim=-1000000000000000000;
    ll a, b, c, d;
    cin>>a>>b>>c>>d;
    if(a*b<=0 || c*d<=0){
        Maxim=max(Maxim, (ll)0);
    }
    Maxim=max(Maxim, a*c);
    Maxim=max(Maxim, a*d);
    Maxim=max(Maxim, b*c);
    Maxim=max(Maxim, b*d);
    cout<<Maxim<<endl;
    return 0;
}


Measured memory_bytes: 3628
mod = 10 ** 9 + 7

def pow(x, n, mod = 10 ** 9 + 7)
  return 1 if n == 0
  return pow(x**2 % mod, n / 2, mod) if (n % 2) == 0
  return pow(x**2 % mod, n / 2, mod) * x % mod if (n % 2) == 1
end

# Permutation: n * (n-1) * …… * (n-k+1) (mod p); O(k)
def prm(n, k, m = 10**9+7)
  (0...k).inject(1){|res,i| res * (n-i) % m }
end

# note: m must be a prime number
# フェルマーの小定理より
def modinv(a, m = 10**9+7)
  pow(a, m-2, m)
end

# combination: nPk / k! (mod p), note: m must be a prime number
def cmb(n, k, m = 10**9+7)
  k = n - k if k > n - k
  return prm( n, k, m ) * modinv( prm(k, k), m ) % m
end

n,a,b = gets.split.map(&:to_i)

#何も選ばない1通りを除く
ans = pow(2,n,mod) - 1 - cmb(n,a) - cmb(n,b)
ans %= mod

puts ans

Measured memory_bytes: 1788
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner in = new Scanner(System.in);

		int animal = in.nextInt();
		int foot = in.nextInt();

		double kame = (foot-2*animal)/2;
		double turu = animal - kame;


		int r_kame = (int)kame;
		int r_turu = (int)turu;

		if(r_kame<0||r_turu<0) {
			System.out.println("No");
		}else if(4*r_kame+2*r_turu==foot&&r_kame+r_turu==animal) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}


	}

}


Measured memory_bytes: 35804
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
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() {
	string s, t;
	cin >> s >> t;
	vector<vector<int>> dp(s.size() + 1, vector<int>(t.size() + 1));
	for (int i = 0; i < (int)s.size(); i++) {
		for (int j = 0; j < (int)t.size(); j++) {
			if (s[i] == t[j]) chmax(dp[i + 1][j + 1], dp[i][j] + 1);
			chmax(dp[i + 1][j + 1], dp[i][j + 1]);
			chmax(dp[i + 1][j + 1], dp[i + 1][j]);
		}
	}
	string res;
	int i = s.size(), j = t.size();
	while (i > 0 && j > 0) {
		if (dp[i][j] == dp[i - 1][j]) {
			i--;
		}
		else if (dp[i][j] == dp[i][j - 1]) {
			j--;
		}
		else {
			res = s[i - 1] + res;
			i--;
			j--;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 38872
function Main(input) {
  var result = ''
  for (var i = 0; i < 3; i++) {
    if (input[i] === '1') {
      result += '9'
    } else if (input[i] === '9') {
      result += '1'
    } else {
      result += input[i];
    }
  }

  console.log(result);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
using ll=long long;

int main(){
    int n;cin>>n;
    string s;cin>>s;
    int ans=0;
    string ss;
    int cnt=0;
    for(int i=0;i<s.size();++i){
        if(s[i]=='R'){
            cnt++;
        }
    }
    for(int i=0;i<s.size();++i){
        if(i<cnt||cnt==s.size())ss.append("R");
        else ss.append("W");
    }
    int f=0,ff=0;
    for(int i=0;i<s.size();++i){
        if(s[i]!=ss[i]){
            if(i<cnt)f++;
            else ff++;
        }
    }
    if(f==ff)ans=f;
    else{
        ans=min(f,ff);
        ans+=abs(f-ff);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3836
#include <stdio.h>
int main(void)
{
    int a,b;
    scanf("%d %d",&a,&b);
    while(a!=0 || b!=0){
        if(a<b)
            printf("%d %d\n",a,b);
        else
            printf("%d %d\n",b,a);
        scanf("%d %d",&a,&b);
    }
    return 0;
}


Measured memory_bytes: 2104
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a + b == 15) {
            System.out.println("+");
        } else if (a * b == 15) {
            System.out.println("*");
        } else {

            System.out.println("x");
        }

    }

}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

vector<bool> isPrime(56000, true);

vector<int> sieve() {
    for (int i = 2; i <= 55555; i++) {
        if (!isPrime[i]) continue;
        for (int j = 2 * i; j <= 55555; j += i) {
            isPrime[j] = false;
        }
    }

    vector<int> v;
    for (int i = 2; i <= 55555; i++) {
        if (isPrime[i] && i % 5 == 1) v.push_back(i);
    }
    return v;
}

int main() {
    int n; cin >> n;
    vector<int> v = sieve();
    rep(i, n) cout << v[i] << " ";
    cout << endl;
}


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

int main()
{
  char S[20] = {0};
  
  cin >> S;
  char* p = strtok(S, "/");
  int year = atoi(p);
  p = strtok(NULL, "/");
  int month = atoi(p);
  p = strtok(NULL, "/");
  int day = atoi(p);
  
  bool isHeisei = true;
  if (year > 2019) {
    isHeisei = false;
  } else if (month >= 5) {
    isHeisei = false;
  }
  
  if (isHeisei) cout << "Heisei" << endl;
  else cout << "TBD" << endl;
  
  return 0;
}

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

void dfs(int s, vector<vector<int>> &l, vector<int> &visited)
{
	visited[s]=1;
	for(int i=0; i<l[s].size(); i++)
	{
		int v=l[s][i];
		if(visited[v]==0)
			dfs(v,l,visited);
	}
}

int main()
{
	int n,m;
	cin>>n>>m;
	vector<vector<int>> l(n);
	for(int i=0; i<m; i++)
	{
		int u,v;
		cin>>u>>v;
		l[u-1].push_back(v-1);
		l[v-1].push_back(u-1);
	}

	vector<int> visited(n,0);
	int ans=0;
	for(int i=0; i<n; i++)
	{
		if(visited[i]==0){
			ans++;
			dfs(i,l,visited);
		}
	}
	cout<<ans-1<<endl;
	return 0;	
}

Measured memory_bytes: 10056
import java.util.*;

public class Main{
	Scanner sc = new Scanner(System.in);
	int [][] data;
	int [] table;
	LinkedList<Integer> mat;
	
	private void doit(){
		data = new int[100][2];
		init();
		while(sc.hasNext()){
			int n = sc.nextInt();
			System.out.println(data[n][1] - data[n][0]);
		}
	}

	private void init() {
		table = new int[17];
		Arrays.fill(table, -1);
		mat = new LinkedList<Integer>();
		for(int i = 0;; i++){
			if(i != 0 && isOK()) break;
			out(i);
			if(i % 5 == 0 && i / 5  < 100){
				data[i / 5][0] = i;
				mat.addLast(i / 5);
			}
			while(in(i)){
			}
		}
		
	}

	private boolean in(int time) {
		if(mat.isEmpty()) return false;
		int nextid = mat.getFirst();
		int num = 0;
		if(nextid % 5 == 1){
			num = 5;
		}
		else{
			num = 2;
		}
		for(int i = 0; i < table.length; i++){
			if(table[i] != -1) continue;
			int now = 1;
			for(int j = i + 1; j < table.length; j++){
				if(table[j] == -1){
					now++;
					if(now == num){
						for(int k = 0; k < num; k++){
							table[i + k] = nextid;
						}
						data[nextid][1] = time;
						mat.removeFirst();
						return true;
					}
				}
				else{
					break;
				}
			}
		}
		return false;
	}

	private void out(int time) {
		for(int i = 0; i < table.length; i++){
			if(table[i] >= 0){
				int id = table[i];
				int res = data[id][1] + 17 * (id % 2) + 3 * (id % 3) + 19;
				if(res == time){
					table[i] = -1;
				}
			}
		}
	}

	private boolean isOK() {
		for(int i = 0; i < table.length; i++){
			if(table[i] != -1){
				return false;
			}
		}
		return true;
	}

	private void debug(Object... o) { System.out.println("debug = " + Arrays.deepToString(o)); }

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

Measured memory_bytes: 18492
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N,sum=0; cin>>N;
  vi A(N);
  rep(i,0,N){
    cin>>A[i];
    sum+=A[i];
  }
  int K; cin>>K;
  rep(i,0,K){
    int X,Y; cin>>X>>Y;
    cout<<sum-A[X-1]+Y<<endl;
  }
  }


Measured memory_bytes: 256