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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define IN freopen("transposition-115.txt","r",stdin)
#define OUT freopen("dichromatic.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 2000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define SZ(v) ((int)v.size())
#define sq(x)  ((x)*(x))

using namespace __gnu_pbds;
using namespace std ;

#define maxn 300005
#define mod 1000000007LL

typedef pair<i64,i64> pii ;
typedef  long long int T ;

char s[maxn] ;

bool possible(int x, int y)
{
    for(int i= x ; i<y ; i++)if( s[i]=='#' && s[i+1]=='#' ) return false ;
    return true ;
}

int main()
{
    int n , a , b , c , d ;
    scanf("%d %d %d %d %d",&n,&a,&b,&c,&d) ;

    scanf("%s",s+1) ;

    if( !possible(a,c) || !possible(b,d) )
    {
        printf("No\n") ;
        return 0 ;
    }

    if( c<d )
    {
        printf("Yes\n") ;
        return 0 ;
    }

    for(int i=b; i<=d ; i++)
    {
        if( s[i]=='.' && s[i-1] =='.' &&s[i+1]=='.' )
        {
            printf("Yes\n") ;
            return 0 ;
        }
    }

    printf("No\n") ;

    return 0 ;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define forN(n, N) for(int n=0; n<N; n++)
#define res_out(ans) cout << ans << "\n";

int L[200];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    int c = 1;
    cin >> S;
    forN(i, S.size()){
        if(S[i] == 'N' && c % 2 != 0)c *= 2;
        else if(S[i] == 'W' && c % 3 != 0)c *= 3;
        else if(S[i] == 'S' && c % 5 != 0)c *= 5;
        else if(S[i] == 'E' && c % 7 != 0)c *= 7;
        if(c % 210 == 0)break;
    }
    if(c == 10 || c == 21 || c == 210)res_out("Yes")
    else res_out("No")
    return 0;
}

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

int M, N;
string s[510];
vector<pii> g[26];
int ans = 0;

bool check(int y, int x, int dy, int dx, char ch) {
  if (s[y][x] != '.' && s[y][x] != ch) return false;
  int ny, nx;
  ny = y + dy, nx = x;
  while (true) {
    if (s[ny][nx] == ch) break;
    if (s[ny][nx] != '.') return false;
    ny += dy;
  }
  ny = y, nx = x + dx;
  while (true) {
    if (s[ny][nx] == ch) break;
    if (s[ny][nx] != '.') return false;
    nx += dx;
  }
  return true;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> M >> N;
  for (int i = 0; i < M; i++) {
    cin >> s[i];
    for (int j = 0; j < N; j++) {
      if (s[i][j] == '.') continue;
      g[s[i][j] - 'A'].emplace_back(i, j);
    }
  }
  bool update = true;
  while (update) {
    update = false;
    for (int i = 0; i < 26; i++) {
      if (g[i].empty()) continue;
      if (abs(g[i][0].first - g[i][1].first) + abs(g[i][0].second - g[i][1].second) == 1) continue;
      int sy, sx;
      int gy, gx;
      int dy, dx;
      tie(sy, sx) = make_tuple(g[i][0].first, g[i][1].second);
      tie(gy, gx) = make_tuple(g[i][1].first, g[i][0].second);
      dy = gy - sy > 0 ? 1 : gy - sy < 0 ? -1 : 0;
      dx = gx - sx > 0 ? 1 : gx - sx < 0 ? -1 : 0;
      if (check(sy, sx, dy, dx, char(i + 'A'))) {
        for (pii p : g[i]) {
          s[p.first][p.second] = '.';
        }
        ans += 2;
        g[i].clear();
        update = true;
        continue;
      }
      tie(sy, sx) = make_tuple(g[i][1].first, g[i][0].second);
      tie(gy, gx) = make_tuple(g[i][0].first, g[i][1].second);
      dy = gy - sy > 0 ? 1 : gy - sy < 0 ? -1 : 0;
      dx = gx - sx > 0 ? 1 : gx - sx < 0 ? -1 : 0;
      if (check(sy, sx, dy, dx, char(i + 'A'))) {
        for (pii p : g[i]) {
          s[p.first][p.second] = '.';
        }
        ans += 2;
        g[i].clear();
        update = true;
        continue;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3332
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long total = 0;
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            total += num;
            array[i] = num;
        }
        long minDiff = Long.MAX_VALUE;
        long aSum = 0;
        for(int i = 0; i < n - 1; i++) {
            aSum += array[i];
            long bSum = total - aSum;
            long diff = Math.abs(aSum - bSum);
            minDiff = Math.min(minDiff, diff);
        }
        System.out.println(minDiff);
    }
}


Measured memory_bytes: 64896
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var s = input.ReadLine();
        var n = s.Length;

        var wcount = 0;
        long sum = 0;

        for(int i=0; i<n; i++) {
            if(s[i] == 'W') {
                sum += i - wcount;
                wcount++;
            }
        }

        return sum;
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }

}


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

using namespace std;

#define pb push_back
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long ll;

const int mn = 2e5 + 5;
const int mod = 998244353;

int n;
vector<int> g[mn];

int main() {
#ifdef LOCAL
	freopen("../1.txt", "r", stdin);
	freopen("../2.txt", "w", stdout);
	size_t bg = clock();
#endif
	scanf("%d", &n);
	int n1 = 1;
	while (n1 < n) n1 <<= 1;
	if (n1 == n) {
		puts("No");
		return 0;
	}
	if (n == 3) {
		puts("Yes\n"
		     "1 2\n"
		     "2 3\n"
		     "3 4\n"
		     "4 5\n"
		     "5 6");
		return 0;
	}
	n1 >>= 1;
	for (int i = 1; i < n1 - 1; i++) {
		g[i].pb(i + 1);
		g[i + n].pb(i + n + 1);
	}
	g[n1 - 1].pb(n + 1);
	g[n1 + n].pb(1);
	g[n1 + 1 + n].pb(n1 + n);
	g[n1 + 1].pb(1);
	g[n1].pb(n1 + 1);
	for (int i = n1 + 2; i <= n; i++) {
		g[i].pb(i - n1 + n);
		g[i + n].pb(i - 1);
	}
	puts("Yes");
	for (int i = 1; i <= 2 * n; i++) {
		for (auto &j:g[i])
			printf("%d %d\n", i, j);
	}
#ifdef LOCAL
	size_t ed = clock();
	printf("time: %f\n", (double) (ed - bg) / CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 13696
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        String str = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";
        int[] iArray = Arrays.stream(str.split(", ")).mapToInt(Integer::parseInt).toArray();

        Scanner sc = new Scanner(System.in);
    	int k = sc.nextInt();
    	System.out.println(iArray[k-1]);
    }
}


Measured memory_bytes: 28628
using System;
using System.Collections.Generic;
using System.Linq;


class Atcoder
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());

        var s = Console.ReadLine().Split().Select(int.Parse).ToArray();

        long sum = 0;

        for (int i = 0; i < s.Length; i++)
        {
            for (int j = 0; j < s.Length; j++)
            {
                if (i == j)
                {
                    continue;
                }
                sum += s[i] * s[j];
            }
        }


        Console.WriteLine(sum/2);

    }
}

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

main(){
	int n,i=0;
	cin>>n;
	long a[n];
	for(;i<n;cin>>a[i],i++);
	sort(a,a+n);
	for(;i-1;(*a*=__gcd(a[n-i+1],n-i+1l))%=998244353,i--);
	cout<<*a<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<queue>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
struct E{
  ll p,t;
};
bool operator<(E a,E b){
  return a.t>b.t;
}
ll L,n;
set<ll> node;
map<ll,vector<E> > edge;

void input(){
  cin>>L>>n;
  node.insert(0);
  node.insert(L);
  for(ll i=0;i<n;i++){
    ll p,d,t;
    cin>>p>>d>>t;
    edge[p].push_back((E){d,t});
    node.insert(p);
    node.insert(p+d);
  }
  for(auto i:node){
    //cout<<i<<endl;
  }
}

ll solve(){
  priority_queue<E> q;
  q.push((E){0,0});
  map<ll,int> dp;
  for(auto i:node){
    dp[i]=-1;
  }
  while(!q.empty()){
    E tmp = q.top();q.pop();
    if(tmp.p == L)return tmp.t;
    if(dp[tmp.p]!=-1&& tmp.t>=dp[tmp.p])continue;
    dp[tmp.p]=tmp.t;
    //cout<<tmp.p<<" "<<tmp.t<<endl;
    const vector<E> e = edge[tmp.p];
    for(int i=0;i<e.size();i++){
      q.push((E){tmp.p+e[i].p,tmp.t+e[i].t});
    }
    for(auto i:node){
      if(i>tmp.p){
        q.push((E){i,tmp.t + (i-tmp.p)});
      }
    }
  }
  return 0;
}


int main(){
  input();
  cout<<solve()<<endl;
}


Measured memory_bytes: 35792
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top,S[1000];

void push(int x){
  S[++top] = x;
}

int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a,b;
  top = 0;
  char s[100];

  while(scanf("%s",s) != EOF){
    if(s[0] == '+'){
      a = pop();
      b = pop();
      push(a+b);
    }
    else if(s[0] == '-'){
      b = pop();
      a = pop();
      push(a-b);
    }
    else if(s[0] == '*'){
      a = pop();
      b = pop();
      push(a*b);
    }
    else{
      push(atoi(s));
    }
  }

  printf("%d\n",pop());

  return 0;
}

Measured memory_bytes: 548
S = list(map(int, input()))
t = 0
if(S[0]==0):
    for i in range(len(S)):
        if(i%2 == 1):
            if(S[i] == 0):
                t+=1
        if(i%2 == 0):
            if(S[i] == 1):
                t+=1
else:
    for i in range(len(S)):
        if(i%2 == 1):
            if(S[i] == 1):
                t+=1
        if(i%2 == 0):
            if(S[i] == 0):
                t+=1
print(t)

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

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

if(a%3 == 0 || b %3 == 0 || (a+b)%3 == 0){
    cout << "Possible" <<endl;
}else cout << "Impossible" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <functional>

using namespace std;

int main(){

	int i, j;
	string S, out;
	
	cin >> S;
	
	out = "No";
	
	for(i = 0; i < S.length(); i++){
		if(S[i] == 'C'){
			for(j = 1; i + j < S.length(); j++){
				if(S[i+j] == 'F') out = "Yes";
			}
		}
	}

	cout << out << endl;

	return 0;

}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main()
{
    int n,t,x,y;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d",&t,&x,&y);
        if(x+y>t)//???,???????????
        {
            printf("No\n");
            return 0;
        }
        if((x+y)%2==0&&t%2==1)//??????????
        {
            printf("No\n");
            return 0;
        }
        if((x+y)%2==1&&t%2==0)//??
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");//????No??return 0?,???????Yes?
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i *= 2){
        if(i * 2 > n){
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long

int N;
//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  vector<int> A,order;
  cin >> N;
  A.resize(N + 1);
  order.resize(N + 1);

  REP(i,N){
  	cin >> A[i];
  	order[A[i]] = i + 1;
  }
  for(int i = 1; i <= N; i++){
  	cout << order[i] << " ";
  }
  cout << endl;
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 2432
#include<stdio.h>   //ABC085C - Otoshidama

int main(){

    int n,Y;
    scanf("%d %d",&n,&Y);

    int x,y,z;
    int sum;
    int flag=0;

    for(int i=0;i<=n;i++){
        for(int j=0;j<=n-i;j++){
            sum=i*10000+j*5000+(n-i-j)*1000;
            if(sum==Y){
                flag=1;
                x=i;
                y=j;
                z=n-i-j;
                break;
            }
        }
        if(flag){
            break;
        }
    }
    if(flag){
        printf("%d %d %d",x,y,z);
    }else{
        printf("%d %d %d",-1,-1,-1);
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main () {
    int A, B, C, K;

    cin >> A >> B >> C >> K;

    int ans = 0;

    if(K > A) {
        ans += A;
        K -= A;
    } else {
        cout << K << endl;
        return 0;
    }

    if(K > B) {
        K -= B;
    } else {
        cout << ans << endl;
        return 0;
    }

    if(K > C) {
        ans -= C;
    } else {
        ans -= K;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
n = int(input())
a = list(map(int,input().split()))
p = [0 for _ in range(10**6)]
pr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]
#print(pr)
at = 0
for x in a:
  d = int(x)
  for y in pr:
    if d % y == 0:
      if p[y] == 1:
        at = 1
      else:
        p[y] = 1
      while d % y == 0:
        d //= y
  if d != 1:
    if p[d] == 1:
      at = 1
    else:
      p[d] = 1
  if at == 1:
    break
  #print(p)
if at == 0:
  print('pairwise coprime')
  exit()
now = int(a[0])
for x in a:
  big,sml = x,now
  while sml:
    #print(big,sml)
    big,sml = sml,big%sml
  now = big
  if now == 1:
    print('setwise coprime')
    exit()
  #print(now)
print('not coprime')

Measured memory_bytes: 217908
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(){
    cout << "Yes" << endl;
}

void no (){
    cout << "No" << endl;
}

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int main() {
    ll a, b, c, d; cin >> a >> b >> c >> d;
    vector<ll> ar = {a,b,c,d};
    ll ans = max({a*c,a*d,b*c,b*d});
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main() {
	long long a,b;
	cin>>a>>b;
	cout<<(a*b)/__gcd(a,b);
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a, b, target;

    // read line
    scanf("%d %d", &a, &b);
    if ( b > 9 && b < 100 ) {
        target = a*100 + b;
    }else if ( b < 10 ) {
        target = (a*10) + b;
    } else {
        target = (a*1000) + b;
    }
    for (int i=1;i<316;i++){
        if ( target == i*i ){
            printf("Yes\n");
             return 0;
        }
    }
    printf("No\n"); 
    return 0;
}

Measured memory_bytes: 128
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
#sys.stdin = open("input.txt", "r")
#sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)



n,m=l()
A=[input() for i in range(n)]
r=set()
c=set()
for i in range(n):
    if "#" in A[i]:
        r.add(i)

for i in range(m):
    x=[A[j][i] for j in range(n)]
    if "#" in x:
        c.add(i)
for i in range(n):
    if(i not in r):
        continue
    for j in range(m):
        if(j in c):
            print(A[i][j],end="")
    print()
    



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

#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> using V = vector<T>;
using P = pair<int, int>;

/*
 *  *  */

set<int> st;
V<int> lis;

void dfs(int x){
  if(x > 3234566667) return;
  if(st.count(x)) return;
  st.insert(x);
  lis.emplace_back(x);

  if(x%10 != 0) dfs(x*10+x%10-1);
  dfs(x*10+x%10);
  if(x%10 != 9) dfs(x*10+x%10+1);
}

signed main() {
  int k;
  cin >> k;

  rep(i, 1, 10){
    dfs(i);
  }

  sort(all(lis));

  cout << lis[k-1] << endl;

  return 0;
}





Measured memory_bytes: 5748
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    String s1, s2, s3;

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

    void run() {
        FastReader sc = new FastReader();
        s1 = sc.next();
        s2 = sc.next();
        s3 = sc.next();
        solve();
    }

    void solve() {
        System.out.println(s1.substring(0, 1).toUpperCase() +
                s2.substring(0, 1).toUpperCase() +
                s3.substring(0, 1).toUpperCase());
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  string s;
  cin >> a >> b >> s;
  bool ans = true;
  if(s[a] != '-') ans = false;
  for(int i = 0; i < a+b+1; i++) {
    if(i != a and (s[i] -'0' < 0 or s[i] -'0' > 9)) ans = false;
  }  
  cout << (ans ?"Yes" :"No") << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define COUT(x) cout<<x<<"\n"

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
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; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = lcm(a, v[i]);} return a;}


void Main()
{
	ll N,K;
	ll res;
	string sres;
	string s;
	cin>>N>>K;
	VI a(N,0);

	REP(i,K){
		ll d;
		cin>> d;
		VI ai(d);
		REP(j,d){
			ll b;
			cin >> b;
			b--;
			a[b]=1;
		}
	}
	REP(i,SIZE(a)){
		if(a[i]==0) res++;
	}



	cout << res << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 3664
#include <iostream>

using namespace std;

int main(){
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	char range = 101;
	char Alice[range] = {0}, Bob[range] = {0};
	char array[range];

	int sum = 0;
	for(int i = 0; i < range; i++){
		if(i >= A && i <= B){
			Alice[i] = 1;
		}
		if(i >= C && i <= D){
			Bob[i] = 1;
		}

		array[i] = Alice[i] * Bob[i];
		sum += array[i];
	}



	if(sum == 0){
		cout << sum << endl;
	}else{
		sum -= 1;
		cout << sum << endl;
	}

	return 0;
}

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

b=input()

i=0
left=0
right=0
previous=0
minleft=0
ans=0 

def process_peak(): 
    global left
    global minleft
    global right
    global ans
    if minleft > left:
        ans = ans + minleft
        ans = ans + left * (left -1) // 2
    else:
        ans = ans + left * (left +1) //2

    ans = ans + right * (right - 1 )//2
    # print("process",ans,left,right,minleft)
    minleft = right
    right = 0


for c in b:
    # print(c,previous)
    if c == ">": # Down 
        if previous == 0: # Start 
            left = 1
        elif previous == 1: # Beyond Peak
            # print("Beyond peak")
            process_peak()
            left = 1 
        else: # Keep down 
            left = left + 1
        previous = -1 
    else: # Up  
        if previous == 0: # Start 
            right  = 1
        elif previous == 1: # Keep up 
            right = right + 1 
        else: # Beyond Bottom 
            # print("Beyond Bottom")
            right = 1
        previous = 1
    # print(ans,left,right,minleft)


process_peak()
ans += minleft 
    
print(ans)

Measured memory_bytes: 4212
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i= (a); i<(b); i++)
#define REP(i,n) for(int i=0;i < (n);i++)
#define ALL(obj) (obj).begin(), (obj).end()
using namespace std;

const long long INF = 1LL << 60;
const int MOD = (int)1e9 + 7;
typedef long long ll;
//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
int n;
vector<vector<int>> board(8,vector<int>(8,0));

void change(vector<vector<int>> &board,int h,int w,int num){
    REP(i,8){
        board[h][i]+=num;board[i][w]+=num;
    }
    board[h][w]-=num*3;
    //右上
    for(int i=h-1;i>=0;i--){
        if(h-i+w<0 || h-i+w>7)continue;
        board[i][h-i+w]+=num;
    }
    //右下
    for(int i=h+1;i<=7;i++){
        if(h-i+w<0 || h-i+w>7)continue;
        board[i][h-i+w]+=num;
    }
    //左上
    for(int i=h-1;i>=0;i--){
        if(w-(h-i)<0 || w-(h-i)>7)continue;
        board[i][w-(h-i)]+=num;
    }
    //左下
    for(int i=h+1;i<=7;i++){
        if(w-(h-i)<0 || w-(h-i)>7)continue;
        board[i][w-(h-i)]+=num;
    }
}

void setqueen(int q,vector<int>queen,vector<vector<int>>board){
    if(q==8){
        REP(i,8){
            int h=queen[i];
            char ans[]="........";
            ans[h]='Q';
            cout << ans << endl;
        }
        exit(0);
    }
    if(queen[q]!=-1){
        setqueen(q+1,queen,board);
    } else {
        for(int i=0;i<8;i++){
            if(board[q][i]<1){
                queen[q]=i;
                change(board,q,i,1);
                setqueen(q+1,queen,board);
                change(board,q,i,-1);
            }
        }
    }
}

signed main () {
    scanf("%d",&n);
    vector<int> queen(8,-1);
    REP(i,n){
        int a,b;scanf("%d %d",&a,&b);
        //a--;b--;
        queen[a]=b;
        change(board,a,b,1);
    }
    setqueen(0,queen,board);
}


Measured memory_bytes: 3252
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<climits>
#include<unordered_map>
#include<set>
#define loopi(x,y) for(int i = x;i<(y);i++)
#define loopj(x,y) for(int j = x;j<(y);j++)


#define newline cout<<"\n";
#define ll long long int
using namespace std;
#define mod  1000000007

int cost[1000000];

int jump(vector<int> & ht, int i, int n)
{
	if (i >= n - 1)
	{
		return 0;
	}
	int a = INT_MAX, b = INT_MAX;

	if (i + 1 < n)
	{
		if (cost[i + 1] == -1)
		{
			cost[i + 1] = jump(ht, i + 1, n);
		}
		a = abs(ht[i + 1] - ht[i]) + cost[i + 1];
	}
	if (i + 2 < n)
	{
		if (cost[i + 2] == -1)
		{
			cost[i + 2] = jump(ht, i + 2, n);
		}
		b = abs(ht[i + 2] - ht[i]) + cost[i + 2];
	}
	return cost[i] = min(a, b);
}


int main() {

	ios_base :: sync_with_stdio(false);
	cin.tie(NULL);

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif


	int n;
	cin >> n;

	vector<int> ht(n);

	loopi(0, n)
	{
		cin >> ht[i];
		cost[i] = -1;
	}

	cout << jump(ht, 0, n);

	return 0;
}


Measured memory_bytes: 5760
#include<stdio.h>

int a[3000];
int b[3000];

int main(){
int i;
for( i=0;;i++){
scanf("%d %d",&a[i],&b[i]);
if(a[i]==0 && b[i]==0)
break;
}

for(int j=0;j<i;j++){
for(int k=0;k<a[j];k++){
for(int p=0;p<b[j];p++){
if(p==0 || p==(b[j]-1) || k==0 || k ==(a[j]-1))
printf("#");
else printf(".");
}
printf("\n");

}
printf("\n");
} 
return 0;
}


Measured memory_bytes: 2048
#include<stdio.h>
#include<string.h>

int main(void) {

	char acContest[4];		//先週行われたコンテストがABCとARCのどちらだったかを入れる配列変数
	//文字列を入力
	scanf("%s", acContest);
	//入力される文字列に応じた文字列を表示
	if (strcmp(acContest, "ABC") == 0) {
		printf("\nARC\n");
	}
	else {
		printf("\nABC\n");
	}
	return 0;
}

Measured memory_bytes: 2076
#include<cstdio>
#include<cstring>
#include<vector>
#define mod 1000000007
using namespace std;

int n,m,k[10],s[10][10],p[10],ans,su[10];

void dfs(int x){
    int res=1,cnt=0;
    if(x==n){
        for(int i=0;i<m;i++){
            cnt=0;
            for(int j=0;j<k[i];j++){
                if(su[s[i][j]-1]){
                    cnt++;
                }
            }
            if(cnt%2!=p[i]){
                res=0;
            }
        }
        ans+=res;
    }
    else{
        su[x]=1;
        dfs(x+1);
        su[x]=0;
        dfs(x+1);
    }
}
int main(){
    scanf("%d %d",&n,&m);
    for(int i=0;i<m;i++){
        scanf("%d",&k[i]);
        for(int j=0;j<k[i];j++){
            scanf("%d",&s[i][j]);
        }
    }
    for(int i=0;i<m;i++){
        scanf("%d",&p[i]);
    }
    dfs(0);
    printf("%d\n",ans);
}

Measured memory_bytes: 128
from collections import defaultdict


def read_input():
    h, w, n = map(int, input().split())
    alist = []
    for i in range(n):
        (px, py) = map(int, input().split())
        alist.append((px, py))

    return h, w, n, alist


def count_arround(px, py, count):
    for xx in [-2, -1, 0]:
        for yy in [-2, -1, 0]:
            count[(px+xx, py+yy)] += 1


def is_area(p, h, w):
    if 1 <= p[0] <= h - 2:
        if 1 <= p[1] <= w - 2:
            return True
    return False


def submit():
    h, w, n, alist = read_input()

    count = defaultdict(int)

    for a in alist:
        count_arround(a[0], a[1], count)

    counts = count.items()
    counts = [c[1] for c in counts if is_area(c[0], h, w)]

    result = []
    s = 0
    for i in range(1, 10):
        result.append(sum([1 for c in counts if c == i]))
        s += result[-1]

    print((h - 2)*(w - 2) - s)
    for r in result:
        print(r)


if __name__ == '__main__':
    submit()


Measured memory_bytes: 213748
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for i in reversed(range(A + 1)):
	for j in range(B + 1):
		sum = X - (500 * i) - (100 * j)
		if sum < 0:
			break
		if sum // 50 <= C:
			cnt += 1
print(cnt)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
#include <algorithm>
#include <cmath>
int main() {
	// your code goes here
	int n,d;
	cin>>n>>d;
	int a[n][d];
	for(int x=0;x<n;x++)
	{
	    for(int y=0;y<d;y++)
	    cin>>a[x][y];
	}
	int c=0,s=0;
	for(int x=0;x<n-1;x++)
	{
	    for(int y=x+1;y<n;y++)
	    {
	        s=0;
	        for(int z=0;z<d;z++)
	        {
	            s+=pow(abs(a[x][z]-a[y][z]),2);
	        }
	        double dis=sqrt(s);
	        int d1=sqrt(s);
	        if((double)d1==dis)
	        c++;
	    }
	    
	}
	
	cout<<c<<endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n; cin >> n;
  vector<int> a(n);
  bool judge = true;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    if(a[i] % 2 == 0){
      if(!(a[i] % 3 == 0 || a[i] % 5 == 0)) judge = false;
    }
  }
  cout << (judge ? "APPROVED" : "DENIED") << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();
void solve(long long N, std::vector<long long> A);

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

void Main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
}

void solve(long long N, std::vector<long long> A){
    ll mny = 1000;
    REP(i, N-1){
        if(A[i] < A[i+1]){
            ll s = mny / A[i];
            mny -= s*A[i];
            mny += s*A[i+1];
        }
    }
    cout << mny << el;
}



Measured memory_bytes: 3688
// Template
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
#include <complex>
#define rep(i, x) for (int i = 0; i < (x); ++i)
#define rng(i, x, y) for (int i = (x); i < (y); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
void solve();
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    solve();
    return 0;
}

// Main Code
void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    
    sort(all(a));
    reverse(all(a));
    ll ans1 = 0, ans2 = 0;
    if (n & 1) {
        rng(i, 0, (n - 1) / 2) ans1 += 2 * a[i];
        rng(i, (n - 1) / 2, (n + 3) / 2) ans1 -= a[i];
        rng(i, (n + 3) / 2, n) ans1 -= 2 * a[i];
    } else {
        rng(i, 0, n / 2 - 1) ans1 += 2 * a[i];
        rng(i, n / 2 - 1, n / 2) ans1 += a[i];
        rng(i, n / 2, n / 2 + 1) ans1 -= a[i];
        rng(i, n / 2 + 1 , n) ans1 -= 2 * a[i];
    }
    if (n & 1) {
        rng(i, 0, (n - 3) / 2) ans2 += a[i] * 2;
        rng(i, (n - 3) / 2, (n + 1) / 2) ans2 += a[i];
        rng(i, (n + 1) / 2, n) ans2 -= a[i] * 2;
    }
    cout << max(ans1, ans2) << "\n";
    return;
}


Measured memory_bytes: 4004
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define INF 1000000000
#define MAX_V 100000

struct edge{long to,cost;};
typedef pair<LL,long> P;//firstは最短距離,secondは頂点番号

long V;
vector<edge> G[MAX_V];
LL d[MAX_V];

void dijkstra(long s){
	priority_queue<P,vector<P>,greater<P> > que;
	fill(d,d+V,INF);
	d[s]=0;
	que.push(P(0,s));
	
	while(!que.empty()){
		P p=que.top();que.pop();//仮の最短距離が短い順に取り出す
		long v=p.second;
		if(d[v]<p.first)continue;
		REP(i,G[v].size()){
			edge e=G[v][i];
			if(d[e.to]>d[v]+e.cost){
				d[e.to]=d[v]+e.cost;
				que.push(P(d[e.to],e.to));//仮の最短距離と頂点の組を更新が行われる度に追加していく
			}
		}
	}
}

int main(){
	long E,r;
	cin>>V>>E>>r;
	REP(i,E){
		edge e;long f;
		cin>>f>>e.to>>e.cost;
		G[f].PB(e);
	}
	dijkstra(r);
	REP(i,V){
		if(d[i]<INF)cout<<d[i]<<endl;
		else cout<<"INF"<<endl;
	}
	return 0;
}

Measured memory_bytes: 17720
import java.util.*;

public class Main {
    public static void main(String[] args){
        long N;
        Scanner sc = new Scanner(System.in);
        N = sc.nextLong();
        if (N % 2 == 1) System.out.print("0\n");
        else {
            long ans = 0;
            long a = 5;
            while (2*a <= N) {
                ans += N/(2*a);
                a *= 5;
            }
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 21844
#include <iterator>
#include <list>
#include <algorithm>
#include <iostream>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <sstream>
#include <iomanip>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
using namespace std;

int main() {
  string S; cin >> S;
  for (int i = 1; i <= S.size(); i++) {
    char c = S[i-1];
    if (i % 2) {
      if (!(c =='R' || c == 'U' || c == 'D')) {
        cout << "No" << endl;
        return 0;
      }
    } else {
      if (!(c == 'L' || c == 'U' || c == 'D')) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <set>
long long A,B,K;
using namespace std;
int main(){
	int A,B,C;
	int num[3];
	for(int i=0;i<3;i++){
		cin>>num[i];
	}
	int t;
	for(int i=0;i<3;i++){
		for(int j=0;j<3-i-1;j++){
			if(num[j]>num[j+1]){
				t=num[j];
				num[j]=num[j+1];
				num[j+1]=t;
			}
		}
	}
	A=num[0],B=num[1],C=num[2];//C是最大的数
	int num1=C-A,num2=C-B;
	int sum=0;
	if(num1%2==0&&num2%2==0){
		sum=num1/2+num2/2; 
	}else if(num1%2==0&&num2%2!=0){
		sum=sum+num1/2;
		//num2是一个奇数
		int t=(num2+1)/2;
		sum=sum+t;
		B=B+2*t;
		int d=B-C;
		if(d%2==0){
			sum=sum+d/2*2;
		}else{
			sum=sum+1;
			d=d-1;
			sum=sum+d/2*d;
		}
	}else if(num1%2!=0&&num2%2==0){
		sum=sum+num2/2;
		//num2是一个奇数
		int t=(num1+1)/2;
		sum=sum+t;
		A=A+2*t;
		int d=A-C;
		if(d%2==0){
			sum=sum+d/2*2;
		}else{
			sum=sum+1;
			d=d-1;
			sum=sum+d/2*d;
		}
	}else{//二者都是奇数 
		//num1,num2都为奇数
		sum=sum+1;
		num1--,num2--; 
		sum=sum+num1/2+num2/2;
	}
	cout<<sum<<endl; 
	//下面开始进行判断 
	
	
	
	
	
	
	
	
	
	

	return 0;
} 

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
ans=10**15
for i in[-1,1]:
    ansi,sum=0,0
    for a in A:
        sum+=a
        if sum*i<=0:ansi+=abs(sum-i);sum=i
        i*=-1
    ans=min(ans,ansi)
print(ans)

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

int main() {
	int n;
	std::cin >> n;
	int cur = 0;
	int answ = 0;
	for (int i = 0; i < n; ++i)
	 {
	 	int z;
	 	std::cin >> z;
	 	if (z == i + 1) {
	 		cur++;
	 	}
	 	else {
	 		answ += (cur + 1) / 2;
	 		cur = 0;
	 	}
	 }
	answ += (cur + 1) / 2; 
	std::cout << answ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;

int main(){
    int n,p;
    cin>>n>>p;
    string s;
    cin>>s;
    if(p==2||p==5){
        ll ans=0;
        for(int i=0;i<n;i++){
            if((s[i]-'0')%p==0LL){
                ans +=i+1;
            }
            
        }
        cout<<ans<<endl;
    }
    else{
        vector<ll>U(n+1,0);
        map<int,int>mods;//各mod pに何個値があるか
        mods[0]=1;
        ll ans=0;
        int pw[n+1];
        pw[0]=1;
        //この処理をしないと値が大きくなりすぎる
        for(int i=1;i<=n;i++) pw[i]=10*pw[i-1] %p;

        for(int i=n-1;i>=0;i--){
            //各Uを求める
            U[i]=(U[i+1]+(s[i]-'0')*pw[n-i-1])%p;
            ans+=mods[U[i]];
            mods[U[i]]++;
        }

        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3204
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        String s = scan.next();
        int max = 0;
        int x = 0;
        for(int i = 0; i < n; i++){
            if(s.charAt(i) == 'I'){
                x++;
            }else{
                x--;
            }
            if(x > max){
                max = x;
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

int K, S;

void _main() {
    cin >> K >> S;
    int ans = 0;
    for (int X = 0; X <= K; ++X) {
        for (int Y = 0; Y <= S - X && Y <= K; ++Y) {
            int Z = S - X - Y;
            ans += (0 <= Z && Z <= K);
        }
    }
    cout << ans << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("output.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<map>
typedef long long int ll;
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 EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const int INF = 2000000000;
    ll N,M,K;
    ll A[100010],B,C,X;
    bool F=true;
    ll ans=0;
    string S,T[200000];

int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N){
        cin>>S;
        if(S=="AC")A[0]++;
        if(S=="WA")A[1]++;
        if(S=="TLE")A[2]++;
        if(S=="RE")A[3]++;
    }
    cout<<"AC x "<<A[0]<<endl;
    cout<<"WA x "<<A[1]<<endl;
    cout<<"TLE x "<<A[2]<<endl;
    cout<<"RE x "<<A[3]<<endl;
    return 0;
}


Measured memory_bytes: 9908
//Chandigarh University
//author:- shivamkr21 (pseduo coders)
#include<bits/stdc++.h>
#define lli long long int
#define endl "\n"
// #define loop(i,n) for(long long int (a)=i, (a)<n, (a)++)
#define mod 1000000007
using namespace std;
int main()
{
	lli n,m;
  	cin>>n>>m;
	if(n==m)
      cout<<"Yes";
  	else
      cout<<"No";
	return 0;
}


Measured memory_bytes: 256