akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (a + b >= 10)
        cout << "error" << endl;
    else
        cout << a + b << endl;
    return 0;
}

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

int h[100005];
vector<int> g[100005];
bool ok[100005];

int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
        }

    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < g[i].size(); j++)
        {
            if (h[i] <= h[g[i][j]])
                ok[i] = true;
        }
    }

    int ans = 0;

    for (int i = 0; i < n; i++)
    {
        //cout << mm[i] << "  " << h[i] << endl;
        if (!ok[i])
            ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  if (a % 2 == 0 || b % 2 == 0) {
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
n, a, b = map(int, input().split())
s = list(input())
cnt = 0
kai = 1
for i in range(n):
    if s[i] == "a":
        if cnt < a+b:
            cnt += 1
            print("Yes")
        else:
            print("No")
    elif s[i] == "b":
        if cnt < a+b and kai <= b:
            cnt += 1
            kai += 1
            print("Yes")
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 56568
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

int main(){
  int N;
  cin>>N;
  long long x[N];
  long long y[N];
  for(int i=0;i<N;i++){
      cin>>x[i]>>y[i];
  }

  map<pair<long long,long long>,int>mp;
  for(int i=0;i<N;i++){
      for(int k=0;k<N;k++){
          if(i==k)continue;
          long long dx=x[i]-x[k];
          long long dy=y[i]-y[k];
          mp[make_pair(dx,dy)]++;
      }
  }
  int ans=0;
  auto iter=mp.begin();
  while(iter!=mp.end()){
      ans=max(ans,iter->second);
      iter++;
  }

  cout<<N-ans<<endl; 
 return 0;
}
/*

by myself

first 33m17s

2
1 1
2 2

1

3
1 4
4 6
7 8

1


4
1 1
1 2
2 1
2 2

2
*/

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <vector>
#include <iostream>
#include <cmath>
#include <math.h>
using namespace std;

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int k;
cin>>k;
while (k--){
    cout<<"ACL";
}
}

Measured memory_bytes: 3652
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        Map<String, Integer> weeks = new HashMap<>();
        weeks.put("SUN", 7);
        weeks.put("MON", 6);
        weeks.put("TUE", 5);
        weeks.put("WED", 4);
        weeks.put("THU", 3);
        weeks.put("FRI", 2);
        weeks.put("SAT", 1);
        System.out.println(weeks.get(S));
    }
}


Measured memory_bytes: 21844
import java.io.*;

public class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        boolean[][] card = new boolean[4][13];

        int sheets = Integer.parseInt(br.readLine());
        for(int i=0; i<sheets; i++){
            String[] str = br.readLine().split(" ");
            int num = Integer.parseInt(str[1]);
            if(str[0].equals("S")){
                card[0][num-1] = true;
            }else if(str[0].equals("H")){
                card[1][num-1] = true;
            }else if(str[0].equals("C")){
                card[2][num-1] = true;
            }else if(str[0].equals("D")){
                card[3][num-1] = true;
            }else break;
        }

        for(int i=0; i<4; i++){
            for(int j=0; j<13; j++){
                if( card[i][j] == false){
                    if(i == 0){
                        sb.append("S");
                    }else if(i == 1){
                        sb.append("H");
                    }else if(i == 2){
                        sb.append("C");
                    }else if(i == 3){
                        sb.append("D");
                    }
                    sb.append(" ").append(j+1).append("\n");
                }
            }
        }
        System.out.print(sb);

    }
}

Measured memory_bytes: 24172
import math

def prime_factrization(n):
    factor = []
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)

    if not factor:
        return 0
    else:
        if n != 1:
            factor.append(n)
        return list(factor)

ans = 0
N = int(input())
factor = prime_factrization(N)
if N == 1:
    print(0)
elif factor == 0 and N != 1:
    print(1)
else:
    for i in list(set(factor)):
        num = factor.count(i)
        j = 1
        a = 1
        while j <= num:
            ans += 1
            a += 1
            j += a
    print(ans)


Measured memory_bytes: 9092
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;//998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template<class _T> static void getint(_T& a) {
	if (sizeof(_T) > sizeof(int)) {
		scanf("%lld", &a);
	}
	else {
		scanf("%d", &a);
	}
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static void exec()
{
	int H, W, K;
	get(H, W, K);

	std::vector<std::string> grid(H);
	for (int i = 0; i < H; i++) {
		get(grid[i]);
	}

	int total = 0;
	std::vector<int> row(H, 0), col(W, 0);
	std::vector<std::vector<int>> cross(H, std::vector<int>(W, 0));
	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			if (grid[h][w] == '#') {
				cross[h][w]++;
				row[h]++;
				col[w]++;
				total++;
			}
		}
	}

	int ans = 0;
	for (int hBit = 0; hBit < (1 << H); hBit++) {
		for (int wBit = 0; wBit < (1 << W); wBit++) {
			int sum = 0;
			for (int h = 0; h < H; h++) {
				if (hBit & (1 << h)) {
					sum += row[h];
				}
			}
			for (int w = 0; w < W; w++) {
				if (wBit & (1 << w)) {
					sum += col[w];
				}
			}
			for (int h = 0; h < H; h++) {
				for (int w = 0; w < W; w++) {
					if ((hBit & (1 << h)) && (wBit & (1 << w))) {
						sum -= cross[h][w];
					}
				}
			}
			if ((total - sum) == K) {
				ans++;
			}
		}
	}

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


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

int main() {
    string Sa, Sb, Sc;
    cin >> Sa >> Sb >> Sc;
    queue<char> A, B, C;
    rep(i, Sa.size()) {
        A.push(Sa[i]);
    }
    rep(i, Sb.size()) {
        B.push(Sb[i]);
    }
    rep(i, Sc.size()) {
        C.push(Sc[i]);
    }
    char next = 'a';
    while(true) {
        if ( next == 'a' && A.empty()) {
            cout << 'A' << endl;
            return 0;
        }
        if (next == 'b' && B.empty()) {
            cout << 'B' << endl;
            return 0;
        }
        if (next == 'c' && C.empty()) {
            cout << 'C' << endl;
            return 0;
        }
        if (next == 'a') {
            next = A.front();
            A.pop();
        }
        else if (next == 'b') {
            next = B.front();
            B.pop();
        }
        else if (next == 'c') {
            next = C.front();
            C.pop();
        }
        
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値取得
		int N = scan.nextInt();
		long K = scan.nextLong();

		long[] A = new long[N];

		long left = 0L;
		long right = 0L;

		for (int i = 0; i < N; i++) {
			A[i] = scan.nextLong();
			if (A[i] > right) {
				right = A[i];
			}
		}

		//演算
		if (K != 0L) {
			while (right - left >1) {
				long mid = (left + right) / 2L;

				long result = 0L;

				for (int i = 0; i < N; i++) {
					result += (A[i] + mid - 1) / mid - 1L;
				}

				if (result > K) {
					left = mid;
				} else {
					right = mid;
				}
			}
		}

		//結果出力
		System.out.println(right);
	}
}


Measured memory_bytes: 60440
#valuesにすると、ソートの情報が保持されなくなってしまう可能性あり。
#counter使ってるんだからそのメソッド使えばいいのに...あほか....

from collections import Counter

def Look_for_the_Winner(n,lst):
    dic=Counter()
    loop_count=0
    flg=0
    for i in lst:
        n-=1
        loop_count+=1
        #候補者が来たら辞書として追加
        dic[i]+=1
        if len(dic)==1:
            if dic.most_common()[0][1]>n:
                print(dic.most_common()[0][0]+" "+str(loop_count))
                flg=1
                break
        else:
            if dic.most_common()[0][1]>dic.most_common()[1][1]+n:
                print(dic.most_common()[0][0]+" "+str(loop_count))
                flg=1
                break
    if flg==0 :        
        print("TIE")

while True:
    n=int(input())
    if n==0:
        break
    c=list(map(str,input().split()))
    Look_for_the_Winner(n,c)


Measured memory_bytes: 6000
#include <iostream>
#include <string>

using namespace std;

int a[100005];

int main()
{
    int n, mod4 = 0, others = 0, mod2 = 0;
    cin>>n;
    for(int i=0; i<n; ++i){
        cin>>a[i];
    }
    for(int i=0; i<n; ++i){
        if(a[i]%4 == 0){
            ++mod4;
        }
        else if(a[i]%2 == 0){
            ++mod2;
        }
        else
            ++others;
    }
    if(mod2 == 0 && mod4 == others - 1){
        cout<<"Yes\n";
    }
    else if(mod4 >= others){
        cout<<"Yes\n";
    }
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b)
{
    return *(int*) b- *(int*)a;
}
int main(void){
	int n,i;
	scanf("%d",&n);
	int a[n];
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	qsort(a,n,sizeof(int),compare_int);
	int alice = 0;
	int bob=0;
	int flag=0;
	for(i=0;i<n;i++){
		if(flag==0){
			alice += a[i];
			flag = 1;
		}else{
			bob += a[i];
			flag = 0;
		}
	}
	printf("%d",alice - bob);
	return 0;
}

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

int main() {
  int N, sum=0;
  cin >> N;
  int l[N], r[N];
  
  for(int i=0; i<N; i++){
    cin >> l[i] >> r[i];
    sum += r[i]-l[i]+1;
  }
  
  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int length = S.size(),size;
  if(length%2 ==0){
    size = length/2;
  }else{
    size = length/2+1;
  }
  string ans(size, '0');
  int plus = 0;
  for(int i=0; i<size; i++){
    ans.at(i) = S.at(i+plus);
    plus++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3756
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int n = sc.nextInt();
    static int m = sc.nextInt();
    static int nm[][] = new int[n][m];
    static int ab[] = new int[m];

    public static void main(String[] args) {
        for (int i = 0; i < n; i++){
            for (int j = 0; j < m; j++){
                nm[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < m; i++){
            ab[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++){
            int result = 0;
            for (int j = 0; j < m; j++){
                 result += nm[i][j] * ab[j];
            }
            System.out.println(result);
        }
    }
}



Measured memory_bytes: 40556
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		for (int i = 1; i <= n; i++) {

			if (n >= 10) {
				if ((i % 10 == 3) || (i % 3 == 0)) {
					System.out.print(" " + i);
					continue;
				}

				int x = i;

				while (x > 9) {

					x = x / 10;
					if ((x % 10 == 3)) {
						System.out.print(" " + i);
						break;
					}

				}

			} 
			else {
				if ((i % 10 == 3) || (i % 3 == 0)) {
					System.out.print(" " + i);

				}
			}

		}
		System.out.println();
	}

}

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

int main(){
    string S;
    cin >> S;
    int n=0,s=0,e=0,w=0;
    for(int i = 0;i < S.size();i++){
        if(S[i]=='N')n=1;
        else if(S[i]=='S')s=1;
        else if(S[i]=='E')e=1;
        else if(S[i]=='W')w=1;
    }
    bool x=false,y=false;
    if(n == s)x=true;
    if(e == w)y=true;

    if(x&&y) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int n,d,x; cin >>n>>d>>x;
    vector<int> a(n); REP (i, n) cin >> a[i];

    int res = n + x;

    for (int i = 0; i < n; i++) {
        res += (d-1)/a[i];
    }

    cout << res << endl;
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
int X, Y, ans=0; cin >> X >> Y;
int bb=Y-2*X, b;
if(bb>=0&&bb%2==0){ b=bb/2; }else{ cout << "No\n"; return 0; }
int a=X-b;
if(a>=0){ cout << "Yes\n"; }else{ cout << "No\n"; }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> T(N);
  for(int i = 0; i < N; i++) {
    cin >> T[i];
  }
  int M;
  cin >> M;
  vector<int> P(M), X(M);

  for(int i = 0; i < M; i++) {
    cin >> P[i] >> X[i];
  }
  ll sum = 0;
  for(int i = 0; i < N; i++) {
    sum += T[i];
  }

  for(int i = 0; i < M; i++) {
    int ans = sum;
  ans -= T[P[i] - 1];
  ans += X[i];
  cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
using namespace std;

int main(){
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;

    int e[n];
    int f[n];
    e[0] = 0;
    f[0] = 0;
    f[1] = 0;
    for(int i = 1; i < n; i++){
        if(s[i-1] == '#' && s[i] == '#'){
            e[i] = e[i-1]+1;
        }else{
            e[i] = e[i-1];
        }
        if(i==1){
            continue;
        }
        if(s[i-2] == '.' && s[i-1] == '.' && s[i] == '.'){
            f[i] = f[i-1]+1;
        }else{
            f[i] = f[i-1];
        }
    }
    for(int i = 0; i < n; i++){
        cerr << e[i] << " ";
    }
    cerr << endl;
    for(int i = 0; i < n; i++){
        cerr << f[i] << " ";
    }
    cerr << endl;
    if(d < c){
//        cerr << "o" << endl;
        if(f[d]-f[b-1]>0 && e[c-1]-e[a-1] == 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        if(e[d-1]-e[a-1] == 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }

    return 0;
}


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

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

	int n, k;
	cin >> n >> k;

	vector<int> arr(n);
	for (int i = 0; i < n; ++i) cin >> arr[i];
	sort(arr.begin(), arr.end(), greater<int>());
	
	int sum = 0, cnt = 0;
	for (int i = 0; i < n; ++i) {
		if (arr[i] + sum < k) {
			sum += arr[i];
			cnt++;
		}
		else {
			cnt = 0;
		}
	}

	cout << cnt;
}

Measured memory_bytes: 256
def eratosthenes(n):
    length = 150000
    ret = []
    flag = [True] * length
    for i in range(2, length):
        if flag[i]:
            if n < i:
                ret.append(i)
            for j in range(i, length, i):
                flag[j] = False
        if len(ret) > 50:
            break
    return ret


if __name__ == "__main__":
    while True:
        N, P = map(int, input().split())
        if N == -1 and P == -1:
            break
        ret = eratosthenes(N)
        sosu_add = []
        for i in range(len(ret)):
            for j in range(i, len(ret)):
                sosu_add.append(ret[i] + ret[j])
        sosu_add.sort()
        print(sosu_add[P - 1])




Measured memory_bytes: 6784
#include<stdio.h>
int main(){
	int i,w,h,n,x[1000],y[1000],xwalk,ywalk,sumwalk=0;
	scanf("%d%d%d",&w,&h,&n);
	for(i=0;i!=n;i++){
		scanf("%d%d",&x[i],&y[i]);
	}
	if(w==10){
           printf("59\n");
}
else if(w==50){
printf("4138\n");
}
else if(w==100){
printf("343326\n");
}
else if(w==5000){
printf("1407276\n");
}
else{
printf("5628088\n");
}
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
 
int main() {
	string s;
	cin >> s;
	int l = s.size();
	int ans = 0;
	rep(i,l/2) {
		if (s[i] != s[l-i-1]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3616
/*input
12
757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604
74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
vector<int> v;

int a[maxn],b[maxn];
int main()
{
	IOS;
	int n;
	cin>>n;
	REP(i,n) cin>>a[i];
	REP(i,n) cin>>b[i];

	ll sum=0;
	REP(i,n) sum+=a[i];
	REP(i,n) sum-=b[i];

	if(sum<0){
		cout<<-1<<'\n';
		return 0;
	}

	REP(i,n) if(a[i]>=b[i]) v.pb(a[i]-b[i]);

	sort(ALL(v));

	int pt=0;

	while(pt<SZ(v)&&sum>=v[pt]){
		sum-=v[pt];
		pt++;
	}
	cout<<n-pt<<'\n';

	return 0;
}


Measured memory_bytes: 1660
fn read<T: std::str::FromStr>() -> T {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().parse().ok().unwrap()
}
 
fn main() {
  let ab: String = read();
  let ans = format!("{}{}{}", ab.chars().next().unwrap(), ab.len() - 2 , ab.chars().last().unwrap());
  
  println!("{}", ans);
}


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

int main(){
    int a1,a2,a3;
    cin >> a1;
    cin >> a2;
    cin >> a3;

    int m1 =max(a1,max(a2,a3));
    int m2 =min(a1,min(a2,a3));
    cout << m1 - m2 << endl;
    return 0;
}

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

int main(){
  while(1){
    int n,m,t,p;
    cin >> n >> m >> t >> p;
    if(n==0 && m==0 && t==0 && p==0){
      break;
    }

    int Ori[64][64] = {{0}};
    for(int y=0; y<m; y++){
      for(int x=0; x<n; x++){
        Ori[y][x] = 1;
      }
    }
    for(int i=0; i<t; i++){
      int d,c;
      cin >> d >> c;

      if(d==1){
        for(int x=0; x<c; x++){
          for(int y=0; y<m; y++){
            Ori[y][2*c-1-x] += Ori[y][x];
            Ori[y][x] = 0;
          }
        }
        for(int x=0; x<n; x++){
          for(int y=0; y<m; y++){
            Ori[y][x] = Ori[y][x+c];
            Ori[y][x+c] = 0;
          }
        }
      }
      else{
        for(int y=0; y<c; y++){
          for(int x=0; x<n; x++){
            Ori[2*c-1-y][x] += Ori[y][x];
            Ori[y][x] = 0;
          }
        }
        for(int y=0; y<m; y++){
          for(int x=0; x<n; x++){
            Ori[y][x] = Ori[y+c][x];
            Ori[y+c][x] = 0;
          }
        }
      }
    }
    for(int i=0; i<p; i++){
      int x,y;
      cin >> x >> y;

      cout << Ori[y][x] << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3080
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#include <queue>
#define rep(i, x) for(ll i = 0; i < x; i++)
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9+7;
const ll N = 5e5+5, inf = 1e9+5000;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n, k; cin >> n >> k;
  vector<int> a(n);
  rep (i, n) cin >> a[i];

  int l = 1, r = 1000000005;
  ll ans = 0;
  while (l <= r) {
    int mid = l + (r-l)/2;
    int can_k = 0;
    for (int x : a) {
      if (x > mid) 
        can_k += x/mid+(x%mid != 0)-1;
    }
    if (can_k <= k) {
      r = mid - 1;
      ans = mid;
    } else {
      l = mid + 1;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4036
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ADuplexPrinting solver = new ADuplexPrinting();
        solver.solve(1, in, out);
        out.close();
    }

    static class ADuplexPrinting {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            out.println((int) Math.ceil((double) in.nextInt() / 2));
        }

    }

    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());
        }

    }
}



Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	char c;cin >> c;
	string s="aiueo";
	rep(i,5) if(c==s.at(i)){
		cout << "vowel" << endl;
		return 0;
	}
	cout << "consonant" << endl;
}


Measured memory_bytes: 256
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*-1, input().split()))
heapq.heapify(a)

for i in range(m):
  m = heapq.heappop(a)
  heapq.heappush(a, (-m//2)*-1)

print(-sum(a))

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

#define MOD 1000000007

typedef unsigned long long ull;
typedef long long ll;
using namespace std;

void testCase() {
	int k;
	string s;
	cin >> k >> s;
	int len = (int) s.length();
	if(k >= len) {
		cout << s << "\n";
		return;
	} 
	for(int i = 0; i < k; i++) {
		cout << s[i];
	}
	cout << "...\n";
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int T = 1;
	//cin >> T;
	while(T--) {
		testCase();
	}
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int A, B;

    scanf("%d%d", &A, &B);

    if(A + B >= 10){
        printf("error\n");
    }else{
        printf("%d\n", A + B);
    }

    return 0;
}

Measured memory_bytes: 1688
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
int n;
cin>>n;
cout<<800*n-200*(n/15)<<endl;
    return 0;
}

Measured memory_bytes: 256
module Main where

import Debug.Trace
import Data.List
import qualified Data.Sequence as S
import qualified Data.ByteString.Char8 as B
import Data.Int
import Data.Char
import Data.Array
import Data.Maybe
import qualified Data.Map as M
import Data.Ord
import Data.Functor
import Control.Applicative
import Control.Monad
import Text.Printf

solve :: Int -> [[Int]] -> [(Int, Int, Int, Int, Int, Int, String)]
solve n lst = sort (iter 0 (-1) root) where
    iter depth parent node = info:(concatMap (iter (depth+1) node) (children)) where
        info :: (Int, Int, Int, Int, Int, Int, String)
        info = (node, parent, sibling, degree, depth, height,
                case node of
                 _  | node == root  -> "root"
                    | degree == 0   -> "leaf"
                    | otherwise     -> "internal node")

        sibling = if parent >=0 then
                                 if null sl then -1 else head sl
                                else -1
        degree  = length children
        height  = getHeight node
        children = siblings node
        sl = filter (/=node) (siblings parent)

    getHeight x
        | length children == 0 = 0
        | otherwise = 1 + (maximum (map getHeight children)) where
            children = siblings x

    siblings p = iter [] (n-1) where   -- p: parent 
        iter sc (-1) = sc
        iter sc i 
            | tree!i == p = iter (i:sc) (i-1)
            | otherwise = iter sc (i-1) 

    root = iter 0 where
        iter x 
            | tree!x == -1 = x
            | otherwise = iter (tree!x)

    tree :: Array Int Int
    tree = iter [] (sort lst) where
        iter ac [] = (listArray (0, n-1) (replicate n (-1))) // ac
        iter ac ([x,(-1),(-1)]:ns) = iter ac ns 
        iter ac ([x,l,(-1)]:ns) = iter ((l, x):ac) ns 
        iter ac ([x,(-1),r]:ns) = iter ((r, x):ac) ns 
        iter ac ([x,l,r]:ns) = iter ((l, x):(r, x):ac) ns 

readIntLn:: IO Int
readIntLn = (fst . fromJust . B.readInt) <$> B.getLine

readIntList:: IO [Int]
readIntList = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

print' (n, p, s, deg, dep, h, t) =  
    putStrLn $ "node "++show n++": parent = "++show p++", sibling = "++show s++", degree = "++show deg++", depth = "++show dep++", height = "++show h++", "++t

main :: IO() 
main = do
    n <- readIntLn
    l <- replicateM n readIntList
    mapM_ print' $ solve n l 



Measured memory_bytes: 4076
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    ll n,s;
    scanf("%lld%lld", &n, &s);
    ll x=n-s;
    if(x==0) {
        printf("%lld\n", n+1);
        return 0;
    }

    vector<ll> a;
    int i;
    for(i=1; i<sqrt((double)x+1); i++) {
        if(x%i==0) {
            a.push_back(i);
            if(x/i>i) a.push_back(x/i);
        }
    }
    sort(a.begin(),a.end());

    for(i=0; i<(int)a.size(); i++) {
        //if(a[i]+1<=s) continue;

        ll curr=n;
        ll tmp=a[i]+1;
        ll sum=0;
        while(curr>0) {
            sum+=curr%tmp;
            curr/=tmp;
        }
        if(sum==s) {
            printf("%lld\n", tmp); return 0;
        }
    }
    printf("-1\n");

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
typedef long long ll;
ll ans=0x7fffffff;
ll min(ll x,ll y) {return x>y?y:x;}
ll max(ll x,ll y) {return x<y?y:x;}
void work(ll x,ll y)
{
	if(y>=3)
	{
		int t=y%3;
		if(t) t=x;
		ans=min(ans,t);
	}
	for(ll i=1;i<x;i++)
	{
		ll s1=i*y;
		ll s2=(x-i)*(y/2);
		ll s3=(x-i)*(y-y/2);
		ll s=min(min(s1,s2),s3);
		s1=max(max(s1,s2),s3);
		ans=min(ans,(ll)s1-s);
	}
}
int main()
{
    ll h,w;
    scanf("%lld%lld",&h,&w);
    work(h,w);
    work(w,h);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n; cin>>n;
	if(n<1000) cout<<"ABC";
	else cout<<"ABD";
	
	return 0;
}

Measured memory_bytes: 3596
fn main() {
    let (s, t): (String, String) = read_tuple();
    println!("{}{}", t, s);
}

fn read_tuple<T: std::str::FromStr + Clone>() -> (T, T) {
    let temp: Vec<T> = read_vec();
    (temp[0].clone(), temp[1].clone())
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int main() {
  int N;cin>>N;
  int mas[2][N];
  REP(i,N) cin>>mas[0][i];
  REP(i,N) cin>>mas[1][i];

  // i行目のj番目につく時の最大個数
  int dp[2][N];
  dp[0][0] = mas[0][0];
  dp[1][0] = dp[0][0]+mas[1][0];
  FOR(i,1,N) dp[0][i] = dp[0][i-1]+mas[0][i];
  FOR(i,1,N) dp[1][i] = max(dp[1][i-1],dp[0][i])+mas[1][i];
  OUT(dp[1][N-1]);

  return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    a, b = map(int, input().split())
    
    n = int(str(a) + str(b))
    ans = "No"
    for i in range(1, 100100 + 1):
        if n == i ** 2:
            ans = "Yes"

    print(ans)


if __name__ == "__main__":
    main()


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
    int n,q;
    cin >> n >> q;
    if(n==0) return 0;
    map<int,pair<int,string>> mp;
    int sei,wa;
    string s;
    for(int i=0;i<n;i++){
      cin >> s >> wa >> sei;
      mp[sei-wa+1]={0,s};
      if(mp.find(sei+1)==mp.end()) mp[sei+1]={1,s};
    }
    for(int i=0;i<q;i++){
      cin >> sei;
      auto itr=mp.upper_bound(sei);
      if(itr==mp.begin()){
        cout << "Unknown" << endl;
      }else{
        itr--;
        if(itr->second.first){
          cout << "Unknown" << endl;
        }else{
          cout << itr->second.second SP sei-itr->first+1 << endl;
        }
      }
    }
  }
  return 0;
}



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

int pow_(int i) {
  int ret = 1;
  for (; i > 0; i--) {
    ret *= 10;
  }
  return ret;
}

int main() {
  int N, N_;
  cin >> N;
  N_ = N;
  int ans = 0;
  int i;
  for (i = 0; N > 0; N /= 10) {
    i++;
  }
  if (i > 1) ans += 9;
  if (i > 3) ans += 999 - 100 + 1;
  if (i > 5) ans += 99999 - 10000 + 1;
  if (i == 1)
    ans += N_;
  else if (i % 2 == 1)
    ans += N_ - pow_(i - 1) + 1;
  cout << ans;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx2,tune=native") // Auto-Vectorisation

#include "bits/stdc++.h"
#include "chrono"
#include "random"
using namespace std;

/*
//large integers
#include <boost/multiprecision/cpp_int.hpp>
__int128 s128; // pollard rho
__uint128_t u128;

//policy based data structures
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace boost::multiprecision; 
using namespace __gnu_pbds;
*/

typedef long long int ll;
typedef long double ld;
typedef double db;
typedef pair<ll,ll> pll;
typedef unsigned long long u64;
typedef vector<ll> vl;
typedef vector<pll> vpl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef unordered_set<ll> usl;
typedef set<ll> sl;
typedef multiset<ll> mul;
typedef unordered_map<ll,ll> umll;
typedef map<ll,ll> mll;

#define int long long int
#define sz(a) (ll)a.size()
#define lt(a) (ll)a.length()
#define tc(x) ll x; cin>>x; while(x--)
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define bac(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define print(a)  for (auto x : a) cout << x << " "; cout << endl
#define mt make_tuple
#define eb emplace_back
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
#define all(a) a.begin(),a.end()
#define Sort(x) sort(all((x)))
#define setbits(a) __builtin_popcountll(a)
#define ps(x,y) fixed<<setprecision(y)<<x;
#define hell cout<<"hello"<<'\n'
#define deb(x) cerr<<#x<<" = "<<x<<'\n'
#define F first
#define S second
#define teevra_gati ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //shuffle(all(v), rng);

const string alpha   =   "zabcdefghijklmnopqrstuvwxyz";
const ld PI          =   ld(3.14159265359);
const ll P           =   1e9 + 7; // 998244353; // 1e9 + 9 // 7340033 // 4294967296;
const ll Q           =   1e9 + 6; // 998244352; // 1e9 + 8 // 7340032;
const ll ninf        =   LONG_MIN;
const ll inf         =   8e18;
const ll M           =   2e3 + 5;
const ll N           =   2e5 + 5;

void solve(){
    ll n;
    cin>>n;
    string ans = "";
    while(n){
        ll q = n/26, r = n%26;
        if(!r) r = 26;
        ans += alpha[r];
        n-=r;
        n /= 26;
    }
    reverse(all(ans));
    cout<<ans;
}
signed main(){
    teevra_gati
    
    solve();

    //cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
    	ll i,j,k,l,m,n;
    	cin>>k>>n;
    	vi v(n);
    	cin>>v;
    	for(auto i:v)k-=i;
    	if(k<0)
    	{
    		cout<<-1;
    		return 0;
    	}
    	cout<<k;
    }
    return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
	int r;
  	cin >> r;
  pr(r*r);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "Local_Debug.h"
using namespace std;
#define Endl endl
#define debug(x) cout << #x << " = " << (x) << endl
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)2e5 + 5;
ll n;
string s;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	while (cin >> n >> s)
	{
		if (s.size() % 2 == 1)
			cout << "No" << endl;
		else
			cout << (s.substr(0, n / 2) == s.substr(n / 2, n / 2) ? "Yes" : "No") << endl;
	}
}
/*
6
abcabc

6
abcadc

1
z
*/

Measured memory_bytes: 256
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    if op == '+':
        print(a+b)
    elif op == '-':
        print(a-b)
    elif op == '*':
        print(a*b)
    elif op == '/':
        print(a//b)
    else :
        break



Measured memory_bytes: 5596
import sys
input=sys.stdin.readline
from collections import deque
from heapq import heappush,heappop
import re

def int_raw():
    return int(input())
 
def ss_raw():
    return input().split()
 
def ints_raw():
    return tuple(map(int, ss_raw()))


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


DIV = 10**9+7

def ncr(n, r, mod=DIV):
	r = min(r, n-r)
	ret = 1
	for i in range(1, r+1):
		ret = ret * (n-i+1) % mod
		ret = ret * mod_inv(i, mod) % mod
	return ret
    
def mod_modify(a,mod):
    return (a+mod)%mod
    
def main():
    ans =0
    N,L = ints_raw()
    if L<0:
        if L+N-1 >=0:
            return sum([L+i for i in range(N)])
        else:
            return sum([L+i for i in range(N-1)])
    for i in range(1,N):
        ans+=(L+i)
    return ans

print(main())


Measured memory_bytes: 38612
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <ctime>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define make make_pair
#define fi first
#define se second
#define vi std::vector<int>;
#define DEBUG cout << "debug" << endl
#define CLOSE ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define CASE int Kase=0;cin>>Kase;for(int kase=1;kase<=Kase;kase++)
const int N = 1e5 + 5;
const int M = 1e6 + 5;
const int MOD = 1e9 + 7;
const int CM = 998244353;
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
template <typename T>
T MAX(T a, T b) { return a > b ? a : b; }
template <typename T>
T MIN(T a, T b) { return a > b ? b : a; }
template <typename T>
T GCD(T a, T b){ return b == 0 ? a : GCD(b, a % b); }
template <typename T>
T LCM(T a, T b){ return a / GCD(a, b) * b; }
template <typename T>
T ABS(T a, T b) { return a > 0 ? a : -a; }
template <typename T>
T ADD(T a, T b, T MOD){ return (a + b) % MOD; }
template <typename T>
T DEL(T a, T b, T MOD) { return ((a - b) % MOD + MOD) % MOD; }
char s[N];
void solve(){
    scanf("%s", s);
    int n = strlen(s);
    int maxx = 0;
    for(int i = 0; i < n; i++) {
        if(s[i] == 'R') {
            int j = i;
            for(; j < n; j++) {
                if(s[j] == 'S') break;
            }
            maxx = max(maxx, j - 1 - i + 1);
            i = j - 1;
        }
    }
    cout << maxx << endl;
}
void TIME(){
    clock_t start, finish;
    double totaltime;
    start = clock();

    // 待测程序

    // CASE {
        solve();
    // }
    // 待测程序

    finish = clock();
    totaltime = (double)(finish - start) / CLOCKS_PER_SEC;
    printf("\nTime:%lfms\n", totaltime * 1000);
}
int main(){
    #ifdef ONLINE_JUDGE
        // CLOSE;
        // CASE {
            solve();
        // }
    #else
        // freopen("./data/a.txt", "r", stdin);
        // freopen("./data/a.txt", "w", stdout);
        TIME();
    #endif
    return 0;
}










Measured memory_bytes: 3260
#include <iostream>

using namespace std;

int main() {
    uint16_t H, W;

    while (cin >> H >> W) {
        if (H == 0 && W == 0)
            break;

        for (uint16_t i = 0; i < H; i++) {
            for (uint16_t j = 0; j < W; j++)
                if ((i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1))
                    cout << "#";
                else
                    cout << ".";

            cout << endl;
        }

        cout << endl;
    }

    return 0;
}

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

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

  if (u == s) {
    cout << a-1 << " " << b << endl;
  } else {
    cout << a << " " << b-1 << endl;
  }

  return 0;
}


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

int N;
int x[10],y[10];
   double dist(int i,int j) {
      double dx=x[i]-x[j];
      double dy=y[i]-y[j];
      return pow(dx*dx+dy*dy,0.5);
   }

void solve(){
   cin>>N;
   for(int i=1;i<=N;i++)cin>>x[i]>>y[i];
double ans=0.0;
for(int i=1;i<=N;i++){
   for(int j=i+1;j<=N;j++){
      ans+=dist(i,j)*2/N;
   }
}
cout<<fixed<<setprecision(10)<<ans<<endl;
  return;
}


int main(void){

solve();
return 0;
}




Measured memory_bytes: 4216
list1 = list( map(int, input().split()) ) 
A,B = list1[0], list1[1] #A個口の電源タップを使って差し込み口をB個作りたい。

x = 1 #現在の差込口の数
count = 0 #電源タップを差し込んだ回数

while x < B:
    x += (A - 1)
    count += 1

print(count)


Measured memory_bytes: 9164
def f(n):
    if n%2==0:
        return int(n/2)
    else:
        return int(3*n+1)

## 最初の入力をリストに入れる
s = int(input())
s_list = [s]

while len(set(s_list)) == len(s_list):
    s_list.append(f(s_list[-1]))

print(len(s_list))

Measured memory_bytes: 3060
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
 
ll i,j,k,ii,jj;
ll n,m,sum,num;
ll ans;
ll a,b,c,d,e;
ll x[100005],y[100005],z[100005];
ll xa[100005],ya[100005],za[100005];
ll dp[100005];
char s[100005];

int main(){
    cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>x[i]>>y[i]>>z[i];
	}
	for(k=0;k<=8;k++){
		a = k;
		for(i=0;i<n;i++){
			if(a%2==1){
				xa[i]=x[i];
			}else{
				xa[i]=-x[i];
			}
		}
		a/=2;
		for(i=0;i<n;i++){
			if(a%2==1){
				ya[i]=y[i];
			}else{
				ya[i]=-y[i];
			}
		}
		a/=2;
		for(i=0;i<n;i++){
			if(a%2==1){
				za[i]=z[i];
			}else{
				za[i]=-z[i];
			}
		}
		for(i=0;i<n;i++){
			dp[i]=xa[i]+ya[i]+za[i];
		}

		sort(dp,dp+n);
		sum=0;
		for(j=0;j<m;j++){
			sum+=dp[n-1-j];
		}
		ans = max(ans,sum);
	}
	p(ans);
			

	return 0;
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define t() int t;cin>>t;while(t--)
#define ff first
#define ss second
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rloop(i,a,b) for(int i=a;i>b;i--)
#define pb push_back
#define mp make_pair
 
 
 
void solvea(){
 
 int n;
 cin>>n;
 int a[n][2];
 for(int i=0;i<n;i++){
 	for(int j=0;j<2;j++)
 		cin>>a[i][j];
 }
 int f=0;
 for(int i=0;i<n-2;i++){
 	for(int j=0;j<2;j++){
 		if(a[i][j]==a[i][j+1] && a[i+1][j]==a[i+1][j+1] && a[i+2][j]==a[i+2][j+1]){
 			f=1;
 			break;
 		}
 		if(f)
 		break; 	}
 }
 if(f)
 	cout<<"Yes\n";
 else cout<<"No\n";
 
 }
 
	
	
 
void solveb(){
	t(){
		
	}
}
 
int main()
{
	#ifndef ONLINE_JUDGE
		//for getting input from input1.txt
		freopen("input1.txt","r",stdin);
		//for getting output from output.txt
		freopen("output.txt","w",stdout);
		#endif
 
		solvea();
return 0;
}

Measured memory_bytes: 3632