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

using namespace std;

int main()
{
    long long sol = 0;
    int n;
    cin >> n;

    if(n == 1){
        cout << 1 << endl;
        exit(0);
    }

    vector<int> seq;

    for(int i = 0; i < n; i++){
        int ai;
        cin >> ai;
        seq.push_back(ai);
    }

    long long cur_xor = seq[0];
    long long cur_sum = seq[0];
    int a = 0;
    int b = 0;
    bool geht = true;

    while(b < n-1){
        if(geht){
            while(geht && b < n-1){
                b++;
                sol += b-a;
                cur_xor ^= seq[b];
                cur_sum += seq[b];

                geht = (cur_xor == cur_sum);

                /*if(geht){
                    sol += b-a+1;
                }*/
            }

            if(b == n-1){
                 while(!geht){
                    a++;
                    cur_xor ^= seq[a-1];
                    cur_sum -= seq[a-1];

                    geht = (cur_xor == cur_sum);
                }
                sol += b-a+1;
            }

            /*if(b == n-1 && geht){
                sol += (pow(2,b-a+1)+b-a+1)/2;
            }
            else{
                sol += (pow(2,b-a)+b-a)/2;
            }*/
        }
        else{
            while(!geht){
                a++;
                cur_xor ^= seq[a-1];
                cur_sum -= seq[a-1];

                geht = (cur_xor == cur_sum);
            }
        }
    }

    cout << sol << endl;

    return 0;
}


Measured memory_bytes: 1400
def main():
    n, k = [int(x) for x in input().split()]
    letters = []
    for _ in range(n):
        letters.append(input()[0])
    alphabet = [0 for _ in range(26)]
    for letter in letters:
        alphabet[ord(letter) - 65] += 1
    alphabet.sort(reverse=True)
    num_contests = 0
    picked = 0
    idx = 0
    while idx < 26:
        if alphabet[idx] > 0:
            picked += 1
            alphabet[idx] -= 1
        if picked == k:
            num_contests += 1
            picked = 0
            idx = -1
            alphabet.sort(reverse=True)
        idx += 1
    print(num_contests)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3184
l,r = map(int,input().split())

ans = 2019
#差が2018より大きいものは商が必ず1以上になるので、計算の量を減らす
if r - l >= 2018:
  print(0)
else:
  #for文でその他全て計算する
  for i in range(l,r):
    for j in range(i + 1 ,r + 1):
      #余りの最小値を求める
      ans  = min(ans, (i * j) % 2019)
  print(ans)

Measured memory_bytes: 2940
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

ll func(ll n){
    return n*(n-1)/2;
}

int main(){
    int n; cin>>n;
    vector<int> a(n);
    vector<int> c(n,0);
    for(int i=0;i<n;i++){
        cin>>a[i];
        c[a[i]-1]++;
    }
    ll sum=0;
    for(int i=0;i<n;i++){
        sum+=func(c[i]);
    }
    for(int i=0;i<n;i++){
        ll ans=sum;
        ans-=func(c[a[i]-1]);
        ans+=func(c[a[i]-1]-1);
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 4096
#include <iostream>

using namespace std;

int cell[10][10];

int main() {
  int x, y, size;
  int max = 0, zero = 0;

  while (cin >> x) {
    cin.ignore();
    cin >> y;
    cin.ignore();
    cin >> size;

    switch (size) {
      case 3:
        if(x >= 2)
          cell[x-2][y]++;
        if(y >= 2)
          cell[x][y-2]++;
        if(x <= 7)
          cell[x+2][y]++;
        if(y <= 7)
          cell[x][y+2]++;
      case 2:
        if(x >= 1){
          if(y >= 1)
            cell[x-1][y-1]++;
          if(y <= 8)
            cell[x-1][y+1]++;
          }
        if(x <= 8){
          if(y >= 1)
            cell[x+1][y-1]++;
          if(y <= 8)
            cell[x+1][y+1]++;
        }
      case 1:
        if(x >= 1)
          cell[x-1][y]++;
        if(x <= 8)
          cell[x+1][y]++;
        if(y >= 1)
          cell[x][y-1]++;
        if(y <= 8)
          cell[x][y+1]++;
        cell[x][y]++;
    }
  }

  for(int i = 0; i < 10; i++)
    for(int j = 0; j < 10; j++){
      if(!cell[i][j])
        zero++;
      else if(cell[i][j] > max)
        max = cell[i][j];
    }

  cout << zero << endl << max << endl;

}

Measured memory_bytes: 1160
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int height = sc.nextInt();
    int width = sc.nextInt();
    String image = "";
    for(int i = 0; i < height; i++){
        image = sc.next();
        System.out.println(image);
        System.out.println(image);
    }
  }
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int main()
{
    char c;
    cin >> c;
    if ('A' <= c && c <= 'Z')
    {
        cout << "A" << endl;
    }
    else
    {
        cout << "a" << endl;
    }

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define xmod int(1e9+7)
#define hmod 1223334444555553LL
using namespace std;

ll n,a[55],y,sum1;
double ans;
int main(){
	scanf("%lld",&n); 
	for (int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+1+n);
	ans=(a[1]+a[2])/2.0;
	for (int i=3;i<=n;i++){
		ans=(ans+a[i])/2.0;
	}
	printf("%.6lf\n",ans);	
	return 0;
} 

Measured memory_bytes: 256
import sys
import math
from collections import defaultdict, deque
from copy import deepcopy
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    H, W = MI()
    sx, sy = MI()
    gx, gy = MI()
    sx-=1
    sy-=1
    gx-=1
    gy-=1
    
    mylist = [input().rstrip() for i in range(H)]
    dist = Init(H, W, float('inf'))
    #dist2 = Init(H, W, float('inf'))
    dq = deque()
    dq2 = deque()
    dq.append((sx, sy))
    move1 = [[1,0],[0,1],[-1,0],[0,-1]]
    move2 = [[i,j] for i in range(-2,3) for j in range(-2,3) if not [i, j ] in move1 and [i, j] != [0, 0]]
    dist[sx][sy] = 0
    while dq:
        x, y = dq.pop()
        #コスト1の移動
        for x2, y2 in move2:
            x2 += x
            y2 += y
            if x2 >= 0 and x2 < H and y2 >= 0 and y2 < W and mylist[x2][y2] == "." and dist[x2][y2] > dist[x][y]+1:
                dist[x2][y2] = dist[x][y]+1
                dq2.append((x2,y2))

        #コスト0の移動
        for x2, y2 in move1:
            x2 += x
            y2 += y
            if x2 >= 0 and x2 < H and y2 >= 0 and y2 < W and mylist[x2][y2] == "." and dist[x2][y2] > dist[x][y]:
                dist[x2][y2] = dist[x][y]
                dq.append((x2,y2))
                
        if not dq:
            dq = dq2
            dq2 = deque()
        
    
    if dist[gx][gy] == float('inf'):
        print(-1)
    else:
        print(dist[gx][gy])
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 103712
from collections import deque
import copy

h,w=map(int,input().split())
ss=[list(input()) for i in range(h)]

ans=0

for hh in range(h):
 for ww in range(w):
  dist=[[-1]*(w+1) for i in range(h+1)]
  c=copy.deepcopy(ss)
  xx=c[hh][ww]
  if xx=='#':
   continue
  dist[hh][ww]=0
  dq=deque()
  dq.append((hh,ww))
  c[hh][ww]='#'
  while dq:
   y,x=dq.popleft()
   for dx,dy in [[1,0],[-1,0],[0,1],[0,-1]]:
    nx=x+dx
    ny=y+dy
    if 0<=nx<w and 0<=ny<h and c[ny][nx]!='#':
     dq.append((ny,nx))
     c[ny][nx]='#'
     dist[ny][nx]=dist[y][x]+1
  for i in dist:
   ans=max(ans,max(i))
print(ans)

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

int main() {
    int N; cin >> N;
    vector<pair<int, int>> v(N);
    for (int i = 0; i < N; i++) {
        cin >> v[i].first;
        v[i].second = i;
    }
    sort(v.begin(), v.end());
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (v[i].second % 2 ^ i % 2) ans++;
    }
    cout << ans / 2 << endl;
    return 0;
}

Measured memory_bytes: 1024
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
sc = 0
te = []
for i in range(k):
    if t[i] == 'r':
        te.append('p')
        sc += p
    elif t[i] == 's':
        te.append('r')
        sc += r
    elif t[i] == 'p':
        te.append('s')
        sc += s
for i in range(k, n-k):
    if t[i] == 'r':
        if te[i-k] != 'p':
            te.append('p')
            sc += p
        else:
            if t[i+k] == 'r':
                te.append('r')
            elif t[i+k] == 's':
                te.append('s')
            elif t[i+k] == 'p':
                te.append('r')
    elif t[i] == 's':
        if te[i-k] != 'r':
            te.append('r')
            sc += r
        else:
            if t[i+k] == 'r':
                te.append('s')
            elif t[i+k] == 's':
                te.append('s')
            elif t[i+k] == 'p':
                te.append('p')
    elif t[i] == 'p':
        if te[i-k] != 's':
            te.append('s')
            sc += s
        else:
            if t[i+k] == 'r':
                te.append('r')
            elif t[i+k] == 's':
                te.append('p')
            elif t[i+k] == 'p':
                te.append('r')
for i in range(n-k, n):
    if t[i] == 'r':
        if te[i-k] != 'p':
            sc += p
    elif t[i] == 's':
        if te[i-k] != 'r':
            sc += r
    elif t[i] == 'p':
        if te[i-k] != 's':
            sc += s
print(sc)

Measured memory_bytes: 49008
using System;
using System.Collections.Generic;

namespace ITP1_7_C
{
	class Program
	{
		private static int r = 0;
		private static int c = 0;

		static void Main(string[] args)
		{
			// サイズ入力
			InputSize();

			// 表入力
			List<List<int>> vs = new List<List<int>>();
			InputTable(vs);

			// 合計計算
			CalcTotal(vs);

			// 出力
			Output(vs);
		}

		// サイズ入力
		static void InputSize()
		{
			string[] vs = Console.ReadLine().Split(' ');
			r = int.Parse(vs[0]);
			c = int.Parse(vs[1]);
		}

		// 表入力
		static void InputTable(List<List<int>> list)
		{
			for(int i = 0; i < r; i++) {
				string[] vs = Console.ReadLine().Split(' ');

				List<int> row = new List<int>();
				foreach(string v in vs) {
					row.Add(int.Parse(v));
				}

				list.Add(row);
			}
		}

		// 合計計算
		static void CalcTotal(List<List<int>> list)
		{
			// 合計行の作成
			List<int> total = new List<int>();
			for(int i = 0; i < c + 1; i++) {
				total.Add(0);
			}

			for(int i = 0; i < r + 1; i++) {
				if(i < r) {
					// 行毎の合計計算
					int cTotal = 0;
					for(int j = 0; j < c; j++) {
						cTotal += list[i][j];
						total[j] += list[i][j];
					}

					// 合計列追加
					list[i].Add(cTotal);
					total[c] += cTotal;
				}

				// 合計行追加
				if(i == r - 1) {
					list.Add(total);
				}
			}
		}

		// 表示
		static void Output(List<List<int>> vs)
		{
			foreach(List<int> row in vs) {
				bool first = true;
				foreach(int v in row) {
					if(!first) {
						Console.Write(" ");
					}
					Console.Write(v);
					first = false;
				}
				Console.WriteLine();
			}
		}
	}
}



Measured memory_bytes: 17932
N = int(input())
h = 0
n = 0
w = 0
for i in range(1,3501):
    if h !=0:
        break
    else:
        for j in range(1,3501):
            if 4*i*j-N*(i+j) > 0:
                if (N*i*j)%(4*i*j-N*(i+j)) == 0:
                    h = i
                    n = j
                    w = (N*i*j)//(4*i*j-N*(i+j))
                    break
print(h,n,w)

Measured memory_bytes: 3188
from itertools import count, takewhile
from math import floor, sqrt

n = int(input())
xys = [map(int, input().split()) for _ in range(n)]

def mysqrt(n):
    x = floor(sqrt(n))
    for x in takewhile(lambda x: x**2 <= n, count(max(0, x-2))):
        pass
    return x

for x, y in xys:
    xy = x*y
    root = mysqrt(xy-1)
    ans = root*2 - (root**2 + root >= xy) - 1 + (x == y)
    print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
     ios_base::sync_with_stdio(0);
     cin.tie(0);
     int n,i,a;
     cin>>n;
	 vector<pair<int,int>>v(n);
	 for(i=0;i<n;i++)
	 {
		 cin>>a;
		 v[i]={a,i+1};
	 }
	 sort(v.begin(),v.end());
	 for(i=0;i<(int)v.size()-1;i++)
		 cout<<v[i].second<<" ";
	 cout<<v[i].second<<'\n';
}


Measured memory_bytes: 1664
#include <iostream>

using namespace std;

//const int MAXN = 10000500;
//const int MAXN = 50;
//const int MAXVALUE = 1000000500;
//const long double EPS = 1e-7;

unsigned int check(unsigned int x) {
	unsigned int y = x;
	for (int i = 3; i < x; i += 2) {
		if (x % i == 0) {
			y = i;
			break;
		}
	}
	return y;
}

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

	int n = 0;
	cin >> n;

	long long int res = 0;

	for (int i = 1; i <= n; ++i) {
		if (i % 3 != 0 && i % 5 != 0) {
			res += i;
		}
	}

	cout << res << endl;
	

	

	//system("pause");
	return 0;
}
	
	


Measured memory_bytes: 3164
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

enum Face
{
	TOP = 0,
	FRONT = 1,
	RIGHT = 2,
	LEFT = 3,
	BACK = 4,
	BOTTOM = 5,
};

class Dice
{
private:
	vector<int> f;

	void alignTopFront(int top, int front)
	{
		if (top != f[TOP])
		{
			if (top == f[FRONT])
			{
				roll("N");
			}
			else if (top == f[RIGHT])
			{
				roll("W");
			}
			else if (top == f[LEFT])
			{
				roll("E");
			}
			else if (top == f[BACK])
			{
				roll("S");
			}
			else if (top == f[BOTTOM])
			{
				roll("NN");
			}
			else
			{

			}
		}
		if (front == f[FRONT])
		{

		}
		else if (front == f[RIGHT])
		{
			roll("WSE");
		}
		else if (front == f[LEFT])
		{
			roll("ESW");
		}
		else if (front == f[BACK])
		{
			roll("WSSE");
		}
		else
		{

		}
	}

public:
	Dice(vector<int> &fi)
	{
		f.resize(6, 0);
		copy(fi.begin(), fi.end(), f.begin());
	}

	void roll(string cmd)
	{
		int tmp;
		for (int i = 0; i < cmd.size(); i++)
		{
			switch (cmd[i])
			{
			case 'E':
				tmp = f[TOP];
				f[TOP] = f[LEFT];
				f[LEFT] = f[BOTTOM];
				f[BOTTOM] = f[RIGHT];
				f[RIGHT] = tmp;
				break;
			case 'N':
				tmp = f[TOP];
				f[TOP] = f[FRONT];
				f[FRONT] = f[BOTTOM];
				f[BOTTOM] = f[BACK];
				f[BACK] = tmp;
				break;
			case 'S':
				tmp = f[TOP];
				f[TOP] = f[BACK];
				f[BACK] = f[BOTTOM];
				f[BOTTOM] = f[FRONT];
				f[FRONT] = tmp;
				break;
			case 'W':
				tmp = f[TOP];
				f[TOP] = f[RIGHT];
				f[RIGHT] = f[BOTTOM];
				f[BOTTOM] = f[LEFT];
				f[LEFT] = tmp;
				break;
			default:
				break;
			}
		}
	}

	bool isIdenticalTo(Dice d)
	{
		for (int i = 0; i < 6; i++)
		{
			for (int j = 0; j < 6; j++)
			{
				if (f[i] != d.f[j])
				{
					this->alignTopFront(f[i], d.f[j]);
					d.alignTopFront(f[i], d.f[j]);
					if (this->f == d.f)
					{
						return true;
					}
				}
			}
		}
		return false;
	}
};

int main()
{
	vector<int> fi(6);
	for (int i = 0; i < 6; i++)
	{
		cin >> fi[i];
	}
	Dice d1(fi);
	for (int i = 0; i < 6; i++)
	{
		cin >> fi[i];
	}
	Dice d2(fi);
	if (d2.isIdenticalTo(d1))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}


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


int main(){
    ll n,k,q;
    cin >> n >> k >> q;
    vector<ll> a(q+1,0);
    for(int i = 1; i<=q; i++){
        cin >> a.at(i);
    }

    vector<ll> point(n+1,k-q);

    for(int i= 1; i<= q; i++){
        point.at(a.at(i))++;
    }

    for(int i = 1; i<= n; i++){
        if(point.at(i) >0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;

        }
    }
    
}

Measured memory_bytes: 2176
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) {
            System.out.println(a);
        } else {
            System.out.println(a - 1);

        }
    }
}

Measured memory_bytes: 20948
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    vi a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(all(a));
    cout << abs(a[0]-a[1]) + abs(a[1]-a[2]) << endl;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long double ld;
typedef long long ll;

int32_t main() {
    IOS;
    ll t;
    // cin>>t;
    t=1;
    while(t--) {
        ll n,w;
        cin>>n>>w;
        ll dp[n+1][w+1];
        ll wa[n],v[n];
        for(int i=0;i<n;i++) {
            cin>>wa[i]>>v[i];
        }
        for(int i=0;i<=n;i++) {
            for(int j=0;j<=w;j++) {
                if(i==0 || j==0) dp[i][j]=0;
                else if(j-wa[i-1]<0) dp[i][j] = dp[i-1][j];
                else {
                    dp[i][j] = max(dp[i-1][j], v[i-1] + dp[i-1][j - wa[i-1]]);
                }
            }
        }
        cout<<dp[n][w]<<endl;
    }
    return 0;
}

Measured memory_bytes: 82376
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>
#include <bitset>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

vector<long long int> E[6000];

int s[6000];
int used[6000];
int cnt1 = 0, cnt2 = 0;

long long int DP[5100][5100];

bool func(int pos, bool odd){
	if(used[pos] != 0){
		if(used[pos] == 1 && !odd || used[pos] == -1 && odd){
			return false;
		}
		return true;
	}
	if(odd){
		cnt1 += 1;
		used[pos] = 1;
	}else{
		cnt2 += 1;
		used[pos] = -1;
	}
	for(int to : E[pos]){
		bool ret = func(to, !odd);
		if(!ret){
			return false;
		}
	}
	return true;
}

int main(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> s[i];
	}
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++){
			if(s[i] > s[j]){
				E[i].push_back(j);
				E[j].push_back(i);
			}
		}
	}
	DP[0][0] = 1;
	for(int i = 0; i < n; i++){
		if(used[i] == 0){
			int preS = cnt1 + cnt2;
			int pre1 = cnt1;
			int pre2 = cnt2;
			bool ret = func(i, true);
			if(!ret){
				cout << 0 << endl;
				return 0;
			}
			int d1 = cnt1 - pre1;
			int d2 = cnt2 - pre2;
			for(int i = 0; i <= preS; i++){
				if(i + d1 < 5100 && preS - i + d2 < 5100){
					DP[i + d1][preS - i + d2] += DP[i][preS - i];
					DP[i + d1][preS - i + d2] %= MOD;
				}
				if(i + d2 < 5100 && preS - i + d1 < 5100){
					DP[i + d2][preS - i + d1] += DP[i][preS - i];
					DP[i + d2][preS - i + d1] %= MOD;
				}
			}
		}
	}
	long long int ans = 0;
	for(int i = n - m; i <= m; i++){
		ans += DP[i][n - i];
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}



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



int main(){
    int a,b,c ,ans,kaketa, sqo;
    cin >>a>>b;
    c=b;

    int i=0;

    while(c>0){
        i++;
        c=c/10;
    }

    kaketa=pow(10,i);

    ans=a*kaketa+b;


        sqo=sqrt(ans);

    if(ans==sqo*sqo)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;

}

Measured memory_bytes: 384
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <queue>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#define local
#ifdef local
    #include "dbg-macro/dbg.h"
#endif
//#define hacks
#ifdef hacks
    #include <boost/multiprecision/cpp_int.hpp>
#endif
#define p std::pair
#define ll long long
#define ld long double
#define ull unsigned long long
#define pi std::pair<int, int>
#define stdabs std::abs
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
#define vec std::vector
#define oreq |=
#define npm next_permutation
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
ll extgcd(ll a, ll b, ll& x, ll& y);
ll nCr(ll n, ll r);
void stat();
template <typename T> T fact(T num);
constexpr ll mod = 1000000000 + 7;
int main()
{
    stat();
    ull a;
    double b;cin>>a>>b;
    int c=100*b+0.5;
    a*=c;
    a/=100;
    cout<<a<<endl;
    return 0;
}
ll extgcd(ll a, ll b, ll& x, ll& y)
{
    if (b == 0) {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) {
        is_prime[i] = true;
    }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++) {
        if (is_prime[i]) {
            for (unsigned ll j = 2 * i; j <= N; j += i) {
                is_prime[j] = false;
            }
            P.emplace_back(i);
        }
    }
    return P;
}

void stat(){
#ifdef local
    rep(i, 2){std::cout << "local enable" << std::endl;
}
#endif
#ifdef hacks
rep(i, 2) { std::cout << "boost enable" << std::endl; }
#endif
}

ll nCr(ll n, ll r)
{
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

template <typename T> T fact(T num)
{
    if (num == 1) { return 1; }
    return num * fact(num - 1);
}


Measured memory_bytes: 3688
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

constexpr int oo = 2.1e9;

int main() {
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<int, int>> a;
    for (int i = 0; i < n; i++) {
        int h, p;
        cin >> h >> p;
        a.emplace_back(h, p);
    }
    sort(begin(a), end(a),
         [&](auto x, auto y) {
             return x.first + x.second < y.first + y.second;
         });
    vector<int> dp(n + 1, oo);
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        auto h = a[i].first;
        auto p = a[i].second;
        for (int j = i; j >= 0; j--) {
            if (dp[j] <= h) {
                dp[j + 1] = min(dp[j + 1], dp[j] + p);
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (dp[i] < oo) {
            ans = i;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
 
using namespace std;
 
const int N = 2e5 + 10;
const int limit = 1e5 + 1;
 
int a[N], n;
long long res;
 
struct Fenwick_Tree {
	int s[N];
	void clear() {memset(s, 0, sizeof(s));}
	void update(int x, int y) {for(; x <= n + limit; x += x & -x) s[x] += y;}
	int query(int x) {int res = 0; for(; x; x -= x & -x) res += s[x]; return res;}
}T;
 
bool check(int x) {
	int sum = limit; res = 0;
	T.clear(); T.update(sum, 1);
	for(int i = 1; i <= n; ++ i) {
		sum += a[i] >= x ? 1 : -1;
		res += T.query(sum);
		T.update(sum, 1);
	}
	long long tot = 1ll * n * (n + 1) / 2;
	return res > (tot - (tot / 2 + 1));
}
 
int main() {
	int ans, l = 1, r = 1e9;
	scanf("%d", &n);
	for(int i = 1; i <= n; ++ i)
		scanf("%d", &a[i]);
	while(l <= r) {
		int mid = (l + r) >> 1;
		if(check(mid)) ans = mid, l = mid + 1;	
		else r = mid - 1;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int) N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=(int) n;i--)
#define p(s) cout<<(s)<<endl
#define DEBUG(x,y) cout<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl;
#define CK(n,a,b) ((a)<=(n)&&(n)<=(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf=1e9+7;

string s,t;
int cnt;
string tmp="";
int main(){
	cin>>s>>t;
	REP(i,0,s.size()){
		if(s[i]!='?') tmp+=s[i];
	}
	string ans="UNRESTORABLE";
	RREP(i,0,(s.size()-t.size()+1)){
		bool ok=true;
		REP(j,0,t.size()){
			if(s[i+j]!='?'&&s[i+j]!=t[j]){
				ok = false;
				break;
			}

		}
		if(ok){
			REP(j,0,t.size()){
				s[i+j]=t[j];
			}
			REP(j,0,s.size()){
				if(s[j]=='?') s[j]='a';
			}
			ans=s;
		}
	}
	p(ans);
	return 0;
}


Measured memory_bytes: 384
N = input().split()
Vs = list(map(int, input().split()))
Cs = list(map(int, input().split()))

l = []
for i in range(0, len(Vs)):
  tmp = Vs[i] - Cs[i]
  l.append(0 if tmp < 0 else tmp )
  

print(sum(l))

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<ll> a(n + 1);
  for(int i = 1; i <= n; i++){
    cin >> a.at(i);
    a.at(i) += a.at(i - 1);
  }
  
  ll ans = 1e18;
  for(int i = 3; i < n; i++){
    ll left = 1, right = i - 1, mid;
    while(left + 1 < right){
      mid = (left + right) / 2;
      if(a.at(mid) < a.at(i - 1) - a.at(mid)) left = mid;
      else right = mid;
    }
    ll b1, b2, c1, c2;
    b1 = a.at(left);
    c1 = a.at(i - 1) - a.at(left);
    if(right != i - 1){
      b2 = a.at(right);
      c2 = a.at(i - 1) - a.at(right);
    }
    else{
      b2 = b1;
      c2 = c1;
    }
    
    left = i, right = n;
    while(left + 1 < right){
      mid = (left + right) / 2;
      if(a.at(mid) - a.at(i - 1) < a.at(n) - a.at(mid)) left = mid;
      else right = mid;
    }
    ll d1, d2, e1, e2;
    d1 = a.at(left) - a.at(i - 1);
    e1 = a.at(n) - a.at(left);
    if(right != n){
      d2 = a.at(right) - a.at(i - 1);
      e2 = a.at(n) - a.at(right);
    }
    else{
      d2 = d1;
      e2 = e1;
    }
    
    ans = min({ans, max({b1, c1, d1, e1}) - min({b1, c1, d1, e1}), 
               max({b1, c1, d2, e2}) - min({b1, c1, d2, e2}), 
               max({b2, c2, d1, e1}) - min({b2, c2, d1, e1}), 
               max({b2, c2, d2, e2}) - min({b2, c2, d2, e2})});
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
int a[110];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			if(a[j]==a[i])
			{
				a[j]=0;
			}
		}
	}
	int sum=0;
	for(int i=0;i<n;i++)
	{
		if(a[i])
		{
			sum++;
		}
	
	}
	cout<<sum<<endl;
//	for(int i=0;i<n;i++)
//	{
//		cout<<a[i]<<" ";
//	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
int main(){
  int N;LL K;cin>>N>>K;
  vector<LL>A(N);
  int bitsum[41]={};
  for(LL &a:A){
    cin>>a;
    LL b=a;
    for(int i=0;i<40;i++){
      bitsum[i]+=(b&1L);
      b>>=1;
    }
  }
  LL ans=0;
  for(int i=40;i>=0;i--){
    if(bitsum[i]<N-bitsum[i]){
      if(ans+(1L<<i)<=K)
        ans+=(1L<<i);
    }
  }
  LL sum=0;
  for(LL a:A)sum+=a^ans;
  cout<<sum<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<list>
int main() {
	int n, i, x;
	std::cin >> n;
	std::string command;
	std::list<int> l;
	for (i = 0; i < n; i++) {
		std::cin >> command;
		if (command == "insert") {
			std::cin >> x;
			l.push_front(x);
		}
		else if (command == "delete") {
			std::cin >> x;
			for (std::list<int>::iterator itr = l.begin(); itr != l.end(); ++itr) {
				if (*itr == x) {
					l.erase(itr);
					break;
				}
			}
		}
		else if (command == "deleteFirst") {
			l.pop_front();
		}
		else if (command == "deleteLast") {
			l.pop_back();
		}
	}
	for (std::list<int>::iterator itr = l.begin(); itr != l.end(); ++itr) {
		if (itr != l.begin())std::cout << " ";
		std::cout << *itr;
	}
	std::cout << "\n";
	return 0;
}


Measured memory_bytes: 34332
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=a; i<=b; i++)
#define per(i,a,b) for (register int i=a; i>=b; i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 555555;
int n,a[N],res=N,mx=2e5;
int cnt[N],s[N];
bool cmp(int x, int y){return cnt[x]>cnt[y];}
int b[5];
void solve(int x, int y){
	int now=0;
	for(int i=1;i<=n;i+=2)now+=a[i]!=x;
	for(int i=2;i<=n;i+=2)now+=a[i]!=y;
	res=min(res,now);
}
int main() {
	read(n);rep(i,1,n)read(a[i]);
	memset(cnt,0,sizeof(cnt));for(int i=1;i<=n;i+=2)cnt[a[i]]++;
	rep(i,1,mx)s[i]=i;
	sort(s+1,s+mx+1,cmp);b[1]=s[1];b[2]=s[2];
	
	memset(cnt,0,sizeof(cnt));for(int i=2;i<=n;i+=2)cnt[a[i]]++;
	rep(i,1,mx)s[i]=i;
	sort(s+1,s+mx+1,cmp);b[3]=s[1];b[4]=s[2];
	if(b[1]!=b[3])solve(b[1],b[3]);
	if(b[1]!=b[4])solve(b[1],b[4]);
	if(b[2]!=b[3])solve(b[2],b[3]);
	if(b[2]!=b[4])solve(b[2],b[4]);
	printf("%d",res);return 0;
}

Measured memory_bytes: 5120
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){

      try(Scanner sc = new Scanner(System.in)){
        while (true) {
            int n = sc.nextInt();
            if (n == 0) { break; 
            }
            int[] scores = new int[n];
            for (int i = 0; i < scores.length; i++) {
            scores[i] = sc.nextInt();
            }
            double average = 0, variance = 0;

            
            for(int i=0; i < scores.length; i++){
                average += scores[i];
            }
            average /= scores.length;

            for(int i=0; i < scores.length; i++){
                double bunnsann = scores[i]-average;
                variance += bunnsann * bunnsann;
            }
            variance /= scores.length;

            System.out.println(Math.sqrt(variance));
        }    
      }
    }
}


Measured memory_bytes: 31452
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	long long a,b,c,k;cin >> a >> b >> c >> k;
	while(b <= a)b*=2,k--;
	while(c <= b || c <= a)c*=2,k--;
	if(k >= 0)cout << "Yes"; else cout << "No";
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>  // ver2.1.9
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lW,0,a.size()){Vout(a[lW]);}
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void uniq(Vi &v){sort(ALL(v)); v.erase(unique(ALL(v)),v.end());}  //  uniqのやつ
 
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
 
signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(16);
  int n,m,d;
  cin >> n >> m >> d;
  double sa;
  if(d==0) sa = 1.0/n*1.0;
  else sa = (2.0*(n-d))/((n*n)*1.0);
  //cout << sa << endl;
  cout << sa*(m-1) << endl;
  return 0;
}

Measured memory_bytes: 256
def insertionSort(A,N):
    for i in range(0,N):
        v = A[i]
        j = i -1
        while j>=0 and A[j] > v :
            A[j+1] = A[j]
            j-=1
        A[j+1] = v
        print(*A, sep=" ")

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


Measured memory_bytes: 5980
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int H,W,K;
  
  int result = 0;
  cin >> H >> W >> K;
  int n = H * W;
  vector<string> A(H);
  vector<int> B(H,0);
  vector<int> C(W,0);
  for(int a = 0;a < H;a++){
      cin >> A[a];
    for(int b = 0;b < W;b++){
      if(A[a][b] == '.'){
        B[a]++;
      C[b]++;
      n--;
      }
    }
  }
  vector<int>D(12);
  for(D[0]= 0;D[0] < 2;D[0]++){
    for(D[1]= 0;D[1] < 2;D[1]++){
      for(D[2]= 0;D[2] < 2;D[2]++){
        for(D[3]= 0;D[3] < 2;D[3]++){
          for(D[4]= 0;D[4] < 2;D[4]++){
            for(D[5]= 0;D[5] < 2;D[5]++){
              for(D[6]= 0;D[6] < 2;D[6]++){
                for(D[7]= 0;D[7] < 2;D[7]++){
                  for(D[8]= 0;D[8] < 2;D[8]++){
                    for(D[9]= 0;D[9] < 2;D[9]++){
                      for(D[10]= 0;D[10] < 2;D[10]++){
                        for(D[11]= 0;D[11] < 2;D[11]++){
                          int k = n;
                          
                          for(int a = 0;a < H;a++){
                            for(int b = 0;b < W;b++){
                              if(A[a][b] == '#'){
                              if(D[a] == 1||D[b+6] == 1)k--;
                            }
                            }
                          }
                          if(k == K)result++;
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  result /= pow(2,(12 - H - W));
  cout << result;
}

Measured memory_bytes: 4068
//https://atcoder.jp/contests/agc013/tasks/agc013_a
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-2.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#endif
    ll N; cin>>N;
    vector<ll> an(N);
    for(auto&& a:an){
        cin>>a;
    }
    vector<ll> zg;//zougen
    zg.reserve(N);
    FOR(i,0,N-1){
        if(an[i]<an[i+1]){ //増加
            zg.push_back(1);
        } else if(an[i]>an[i+1]){ //減少
            zg.push_back(-1);
        } //増減なし
    }
    ll flg=zg[0];
    ll ans=1;
    FOR(i,1,zg.size()){
        if(flg!=zg[i]){
            if(i+1<zg.size()){
                ++i;
                flg=zg[i];
            } else {
                flg=zg[i];
            }
            ++ans;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a>b)
	{
		for(int i=0;i<a;i++)
		{
			cout<<b;
		}
	}
	if(a<b)
	{
		for(int i=0;i<b;i++)
		{
			cout<<a;
		}
	}
	if(a==b)
	{
		for(int i=0;i<a;i++)
		{
			cout<<b;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   for(int i=0;i<(n);++i)
#define SORT(c)    sort((c).begin(),(c).end())
#define CLR(a)     memset((&a), 0 ,sizeof(a))//clear memory
#define dump(x)    cerr << #x << " = " << (x) << endl;//debug
#define debug(x)   cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define EPS        1e-10//sample:if((double)>=(double)+EPS)
//cin,cout release



int n,A[5000000];

void maxheapify(int i){
  int l=2*i,r=2*i+1,largest;
  if(l<=n&&A[l]>A[i])largest=l;
  else largest=i;
  if(r<=n&&A[r]>A[largest])largest=r;
  if(largest!=i){
    swap(A[i],A[largest]);
    maxheapify(largest);
  }
}
int extract(){
  int maxv;
  if(n<1)return INT_MIN;
  maxv=A[1];
  A[1]=A[n--];
  maxheapify(1);
  return maxv;
}
void increasekey(int i,int key){
  if(key<A[i])return;
  A[i]=key;
  while(i>1&&A[i/2]<A[i]){
    swap(A[i],A[i/2]);
    i/=2;
  }
}
void insert(int key){
  A[++n]=INT_MIN;
  increasekey(n,key);
}

int main(){
  int key;
  string str;
  while(1){
    cin>>str;
    if(str=="end")break;
    if(str=="insert"){
      cin>>key;
      insert(key);
    }
    else cout<<extract()<<endl;
  }
  return 0;
}


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

using ll = long long;
#define mod 1000000007
#define init ios::sync_with_stdio(0), cin.tie(0);
typedef vector<int> vi;
typedef pair<int, int> pi;
#define MS(x, y) memset(x, y, sizeof(x))
#define F first
#define S second
#define PB push_back
#define MP make_pair

ll bs(vector<ll> &b, ll m, ll k)
{
    int l = 0, r = m;
    int ans = 0;
    while (l <= r)
    {
        int mid = l + (r - l) / 2;
        if (b[mid] <= k)
        {
            ans = mid;
            l = mid + 1;
        }
        else
        {
            r = mid - 1;
        }
    }
    return ans;
}
int main()
{
    init;
    ll n, m, k;
    cin >> n >> m >> k;

    vector<ll> a(n + 1), b(m + 1);

    for (ll i = 1; i <= n; i++)
    {
        cin >> a[i];
        a[i] += a[i - 1];
    }
    for (ll i = 1; i <= m; i++)
    {
        cin >> b[i];
        b[i] += b[i - 1];
    }

    ll cnt = 0, sum = 0;
    for (ll i = 0; i <= n; i++)
    {
        ll ind = 0;
        if (k >= a[i])
            ind = bs(b, m, k - a[i]);
        else
            break;

        if (a[i] + b[ind] <= k)
            cnt = max(cnt, i + ind);
    }

    cout << cnt;
}

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

using namespace std;

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

int main(){
    int k, n;
    cin >> k >> n;
    int arr[n];
    for(int i=0; i<n; i++){
        cin >> arr[i];
    }
    long int max = 0;
    long long int sum = 0;
    for(int i=0; i<n; i++){
        if(i < n-1){
            int diff = abs(arr[i] - arr[((i + 1))]);
            sum += diff;
            max = max1(diff, max);
        }else {
            int diff = k - arr[i];
            diff += arr[0];
            sum += diff;
            max = max1(max, diff);
        }
    }
    cout << sum - max << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
  string S;
  cin >> S;
  int ans = 0;
  int cont = 0;
  for (int i = 0; i < S.length(); i++) {
    if (S[i]=='A' || S[i]=='T' || S[i]=='C' || S[i]=='G') {
      cont++;
      ans = max(ans, cont);
    } else {
      cont = 0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
import math
x = int(input())

def isPrime(n):
    if n == 2:
        return True
    i = 2
    m = math.ceil(math.sqrt(n))
    flag = True
    while i <= m:
        if n % i == 0:
            flag = False
            break
        i += 1
    return flag

i = x
while True:
    if isPrime(i):
        print(i)
        break
    i += 1

Measured memory_bytes: 3064
def resolve():
    import math
    a, b = map(int, input().split())
    if a == 1:
        bina = 0
    elif a == 2:
        bina = 1
    elif a == 3:
        bina = 3
    elif a%4 ==3:
        bina = a
    else:
        lowera = math.floor((a - 3) / 4) * 4 + 3
        bina = 0
        for i in range(lowera + 1, a):
            bina = bina ^ i

    if b ==1:
        binb = 1
    elif b ==2:
        binb = 3
    elif b==3:
        binb =0
    else:
        if b%4 == 3:
            binb = 0
        else:
            lowerb = math.floor((b-3)/4)*4+3
            binb = 0
            for j in range(lowerb+1, b+1):
                binb = binb^j

    print(bina^binb)
resolve()

Measured memory_bytes: 38768
import sys
from bisect import bisect_left as bl
input = sys.stdin.readline
N = int(input())
mod = 998244353
a = []
xs = [0] * N
for _ in range(N):
  x, d = map(int, input().split())
  a.append((x, d))
a.sort()
for i in range(N): xs[i] = a[i][0]

class SegTree:
  def segfunc(self, x, y):
    return max(x, y)
  def __init__(self, n, ide_ele, init_val):
    #####単位元######
    self.ide_ele = ide_ele
    #num:n以上の最小の2のべき乗
    self.num = 2 ** (n - 1).bit_length()
    self.seg = [self.ide_ele] * 2 * self.num
    #set_val
    for i in range(n):
      self.seg[i + self.num - 1] = init_val[i]    
    #built
    for i in range(self.num - 2, -1, -1) :
      self.seg[i] = self.segfunc(self.seg[2 * i + 1], self.seg[2 * i + 2]) 
  def update(self, k, x):
    k += self.num - 1
    self.seg[k] = x
    while k + 1:
      k = (k - 1) // 2
      self.seg[k] = self.segfunc(self.seg[k * 2 + 1], self.seg[k * 2 + 2]) 
  def query(self, p, q):
    if q <= p:
      return self.ide_ele
    p += self.num - 1
    q += self.num - 2
    res = self.ide_ele
    while q - p > 1:
      if p & 1 == 0:
        res = self.segfunc(res, self.seg[p])
      if q & 1 == 1:
        res = self.segfunc(res, self.seg[q])
        q -= 1
      p = p // 2
      q = (q - 1) // 2
    if p == q:
      res = self.segfunc(res, self.seg[p])
    else:
      res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
    return res

seg = SegTree(N, 0, [0] * N)
#print(xs, a)
for l in range(N - 1, -1, -1):
  r = bl(xs, a[l][0] + a[l][1])
  mx = max(l, seg.query(l, r))
  seg.update(l, mx)
  #print(mx, a[i][0] + a[i][1])

dp = [0] * (N + 1)
dp[0] = 1
for i in range(N):
  dp[i + 1] += dp[i]
  dp[i + 1] %= mod
  dp[seg.query(i, i + 1) + 1] += dp[i]
  dp[i + 1] %= mod
print(dp[-1])

Measured memory_bytes: 101724
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
    int h,w;
    while(1){
    cin >> h >> w;
    if(h==0&&w==0) break;
    for (int j=0; j<h; j++) {
        for (int i=0; i<w; i++) {
            if((j+i)%2==0) {
                cout << "#";
            } else {
                cout << ".";
            }
        }
        cout << endl;
    }
    cout << endl;
    }
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
vector<char> num{'3', '5', '7'};
int ans = 0;
ll n;
vector<int> kazu;
bool judge(ll l){
    vector<bool> con(3, false);
    string t = to_string(l);
    rep(i, t.size()){
        rep(j, 3){
            if(t[i] == num[j]) con[j] = true;
        }
    }
    if(con[0] and con[1] and con[2]) return true;
    else return false;
}
void dfs(ll m){
    if(m > n) return;
    if(judge(m)) ans++; 

    dfs(m * 10 + 3);
    dfs(m * 10 + 5);
    dfs(m * 10 + 7);
}

int main(){
    cin >> n;
    dfs(0);
    cout << ans << endl;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

int N, M, Q;
vint A, B, C, D;
int mas[15][15][15] = {};
int dfs(int u, vint dat, int sum) {
	if (u == N-1) return (0);
	int ret = 0;
	for (int s = 0; s + sum <= M-1; s++) {
		int val = 0;
		int ss = s;
		val += mas[u][u+1][ss];
		for (int i = u-1; i >= 0; i--) {
			ss += dat[i];
			val += mas[i][u+1][ss];
		}
		vint d2 = dat;
		d2.push_back(s);
		chmax(ret, dfs(u+1, d2, ss) + val);
	}
	return (ret);
}

void Main() {
	cin >> N >> M >> Q;
	A = vint(Q);
	B = vint(Q);
	C = vint(Q);
	D = vint(Q);
	for (int i = 0; i < Q; i++) {
		cin >> A[i] >> B[i] >> C[i] >> D[i]; --A[i], --B[i];
		mas[A[i]][B[i]][C[i]] = D[i];
	}
	cout << dfs(0, vint(), 0) << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3664