akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

typedef pair<int, int> XY; // first=i, second=j
int H, W;

XY next(XY xy) {
    if (xy.first % 2 == 0) {
        if (xy.second < W - 1) {
            xy.second += 1;
        }
        else {
            xy.first += 1;
        }
    }
    else {
        if (xy.second > 0) {
            xy.second -= 1;
        }
        else {
            xy.first += 1;
        }
    }
    return xy;
}

void Main() {
    cin >> H >> W;
    if (H == 1 && W == 1) {
        cout << 0 << endl;
        return;
    }
    vector<vector<int> > a(H, vector<int>(W, 0));
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> a[i][j];
        }
    }

    vector<XY> ansFrom, ansTo;
    XY xy = make_pair(0, 0);
    while (true) {
        int i = xy.first;
        int j = xy.second;
        xy = next(xy);
        if (a[i][j] % 2 == 1) {
            a[i][j] -= 1;
            a[xy.first][xy.second] += 1;
            ansFrom.push_back(make_pair(i, j));
            ansTo.push_back(make_pair(xy.first, xy.second));
        }

        if (H % 2 == 1) {
            if (xy.first == H - 1 && xy.second == W - 1) {
                break;
            }
        }
        else {
            if (xy.first == H - 1 && xy.second == 0) {
                break;
            }
        }
    }

    int sz = ansFrom.size();
    for (int i = 0; i < sz; ++i) {
        ansFrom[i].first += 1;
        ansFrom[i].second += 1;
        ansTo[i].first += 1;
        ansTo[i].second += 1;
    }

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

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

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

//main code
int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	VL a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	VL dp(n+2,INT32_MIN), sum(n+1,0);
	dp[0] = INT32_MAX;
	for (int i = n-1; i >= 0; i--) {
		auto itr = upper_bound(RALL(dp), a[i]);
		int b = dp.rend() - itr;
		dp[b] = a[i];
		sum[b] = sum[b-1] + a[i];
	}
	for (int i = n; i >= 0; i--) {
		if (sum[i] != 0) {
			cout << sum[i] << endl;
			return 0;
		}
	}
	return 0;
}




Measured memory_bytes: 5232
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
int a,b,c,tmp;
cin>>a>>b>>c;
if(a==7){
	tmp=a;
	a=b;
	b=tmp;
}else if(c==7){
	tmp=c;
	c=b;
	b=tmp;
}
if(a==5&&b==7&&c==5){
	cout<<"YES"<<endl;
}else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long int n;
  cin>>n;
  vector<long long int> a(n);
  for(long long int i=0; i<n; i++){
    cin>>a.at(i);
  }
  long long int now=1;
  long long int ans=0;
  for(long long int i=0; i<n; i++){
    if(a.at(i)==now){
      now++;
    }else{
      ans++;
    }
  }
  if(ans==n){
    cout<<-1<<endl;
  }else{
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 4796
import itertools
N,M,Q=map(int,input().split())
a=[0 for i in range(Q)]
b=[0 for i in range(Q)]
c=[0 for i in range(Q)]
d=[0 for i in range(Q)]
for i in range(Q):
    a[i],b[i],c[i],d[i]=map(int,input().split())
    b[i]-=1;a[i]-=1
ans=0
for seq in itertools.combinations_with_replacement(range(M),N):
    tmp=0
    for i in range(Q):
        if seq[b[i]]-seq[a[i]]==c[i]:
            tmp+=d[i]
    ans=max(ans,tmp)
print(ans)


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

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    if (a == b) {
        cout << c << endl;
    } else if (b == c) {
        cout << a << endl;
    } else {
        cout << b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,ans;
set<int> a; 
void dfs(string s){
	int x=0,y=0;
	stringstream ss;
	ss<<s;
	ss>>x;
	y=x;
	//cout<<"y="<<y<<endl;
	if (x>n) return ;
	set<int> b;
	while(x>0){
		b.insert(x%10);
		x/=10;
	}
	if(b==a) {
		ans++;
		//cout<<y<<" "<<endl;
	}		
	dfs(s+"3");
	dfs(s+"5");
	dfs(s+"7");
} 
int main() {
	a.insert(3);a.insert(5);a.insert(7);
	int i,j;
	cin>>n;

	dfs("");
	cout<<ans;
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,m;
    cin>>n>>m;
    ll sum=0,a;
    for(ll i=0;i<m;i++)
    {
        cin>>a;
        sum+=a;
    }
    sum=n-sum;
    if(sum<0)
    cout<<"-1";
    else
    cout<<sum;
}

Measured memory_bytes: 3636
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();
		sc.close();

		String aw = "";
		for (int i = 0; i < b; i++) {
			aw += String.valueOf(a);
		}
		String bw = "";
		for (int i = 0; i < a; i++) {
			bw += String.valueOf(b);
		}
		if (aw.compareTo(bw) >= 0) {
			System.out.println(bw);
		} else {
			System.out.println(aw);
		}
	}
}


Measured memory_bytes: 20052
/**
 * @author: pr4shan7 (प्रशांत)
 */
// #define _DEBUG

#ifndef _DEBUG
#define NDEBUG
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

// #define int long long
// #define double long double

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pb_set;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define endl '\n'
#define x first
#define y second
#define cai static_cast<int>
#define cal static_cast<long long>
#define cad static_cast<long double>
#define deb(z) cout << "// " << #z << " = " << z << endl;
const int N = 1e5 + 5;
const int INF = 1e9;
const int MV = 1e9 + 7;



int32_t main() {
	ios_base::sync_with_stdio(false);
	// cin.tie(NULL);

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

	int n; cin >> n;
	unordered_set<int> set;
	bool b = true;
	for (int i = 0; i < n; ++i)
	{
		int temp; cin >> temp;
		if(set.find(temp)!=set.end()) b=false;
		set.insert(temp);
	}
	if(b) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 8520
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(vector<vector<A>> v) { string res="{"; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res+"}";}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H,W;
  cin >> H >> W;
  MAT2D(m,int,H+2,W+2);
  REP(i,H) {
    string s;
    cin >> s;
    REP(j,W) {
      if (s[j] == '.') m[i+1][j+1] = 1;
    }
  }
  MAT3D(d,int,4,H+2,W+2);
  RREP(i,1,H+1) {
    RREP(j,1,W+1) {
      if (m[i][j] == 1) {
        d[0][i][j] = d[0][i][j-1] + 1;
        d[1][i][j] = d[1][i-1][j] + 1;
      }
      int ri = H+1-i, rj = W+1-j;
      if (m[ri][rj] == 1) {
        d[2][ri][rj] = d[2][ri][rj+1] + 1;
        d[3][ri][rj] = d[3][ri+1][rj] + 1;
      }
    }
  }
  int ans = 0;
  RREP(i,1,H+1) {
    RREP(j,1,W+1) {
      int t = d[0][i][j]+d[1][i][j]+d[2][i][j]+d[3][i][j];
      if (t > ans) ans = t;
    }
  }
  cout << ans - 3 << endl;
  return 0;
}


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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  string X;
  cin >> X;
  int cnt_s = 0, cnt_t = 0, ans = 0;
  for(int i = 0; i < X.size(); i++){
    if(X[i] == 'S')cnt_s++;
    else {
      if(cnt_s){
        cnt_s--;
        ans++;
      }
    }
  }
  cout << X.size() - 2 * ans << endl;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#define LL long long
using namespace std;
const LL mod=998244353;
LL n,m,a[310][310],cnt=0;
LL c[310][310];
LL Pow(LL a,LL b)
{
	LL ans=1;
	while(b)
	{
		if(b&1) ans=ans*a%mod;
		a=a*a%mod;b>>=1;
	}
	return ans;
}
int main()
{
	scanf("%lld %lld",&n,&m);
	for(LL i=1;i<=n;i++)
	{
		for(LL j=1;j<=m;j++) scanf("%lld",&a[i][j]);
		for(LL j=1;j<=m;j++)
		{
			if(!a[i][j]) continue;
			if(!c[j][j])
			{
				for(LL k=j;k<=m;k++) c[j][k]=a[i][k];
				cnt++;break;
			}
			else for(LL k=j;k<=m;k++) a[i][k]^=c[j][k];
		}
	}
	printf("%lld",(Pow(2,n)-Pow(2,n-cnt)+mod)%mod*Pow(2,m-1)%mod);
}

Measured memory_bytes: 1664
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>

using namespace std;


int main() {
	int i, j, k;
	long long x, y;

	cin >> x >> y;

	long long num = x;

	for (i = 1; num  <= y; i++) {
		num = num * 2;
	}
	i--;

	cout << i << endl;





	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
N = int(input())
dp = [ [] for _ in range(N+1)] 
mod = 10**9 +7

for s_len in range(N+1):
    for c1 in range(4):
        dp[s_len].append([])
        for c2 in range(4):
            dp[s_len][c1].append([0,0,0,0])
dp[0][3][3][3] = 1            

for s_len in range(N):
    for c4 in range(4):
        for c3 in range(4):
            for c2 in range(4):
                if dp[s_len][c2][c3][c4] == 0:
                    continue
                for c1 in range(4):
                    if c3 == 0 and c2 == 1 and c1 == 2:
                        continue
                    if c3 == 1 and c2 == 0 and c1 == 2:
                        continue
                    if c3 == 0 and c2 == 2 and c1 == 1:
                        continue
                    if c4 == 0 and c2 == 1 and c1 == 2:
                        continue
                    if c4 == 0 and c3 == 1 and c1 == 2:
                        continue
                    dp[s_len+1][c1][c2][c3] += dp[s_len][c2][c3][c4]
                    current_num = dp[s_len][c2][c3][c4]
                    dp[s_len+1][c1][c2][c3] = dp[s_len+1][c1][c2][c3]%mod

ans = 0

for c1 in range(4):
    for c2 in range(4):
        for c3 in range(4):
            ans += dp[N][c1][c2][c3]
            ans = ans%mod
print(ans)

Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<string>
#include<cstdlib>
using namespace std;
string s; 
int main(){
	cin>>s;
	cout<<s[0]<<s.length()-2<<s[s.length()-1]<<endl;
 	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#define QR (Q[i].rank)
#define QF (Q[i].file)

struct point{
	int rank;
	int file;
};

int min(int a, int b){
	return a < b ? a : b;
}

int max(int a, int b){
	return a > b ? a : b;
}

std::vector<point> EightQueen_Rec(std::vector<point> Queens){
	std::vector<std::vector<point> > Stack;
	Stack.push_back(Queens);
	std::vector<point> answer;
	while (!Stack.empty()){
		std::vector<point> Q = Stack.back();
		Stack.pop_back();
		bool isWrong = false;
		std::vector<std::vector<int> > Board(8, std::vector<int>(8, 0));
		for (int i = 0; i < (int)Q.size(); i++){
			if (Board[QR][QF] != 0){
				isWrong = true;
				break;
			}
			for (int j = 0; j < 8; j++){
				Board[QR][j] = i+1;
				Board[j][QF] = i+1;
			}
			for (int j = max(QF-QR, 0), k = QR-QF+j; j <= min(7+QF-QR, 7); j++, k++){
				Board[k][j] = i+1;
			}
			for (int j = max(QR+QF-7, 0), k = QR+QF-j; j <= min(QR+QF, 7); j++, k--){
				Board[k][j] = i+1;
			}
			Board[QR][QF] = i+9;
		}
		if (isWrong) continue;
		if ((int)Q.size() == 8){
			answer = Q;
			break;
		}
		int currentr;
		for (int i = 0; i < 8; i++){
			currentr = -1;
			for (int j = 0; j < 8; j++){
				if (Board[i][j] == 0){
					currentr = i;
					break;
				}
				if (Board[i][j] >= 9){
					currentr = 8;
					break;
				}
			}
			if (currentr >= 0 && currentr <= 7) break;
			if (currentr == -1){
				isWrong = true;
				break;
			}
		}
		if (isWrong) continue;
		for (int i = 0; i < 8; i++){
			if (Board[currentr][i] == 0){
				std::vector<point> Qnext = Q;
				point newQ;
				newQ.file = i; newQ.rank = currentr;
				Qnext.push_back(newQ);
				Stack.push_back(Qnext);
			}
		}
	}

	return answer;
}

int main(){
	int k, r, c;
	scanf("%d", &k);
	std::vector<point> Queens;
	for (int i = 0; i < k; i++){
		scanf("%d%d", &r, &c);
		point x;
		x.rank = r; x.file = c;
		Queens.push_back(x);
	}
	std::vector<point> result = EightQueen_Rec(Queens);

	for (int i = 0; i < 8; i++){
		for (int j = 0; j < 8; j++){
			bool isQueen = false;
			for (int k = 0; k < 8; k++){
				if (result[k].rank == i && result[k].file == j){
					isQueen = true;
					break;
				}
			}
			if (isQueen) printf("Q"); else printf(".");
		}
		printf("\n");
	}



	return 0;
}


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

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

typedef pair<int,int> P;

int bfs(int, int, int, int, char **);

int main()
{
	int w, h, sx, sy;
	char **map;

	while( cin >> w >> h && w > 0)
	{
		fflush(stdin);

		map = new char *[h];
		for(int f1 = 0; f1 < h; f1++)
		{
			map[f1] = new char [w+1];
			scanf("%s",map[f1]);
			for(int f2 = 0; f2 < w; f2++)
			{
				if(map[f1][f2] == '@')
				{
					sx = f2;
					sy = f1;
				}
			}
		}
		cout << bfs(w, h, sx, sy, map) << endl;
	}

	return 0;
}

int bfs(int w, int h, int sx, int sy, char **map)
{
	int px, py, cnt = 1;

	queue<P> que;
	que.push(P(sy,sx));
	while(!que.empty())
	{
		P p = que.front(); que.pop();
		for(int f1 = 0; f1 < 4; f1++)
		{
			py = p.first + dy[f1];
			px = p.second + dx[f1];
			if(px >= 0 && px < w && py >= 0 && py < h && map[py][px] == '.')
			{
				que.push(P(py,px));
				map[py][px] = '#';
				cnt++;
			}
		}
	}
	return cnt;
}

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

int main() {
    int n, x, check[105] = {0};
    cin >> x >> n;
    rep(i, n) {
        int tmp;
        cin >> tmp;
        check[tmp] = 1;
    }

    int ans, tmp = 1000;
    for(int i = 0; i <= 101; i++) {
        if(check[i] == 0) {
            if(abs(x - i) < tmp) {
                ans = i;
                tmp = abs(x - i);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3676
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    String[] line = br.readLine().split(" ");
    long[] a = new long[n];
    for(int i = 0; i < n; i++){
      a[i] = Long.parseLong(line[i]);
    }
    int k = 1 + (n%2);
    long[][] dp = new long[n + 1][k + 2];
    for(int i = 0; i <= n; i++){
      Arrays.fill(dp[i], Long.MIN_VALUE);
    }
    dp[0][0] = 0;

    for(int i = 0; i < n; i++){
      for(int j = 0; j <= k; j++){
        dp[i + 1][j + 1] = Math.max(dp[i + 1][j + 1], dp[i][j]);
        long temp = dp[i][j];
        if((i + j) % 2 == 0 && i >= j) {
          temp += a[i];
        }
        dp[i + 1][j] = Math.max(dp[i + 1][j], temp);
      }
    }
    System.out.println(dp[n][k]);
  }
}


Measured memory_bytes: 74932
'''
暗証番号3桁はたかだか10**3の候補。これを全探索で調べるだけ
pythonのindex関数を使用するとオブジェクト内に要素が存在しない場合エラーになる
'''
n = int(input())
s = [int(i) for i in input()]

def my_index(l,x,ind):
    '''
    l: イテラブル(for inで取り出せる)オブジェクト
    x: 探し出す大賞
    ind: イテラブルで探し始める位置（インデックス）
    返り値: 存在する場合はそのインデックス、存在しない場合は-1
    '''
    global n #入力のnと同一のものであるという意味
    if ind == n: #探索するものがない場合
        return -1
    for i in range(ind, n):
        if l[i] == x:
            return i
    else:
        return -1
c = 0
for i in range(10):
    x1 = my_index(s,i,0)
    if x1 != -1:
        for j in range(10):
            x2 = my_index(s,j,x1+1)
            if x2 != -1:
                for k in range(10):
                    x3 = my_index(s,k,x2+1)
                    if x3 != -1:
                        c += 1
print(c)

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

dateSet = [int(i) for i in input().split(" ")]

temp = sum(dateSet)

max = dateSet[0]
for i in range(N):
    if dateSet[i] < max:
        dateSet[i] = max
    else:
        max = dateSet[i]

print(sum(dateSet) - temp)


Measured memory_bytes: 32072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 +5;
const int MOD=1e9+7;
int a[N]={0},ans[N]={0};

int main(){
	string s;
	cin>>s;
	int n;
	if(s=="SUN")	n=7;
	else if(s=="MON")	n=6;
	else if(s=="TUE") 	n=5;
	else if(s=="WED") 	n=4;
	else if(s=="THU") 	n=3;
	else if(s=="FRI") 	n=2;
	else if(s=="SAT") 	n=1;
	printf("%d\n",n);
	return 0;
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

LL dx[] = {1, -1, 0, 0, -1, -1, 1, 1};
LL dy[] = {0, 0, 1, -1, -1, 1, -1, 1};

///**************************DONE****************************///

int x[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main()
{
    int k;
    cin >> k;
    
    cout << x[k - 1] << '\n';
    return 0;
}


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

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

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

    int a, b, c, x, count=0;
    int money;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> x;

    REP(i, a+1) REP(j, b+1) REP(k, c+1){
        money = 500*i + 100*j + 50*k;
        if (money == x) count++;
    }

    cout << count << "\n";
}

Measured memory_bytes: 256
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.List

add :: (Int,Int) -> (Int,Int) -> (Int,Int)
add (x,y) (z,w) = (x+z,y+w)

analyze :: Int -> VU.Vector (Int,Int) -> [Int] -> ((Int,Int),Int)
analyze d as xs = (sss, if xs == [0..d-1] then d else maximum $ ([0..d-1] \\ xs))
    where sss = foldl' add (0,0) [(100*(i+1)*(fst $ as VU.! i) + (snd $ as VU.! i),fst $ as VU.! i) | i <-xs]

fun :: (Int,Int) -> VU.Vector (Int,Int) -> Int -> ((Int,Int),Int) -> Int
fun (d,g) as n ((x,y),z) = if z == d then y
              else if g > x && n < first then fun (d,g) as (n+1) ((x+100*(z+1),y+1),z)
              else if g > x && n >= first then 2^20
              else y
              where first = fst $ as VU.! z


main :: IO ()
main = do
    (d,g) <- (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 readInt <$> BS.getLine
    as <- VU.replicateM d $ (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 readInt <$> BS.getLine
    print $ minimum $ map (fun (d,g) as 0) (map (analyze d as) (powerSet [0..d-1]))

powerSet :: [a] -> [[a]]
powerSet = filterM (\x -> [True,False]) 

readInt :: BS.ByteString -> Maybe (Int,BS.ByteString)
readInt xs = do
    (x,ys) <- BS.readInt xs
    return (x,BS.tail ys)

Measured memory_bytes: 1020
def searchDivisors(n):
    lstDivisors = []
    t = int(n ** .5)
    for a in range(1, t + 1):
        if n % a == 0:
            lstDivisors.append(a)
            b = n // a
            if b != a:
                lstDivisors.append(b)
    lstDivisors.sort()

    return lstDivisors


N = int(input())
ans = 0
lstDivisors = searchDivisors(N)


for k in lstDivisors:
    m = N // k - 1
    if k == m:
        continue
    if k > m:
        break
    ans += m


print(ans)

Measured memory_bytes: 38896
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }


int main() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    auto dp = make_v(n+1, k+1, 0);
    vector<int> sum(k+2, 0);
    dp[0][0] = 1;
    for (int i = 0; i < n; ++i) {
        int s = 0;
        for (int j = 0; j <= k; ++j) {
            (s += dp[i][j]) %= MOD;
            sum[j+1] = s;
        }
        for (int j = 0; j <= k; ++j) {
            (dp[i+1][j] = sum[j+1] - sum[max(0, j-v[i])]  + MOD) %= MOD;
        }
    }
    cout << dp[n][k] << "\n";
    return 0;
}


Measured memory_bytes: 40192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    string s;
    cin>>s;
    int c=s.length();
    if(c%2!=0) cout<<"No";
    else{
        int flag=0;
        for(int i=0;i<c;i++){
            if(i%2==0){
                if(s[i]!='h'){
                    flag=1;
                    break;
                }
            }
            else{
                if(s[i]!='i'){
                    flag=1;
                    break;
                }
            }
        }
        if(flag) cout<<"No";
        else cout<<"Yes";
    }
    return 0;
}

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

if __name__ == "__main__":
    N = int(input())
    A = int(input())
    # 500円玉無限枚なので、Nを500で割った余りが1円玉で払えるかを考える
    if (N%500) <= A:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 2940
#include <stdio.h>
#include <math.h>
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)
#define all(c) begin(c),end(c)
#define vmax(c) *max_element(all(c))
#define vmin(c) *min_element(all(c))
 
template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const long long INF = 0x3f3f3f3f3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9; 

// 多次元配列を作る
// vector<vi> my_vector(n, vi(m, 0));

// 多次元配列の dump
// for (vi v : my_vector) {
//     cout << v;
// }

auto solve() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(b / a, c);
}

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

    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

double d[100][10000];
int main(){
	int n,m,k;
	while(1){
		cin >> n >> m >> k;
		if(n==0&&m==0&k==0) break;
		REP(i,100) REP(j,10000) d[i][j] = 0;
		d[0][0] = 1.0;
		REP(i,n){
			REP(j,10000){
				// if(d[i][j]<0.00001) continue;
				FOR(p,1,m+1){
					d[i+1][j+p] += d[i][j]*(1.0/double(m));
				}
			}
		}
		double res = 0;
		REP(i,10000){
			 // if(d[n][i]!=0) cout << i << "  " << d[n][i] << endl;
			int num = max(i-k,1);
			res += d[n][i]*num;
		}
		cout << shosu(8) << res << endl;
	}
}

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

using namespace std;

int main(){
  int N,M,K; cin >> N >> M >> K;
  
  for( int k = 0; k <= N ; k++){
    for(int l = 0; l <= M ; l++){
      if( k * ( M - l ) + l * ( N - k) == K){ cout << "Yes" <<endl; return 0;}}}
    
    cout <<"No" <<endl; return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second

#define all(v) (v).begin(), (v).end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,b) FOR(i,0,b)
#define reps FOR
#define eb emplace_back
#define pb eb

template<class T> inline bool MX(T &l, const T &r) { return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l, const T &r) { return l>r?l=r,1:0;}

using LL = long long;
using pii = pair<int, int>;
using pll = pair<LL, LL>;

int N;
int M;
int mpy[514];
int mpx[514];
int ans[514][514];

void Ground(int s, int t, int y, int x, int b, int rot) {
  rep(k, rot) { 
    rep(i, 2) {
      rep(j, 2) {
        int ny[] = {1, 0, 1, 0};
        int nx[] = {0, 0, 1, 1};
        int idx = i*2 + j;
        ans[y*2+ny[idx]][x*2+nx[idx]] = ans[s*2+i][t*2+j];
      }
    }
  }
  
  rep(i, 2) {
    if (b >> i & 1) {
      swap(ans[y*2+i][x*2], ans[y*2+i][x*2+1]);
    }
  }
}

void Try(int idx, int st, int y, int x) {
  assert(x == mpy[y]);
  pii p(-1, -1);
  int fy = y;
  int i = 0;
  while (1) {
    int b = 0;
    if (i < 16) {
      b = st >> (2*i) & 3;
    }
    if (p.X != -1) assert(p == pii(y, y));
    bool upper = x < y;
    Ground(y, x, x, mpy[x], b, upper?3:1);
    if (fy == x) break;
    p = pii(x, x);
    tie(y, x) = pii(x, mpy[x]);
    ++i;
  }
}

void Construct(int idx) {
  int y = 0;
  int x = idx;
  rep(i, M) {
    mpy[y] = x;
    mpx[x] = y;
    y++;
    x++;
    y %= M;
    x %= M;
  }

  rep(y, M) {
    int x = mpy[y];
    if (ans[y*2][x*2]) continue;
  
    int lim = 256;
    rep(st, lim) {
      rep(i, 2) {
        rep(j, 2) {
          ans[y*2+i][x*2+j] = 4*idx+i*2+j;
        }
      }
      
      Try(idx, st, y, x);

      int cnt = 0;
      rep(i, 2) {
        rep(j, 2) {
          cnt += (ans[y*2+i][x*2+j] == 4*idx+i*2+j);
        }
      }
      if (cnt == 4) goto L_FOUND;
    }
    assert(0);
L_FOUND:
    continue;
  }
}

int main() {
  cin >> N;
  if (N == 1) {
    cout << "Yes" << endl;
    cout << "1" << endl;
    return 0;
  }

  if (N%2) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;

  M = N/2;
  rep(i, M) {
    rep(j, 2) {
      ans[i*2+j][i*2+j] = 1;
    }
    ans[i*2][i*2+1] = 2;
    ans[i*2+1][i*2] = 3;
  }

  reps(i, 1, M) {
    Construct(i);
  }
  rep(i, N) {
    rep(j, N) {
      if (j) cout << " ";
      cout << ans[i][j];
    }
    cout << endl;
  }
}



Measured memory_bytes: 4092
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long a = in.nextLong();
//            double b = in.nextDouble();
            String bStr = in.next();
            StringBuilder sb = new StringBuilder();
            int idx = bStr.indexOf('.');
            sb.append(bStr.substring(0, idx)).append(bStr.substring(idx + 1));
            long b1 = Long.parseLong(sb.toString());
            out.println(a * b1 / 100);
        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

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

    }

}

Measured memory_bytes: 33980
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
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() {
    int n,m;
    cin >> n >> m;
    vector<int>a(n);
    rep(i,m) {
        int k;
        cin >> k;
        rep(j,k) {
            int s;
            cin >> s;
            s--;
            a[s] |= 1<<i;
        }
    }
    int p = 0;
    rep(i,m) {
        int x;
        cin >> x;
        p |= x<<i;
    }
    int ans = 0;
    for(int s = 0;s<(1<<n);s++) {
        int t = 0;
        for(int i = 0;i<n;i++) {
            if(s>>i & 1) {
                t ^= a[i];
            }
        }
        if(t == p) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

class segtree{
public:
	static const int N=1<<18;
	int dp[1<<19];
	segtree(){
		memset(dp,0,sizeof(dp));
	}
	void init(){
		memset(dp,0,sizeof(dp));
	}
	void update(int k,int v){
		k+=N-1;
		dp[k]+=v;
		while(k>0){
			k=(k-1)/2;
			dp[k]=dp[k*2+1]+dp[k*2+2];
		}
	}

	int query(int a,int b,int k=0,int l=0,int r=N){
		if(b<=l || r<=a)return 0;
		if(a<=l && r<=b)return dp[k];
		int mid=(l+r)/2;
		int vl=query(a,b,k*2+1,l,mid);
		int vr=query(a,b,k*2+2,mid,r);
		return vl+vr;
	}
};

int n;
ll a[100005];
ll fa[100005];
int cnt[300005];
int sum[300005];
segtree seg;

bool C(int v){
	seg.init();
	memset(cnt,0,sizeof(cnt));
	memset(sum,0,sizeof(sum));
	for(int i=0;i<n;i++){
		if(a[i]>=v){
			fa[i]=1;
		}else{
			fa[i]=-1;
		}
	}
	for(int i=0;i<n;i++){
		sum[i+1]+=sum[i];
		sum[i+1]+=fa[i];
		cnt[sum[i+1]+n]++;
	}
	for(int i=2*n;i>=0;i--){
		cnt[i]+=cnt[i+1];
	}
	int rng=n;
	ll val=0;
	for(int i=0;i<n;i++){
		val+=(ll)cnt[rng]-seg.query(rng,n*2+1);
		seg.update(sum[i+1]+n,1);
		rng+=fa[i];
	}
	ll all=(ll)n*(n+1LL)/2LL;
	//printf("%d %lld %lld\n",v,all,val);
	return val>=(ll)(all+1)/2LL;
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}
	int l=0,r=1LL<<30;
	while(l+1<r){
		int mid=(ll)(l+r)/2LL;
		if(C(mid))l=mid;
		else r=mid;
	}
	printf("%d\n",l);
	return 0;
} 

Measured memory_bytes: 6144
import java.math.BigInteger;
import java.util.Scanner;
import java.util.*;
public class Main {
	public static void main(String[] args) {
		BigInteger a,b;
		Scanner cin=new Scanner(System.in);
		a=cin.nextBigInteger();
		b=cin.nextBigInteger();
		System.out.println(a.multiply(b));
	}
}



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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll count = 0;
    ll N, C, K;
    vector<ll> shomi;
    cin >> N >> C >> K;
    shomi.resize(N);
    rep(i, N) cin >> shomi[i];
    sort(shomi.begin(), shomi.end());
    while(shomi.size()) {
        ll temp = 0;
        ll current = shomi.front();
        auto end = upper_bound(shomi.begin(), shomi.end(), current + K);
        shomi.erase(shomi.begin(), min(end, shomi.begin() + C));
        count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    bool zero = false;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] == 0) {
            zero = true;
        }
    }
    
    if(zero) {
        cout << 0 << endl;
        return 0;
    }
    
    boost::multiprecision::cpp_int ans = a[0];
    for (int i = 1; i < n; i++) {
        ll nxt = a[i];
        ans *= nxt;
        if (ans > 1000000000000000000) {
            cout << -1 << endl;
            return 0;            
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

int main() {
    fastIO;
    int n;
    cin >> n;

    int total = 0;
    vector<int> times;
    rep(_, n) {
        int time;
        cin >> time;
        times.push_back(time);
        total += time;
    }

    int m;
    cin >> m;

    while (m--) {
        int idx, stimulation;
        cin >> idx >> stimulation;
        cout << (total - times[idx - 1] + stimulation) << endl;
    }
}

Measured memory_bytes: 3636
n = int(input())
h = tuple(map(int, input().split()))
dp = [0]*n
dp[1] = abs(h[1] - h[0])
for i in range(2,n):
    dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]))
print(dp[-1])


Measured memory_bytes: 14108
<?php
fscanf(STDIN, "%s", $a);

if ($a == 'A') {
    echo 'T';
} else if ($a == 'C') {
    echo 'G';
} else if ($a == 'G') {
    echo 'C';
} else if ($a == 'T') {
    echo 'A';
}

Measured memory_bytes: 3828
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    var (a, b) = readLongList()
    var count = b - a + 1
    val tmpa = if (a % 2 == 1L) {
        count--
        a
    } else {
        0
    }
    val tmpb = if (b % 2 == 0L) {
        count--
        b
    } else {
        0
    }
    val tmpc = if ((count / 2) % 2 == 0L) 0L else 1L
    out.println(tmpa xor tmpb xor tmpc)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 37856
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

int main(){


	int W,D;
	while(true){
		scanf("%d %d",&W,&D);
		if(W == 0 && D == 0)break;

		int table_W[W],table_D[D];
		bool check_W[W],check_D[D];


		for(int i = 0; i < W; i++)check_W[i] = false;
		for(int i = 0; i < D; i++)check_D[i] = false;

		for(int i = 0; i < W; i++){
			scanf("%d",&table_W[i]);
		}

		for(int i = 0; i < D; i++){
			scanf("%d",&table_D[i]);
		}

		//?????????sort
		for(int i = W-2; i >= 0; i--){
			for(int k = 0; k <= i; k++){
				if(table_W[k] < table_W[k+1])swap(table_W[k],table_W[k+1]);
			}
		}

		for(int i = D-2; i >= 0; i--){
			for(int k = 0; k <= i; k++){
				if(table_D[k] < table_D[k+1])swap(table_D[k],table_D[k+1]);
			}
		}

		int sum = 0;

		for(int i = 0; i <= W-1; i++){
			for(int k = 0; k <= D-1; k++){
				if(table_W[i] > table_D[k])break;
				if(table_W[i] == table_D[k] && check_D[k] == false){
					check_W[i] = true;
					check_D[k] = true;
					sum += table_W[i];
					break;
				}
			}
		}

		for(int i = 0; i < W; i++){
			if(check_W[i] == false){
				sum += table_W[i];
			}
		}

		for(int k = 0; k < D; k++){
			if(check_D[k] == false){
				sum += table_D[k];
			}
		}

		printf("%d\n",sum);
	}

	return 0;
}

Measured memory_bytes: 2572
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

const int MAX = 2000000 ;

//宣言するときはstaticをつけて静的変数にするかグローバル変数として宣言
class SGT{
public :
	int n ;
//	d変数は単位元、計算の邪魔をしない値に設定する、INFや0など
	int d = 0 ;
	int num[MAX] ;

	void init(vector<ll> &a){
		n = 1 ;
		while(a.size()>n) n *= 2 ;
		for(int i=0;i<n;i++){
			if(i<a.size()) num[n-1+i] = a.at(i) ;
			else num[n-1+i] = d ;
		}
		for(int i=n-2;i>=0;i--){
			num[i] = num[i*2+1]+num[i*2+2] ;
		}
	}

//	内容次第でwhile内の計算式を書き換える
	void update(int i,int a){
		i += n-1 ;
		num[i] = a ;
		while(i>0){
			i = (i-1)/2 ;
			num[i] = num[i*2+1]+num[i*2+2] ;
		}
	}

	int query(int a,int b,int l,int r,int now){
		if(r<=a||b<=l) return d ;
		if(a<=l&&r<=b) return num[now] ;
		int r1 = query(a,b,l,(l+r)/2,now*2+1) ;
		int r2 = query(a,b,(l+r)/2,r,now*2+2) ;
		return r1+r2 ;
	}
};

int main(){
	ll n,k ;
	cin >> n >> k ;
	vll a(n) ;
	for(auto &i:a) cin >> i ;
	vll sum(n+1,0) ;
	for(int i=1;i<=n;i++) sum.at(i) += sum.at(i-1)+a.at(i-1)-k ;
	vll sub = sum ;
	sort(all(sub)) ;
	map<ll,ll> m ;
	ll pre = INF ;
	ll cnt = 0 ;
	for(int i=0;i<sub.size();i++){
		if(sub.at(i)!=pre) m[sub.at(i)]=cnt,cnt++ ;
		pre = sub.at(i) ;
	}
	vll zero(m.size(),0) ;
	zero.at(m[0]) = 1 ;
	static SGT sgt ;
	sgt.init(zero) ;
//	for(int i=0;i<sgt.n;i++) cout << sgt.num[i+sgt.n-1] << " " ; cout << endl ;
	ll ans = 0 ;
	for(int i=1;i<sum.size();i++){
		ans += sgt.query(0,m[sum.at(i)]+1,0,sgt.n,0) ;
//		cout << sum.at(i) << " " << sgt.query(0,m[sum.at(i)]+1,0,sgt.n,0) << endl ;
//		cout << m[sum.at(i)] << endl  ;
//		cout << sgt.query(0,1,0,sgt.n,0) << " " << sgt.query(0,2,0,sgt.n,0) << endl ;
//		for(auto p:m) cout << p.first << "(" << sgt.num[p.second+sgt.n-1] << ") " ; cout << endl ;
		sgt.update(m[sum.at(i)],sgt.num[m[sum.at(i)]+sgt.n-1]+1) ;
//		cout << ans << endl ;
	}
	cout << ans << endl ;
//	for(auto p:m) cout << p.first << " " << p.second << endl ;
}


Measured memory_bytes: 23040
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<cstdint>
#include<cstddef>
#include<vector>
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using usize = uint_fast64_t;
#define rep(i, n) for (usize i = 0; i < (usize)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;
using i64 = int_fast64_t;
constexpr i64 MAX = 10000000;
constexpr i64 MOD = 1000000007;
i64 fac[MAX], finv[MAX], inv[MAX];
template <i64 modulus>
class modcal
{

public:
  i64 a;

  constexpr modcal(const i64 x = 0) noexcept : a(x % modulus) {}
  constexpr i64 &value() noexcept { return a; }
  constexpr const i64 &value() const noexcept { return a; }
  constexpr modcal operator+(const modcal rhs) const noexcept
  {
    return modcal(*this) += rhs;
  }
  constexpr modcal operator-(const modcal rhs) const noexcept
  {
    return modcal(*this) -= rhs;
  }
  constexpr modcal operator*(const modcal rhs) const noexcept
  {
    return modcal(*this) *= rhs;
  }
  constexpr modcal operator/(const modcal rhs) noexcept
  {
    return modcal(*this) /= rhs;
  }
  constexpr modcal &operator+=(const modcal rhs) noexcept
  {
    a += rhs.a;
    if (a >= modulus)
    {
      a -= modulus;
    }
    return *this;
  }
  constexpr modcal &operator-=(const modcal rhs) noexcept
  {
    if (a < rhs.a)
    {
      a += modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modcal &operator*=(const modcal rhs) noexcept
  {
    a = a * rhs.a % modulus;
    return *this;
  }
  constexpr modcal &operator/=(modcal rhs) noexcept
  {
    i64 exp = modulus - 2;
    while (exp)
    {
      if (exp % 2)
      {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }

  void COMninit()
  {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
      fac[i] = fac[i - 1] * i % modulus;
      inv[i] = MOD - inv[modulus % i] * (modulus / i) % modulus;
      finv[i] = finv[i - 1] * inv[i] % modulus;
    }
  }
  i64 COMn(i64 n, i64 k)
  {
    if (n < k)
      return 0;
    if (n < 0 || k < 0)
      return 0;
    return fac[n] * (finv[k] * finv[n - k] % modulus) % modulus;
  }
  constexpr modcal<1000000007> modpow(const modcal<1000000007> &a, i64 n)
  {
    if (n == 0)
      return 1;
    auto t = modpow(a, n / 2);
    t = t * t;
    if (n & 1)
      t = t * a;
    return t;
  }
};
using modc = modcal<1000000007>;
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
i64 n;
cin >> n;
vector<i64> a(n),sum(n + 1);
rep(i,n){
    cin >> a[i];
    sum[i + 1] = sum[i] + a[i];
}
modc ans = 0;
rep(i,n - 1){
    ans += (sum[n] - sum[i + 1]) % MOD * a[i];
}
cout << ans.a << endl;
}

Measured memory_bytes: 6348
/* ex7_1
saitomo*/
#include<stdio.h>



//頂点を表す構造体point を定義
typedef struct point{
    int x_elem;
    int y_elem;
}point;
//プロトタイプ宣言
point shift_point(point vec1,point vec2);

int main(void){
    point vec1,vec2,vec3,vec4;
    scanf("%d%d%d%d",&vec1.x_elem,&vec1.y_elem,&vec2.x_elem,&vec2.y_elem);
    vec3=shift_point(vec1,vec2);
    vec4=shift_point(vec2,vec3);
    printf("%d %d %d %d\n",vec3.x_elem,vec3.y_elem,vec4.x_elem,vec4.y_elem);
    return 0;
}

//点を移動させる関数を定義
point shift_point(point vec1,point vec2){
    point new_vec;
    new_vec.x_elem=vec2.x_elem-vec1.x_elem;//とりあえず計算に使う値を代入しておく
    new_vec.y_elem=vec2.y_elem-vec1.y_elem;
    new_vec.y_elem=new_vec.x_elem+vec2.y_elem;
    new_vec.x_elem=vec2.x_elem-(new_vec.y_elem-new_vec.x_elem-vec1.y_elem);
    //図を描くことで計算式を求めた
    return new_vec;//ポイントとして出力
}


Measured memory_bytes: 1728