akhauriyash/Code-Regression huggingface dataset:
import math

A, B = map(int, input().split())

A_row = math.ceil((A-1)/50)
if A_row == 0:
    A_row = 1
A_row_full = (A-1)//50
B_row = math.ceil((B-1)/50)
if B_row == 0:
    B_row = 1
B_row_full = (B-1)//50

print("100 ", (A_row+B_row)*2)

A_mod = (A-1)%50
B_mod = (B-1)%50

if A_row == A_row_full:
    A_add = ''
    A_add2 = ''
else:
    A_add = '.#'
    A_add2 = '##'

if B_row == B_row_full:
    B_add = ''
    B_add2 = ''
else:
    B_add = '.#'
    B_add2 = '..'


for i in range(50):
    print('.#'*A_row_full + (A_add if i < A_mod else A_add2) + '.#'*B_row_full + (B_add if i < B_mod else B_add2))
    print('##'*A_row + '..'*B_row)


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

int main() {
    char c;
    cin >> c;
    vector <char> a(30);
    a[0] = 'a';
    a[1] = 'b';
    a[2] = 'c';
    a[3] = 'd';
    a[4] = 'e';
    a[5] = 'f';
    a[6] = 'g';
    a[7] = 'h';
    a[8] = 'i';
    a[9] = 'j';
    a[10] = 'k';
    a[11] = 'l';
    a[12] = 'm';
    a[13] = 'n';
    a[14] = 'o';
    a[15] = 'p';
    a[16] = 'q';
    a[17] = 'r';
    a[18] = 's';
    a[19] = 't';
    a[20] = 'u';
    a[21] = 'v';
    a[22] = 'w';
    a[23] = 'x';
    a[24] = 'y';
    a[25] = 'z';
    int ggg;
    rep(i, 26){
        if(c == a[i]){
            ggg = i;
        }
    }
    cout << a[ggg+1] << endl;
}

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

string s;
int f[26];
void solve(){
    cin >> s;
    for(char i:s)
        f[i-'a']++;
    bool fl = 1;
    for(int i=0;i<26;++i)
        if(f[i]&1)
            fl = 0;
    cout << (fl ? "Yes":"No") << "\n";
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t =1;
    while(t--)
        solve();
    return 0;
}



Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll dist[222222];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll k;cin>>k;
  for(int i=0;i<222222;i++)dist[i]=llINF;
  priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>>que;
  que.push({1,1});
  while(!que.empty()){
    ll now=que.top().F;
    ll cost=que.top().S;
    now%=k;
    que.pop();
    if(dist[now]<=cost)continue;
    dist[now]=cost;
    if(dist[(now+1)%k]>cost+1){que.push({(now+1)%k,cost+1});}
    if(dist[(now*10)%k] > cost){que.push({(now*10)%k,cost});}
  }
  cout<<dist[0]<<endl;
  return 0;
}


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

int main() {
  int H,W;
  cin >> H >> W;
  vector<string> S(50) ;
  for(int i=0;i<H;i++){cin >> S.at(i);}

  vector<int> dx={1,0,-1,0,1,-1,-1,1};
  vector<int> dy={0,1,0,-1,1,1,-1,-1};
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
     int cnt=0;
     if((S.at(i)).at(j)=='.'){
      for(int k=0;k<8;k++){
          int xx = i + dx.at(k);
          int yy = j + dy.at(k);
          if (xx>=0 && xx<H && yy>=0 && yy<W){
            if((S.at(xx)).at(yy)=='#'){cnt++;}
          }
        
        (S.at(i)).at(j) = cnt +'0';
      } 
     }
    }
  }
  for(int i=0;i<H;i++){cout<<S.at(i)<<endl;}

}


Measured memory_bytes: 256
dic={}
s=raw_input().lower().split()
for word in s:
    try:
        dic[word]+=1
    except:
        dic[word]=1

m=0
l=0
for word, e in dic.items():
   if e>m:
       m=e
       w1=word
   if len(word)>l:
       l=len(word)
       w2=word

print w1, w2

Measured memory_bytes: 4224
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string c = "CODEFESTIVAL2016";
  string s; cin >> s;
  int ans = 0;
  FOR(i,0,16) {
    if(s[i] != c[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import heapq
k,t = map(int,input().split())
a = list(map(int,input().split()))
pre = a.index(max(a))
res = 0
while k>0:
    a[pre] -=1
    k -=1
    if k==0:
        break
    else:
        Conf=[]
        Conf = a[:]
        if t>1:
            Conf[pre] = -1
            preV = max(Conf)
            prei = a.index(preV)
            if preV==0:
                res+=1
            else:
                pre = prei
        else:
            res+=1
print(res)

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

int N;
int X[200001];
int Y[200001];

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> X[i];
		Y[i] = X[i];
	}
	sort(Y + 1, Y + N + 1);

	for (int i = 1; i <= N; i++) {
		if (lower_bound(Y + 1, Y + N + 1, X[i]) - Y <= N / 2) {
			cout << Y[N / 2 + 1] << endl;
		}
		else if (lower_bound(Y + 1, Y + N + 1, X[i]) - Y >= N / 2 + 1) {
			cout << Y[N / 2] << endl;
		}
	}
}

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

void fnInput(vector<int> &rviTrg, vector<int> &rviSch)
{
  int iTrgCnt;
  cin >> iTrgCnt;

  rviTrg.resize(iTrgCnt + 1);
  for (int i = 0; i < iTrgCnt; i++)
    cin >> rviTrg[i];

  int iSchCnt;
  cin >> iSchCnt;

  rviSch.resize(iSchCnt);
  for (int i = 0; i < iSchCnt; i++)
    cin >> rviSch[i];
}

void fnLinSch(vector<int> &rviTrg, const vector<int> &cnrviSch, int &riFnd)
{
  size_t zMaxSiz = rviTrg.size() - 1;
  for (size_t zi = 0; zi < cnrviSch.size(); zi++)
  {
    rviTrg[zMaxSiz] = cnrviSch[zi];
    size_t zj = 0;
    while (rviTrg[zj] != cnrviSch[zi])
      zj++;
    if (zj != zMaxSiz)
      riFnd++;
  }
}

void fnResult(int a_iFnd)
{
  cout << a_iFnd << endl;
}

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

  vector<int> viTrg, viSch;
  int iFnd = 0;

  fnInput(viTrg, viSch);
  fnLinSch(viTrg, viSch, iFnd);
  fnResult(iFnd);

  return 0;
}

Measured memory_bytes: 1244
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define INF 1000000000000
#define MOD 1000000007
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3)                                                 \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << endl
#define debug_4(x1, x2, x3, x4)                                             \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5)                                         \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

using namespace std;
using ll = long long;

char itoc(const ll i) { return (i + '0' + 49); }

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

    string name;
    while (true) {
        n--;
        ll amari = n % 26;
        ll div = n / 26;
        debug(amari, div);
        name.push_back(itoc(amari));
        if (div == 0) {
            break;
        }
        n = div;
    }
    reverse(name.begin(), name.end());
    cout << name << endl;
    return 0;
}

Measured memory_bytes: 3104
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, M: int):
    if N == M:
        ret = YES
    else:
        ret = NO
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
(N,) = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

numLeafs = A
if not (0 <= numLeafs[0] <= 1):
    print(-1)
    exit()

# Bound max non-leaves by how many expansions the previous level can do
maxNonLeafs = [None for i in range(N + 1)]
maxNonLeafs[0] = 1 - numLeafs[0]
for i in range(1, N + 1):
    maxNonLeafs[i] = 2 * maxNonLeafs[i - 1] - numLeafs[i]
    if maxNonLeafs[i] < 0:
        print(-1)
        exit()

# Tighten max non-leaves by how many available children are on next level
maxNonLeafs[N] = 0
for i in range(N - 1, -1, -1):
    maxNonLeafs[i] = min(maxNonLeafs[i], maxNonLeafs[i + 1] + numLeafs[i + 1])


count = 0
for i in range(N + 1):
    count += maxNonLeafs[i] + numLeafs[i]
print(count)


Measured memory_bytes: 700164
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define int long long int
#define vi vector<int>
#define vvi vector < vi >
#define pii pair<int,int>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define tr(k,st,en) for(int k = st; k <= en ; k++)
#define trb(k,en,st) for(int k = en; k >= st ; k--)
using namespace std;

int32_t main()
{
    std::ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    int ans = 0;
    tr(i,k,n+1){
        ans  = (ans + (i*(n-i+1)) + 1)%mod;
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> PP;
int dx[4]={0,-1,0,1},dy[4]={1,0,-1,0};
bool check(int n,int m,int x,int y) {return x>=0&&x<n&&y>=0&&y<m;}
int N(char c) {
  if(c=='N') return 0;
  if(c=='W') return 1;
  if(c=='S') return 2;
  return 3;
}

int main() {
  int n,m;
  while(cin >> m >> n && n) {
    string s[n];
    vector<PP> v;
    for(int i=0; i<n; i++) {
      cin >> s[i];
      for(int j=0; j<m; j++) {
        if(isalpha(s[i][j])&&s[i][j]!='X') v.push_back(PP(P(i,j),N(s[i][j])));
      }
    }
    for(int t=0; t<=180; t++) {
      vector<P> d[n][m];
      int c=0;
      for(int i=0; i<v.size(); i++) {
        int nx=v[i].first.first,ny=v[i].first.second,k=v[i].second;
        if(s[nx][ny]=='X') continue;c++;
        for(int j=0; j<4; j++) {
          int kk=(k+j)%4;
          int x=nx+dx[kk],y=ny+dy[kk],f=0;
          if(!check(n,m,x,y)||s[x][y]=='#') continue;
          for(int l=0; l<v.size(); l++) {
            if(s[x][y]!='X'&&v[l].first==P(x,y)) f=1;
          }
          if(f) continue;
          d[x][y].push_back(P((kk+2)%4,i));
          v[i].second=(kk+3)%4;
          break;
        }
      }
      if(!c) {cout << t << endl;goto end;}
      for(int i=0;i<n;i++) {
        for(int j=0;j<m;j++) {
          if(!d[i][j].size()) continue;
          sort(d[i][j].begin(),d[i][j].end());
          P p=d[i][j][0];
          v[p.second]=PP(P(i,j),(p.first+1)%4);
        }
      }
    }
    cout << "NA" << endl;
  end:;
  }
  return 0;
}


Measured memory_bytes: 1244
import java.util.Scanner;

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

      int b;

      int c;

      int d;

          b = a % 60;

          c = a % 3600 / 60;

          d = a /3600;

 
       System.out.println(d+":"+c+":"+b);
  }
}
     


Measured memory_bytes: 26188
import java.util.Scanner;
import java.util.HashMap;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.lang.Math;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (h[i] >= k) ans += 1;
        }
        System.out.println(ans);
    }

}


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

int main() {
	int N; cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];

	vector<int> b(N);
	int ans = 0;
	for (int i = 0; i < N; i++) {
		while (a[i] % 2 == 0) {
			a[i] /= 2;
			b[i]++;
		}
		ans += b[i];
	}

	cout << ans << endl;
}

Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            long a = in.nextLong();
            long b = in.nextLong();
            long x = in.nextLong();
            long da = a % x == 0 ? (a / x) - 1 : a / x;
            long db = b / x;
            out.println(db - da);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

    }
}



Measured memory_bytes: 23380
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

sum_b = sum(B)
additional = 0
for i in range(n-1):
  if A[i]+1 == A[i+1]:
    additional += C[A[i]-1]
print(sum_b + additional)

Measured memory_bytes: 3064
#include <stdio.h>
int main(){
    int n;
    scanf("%d",&n);

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

    long long cnt=0;
    int sum=0;
    int l=0,r=0;
    while(l<n){
        while(r<n && (sum&a[r])==0){
                cnt+=r-l+1;
                sum+=a[r++];
        }
        sum-=a[l++];
    }
    printf("%lld\n",cnt);
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
double dp[305][305][305];
int cnt[10];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        cnt[x]++;
    }
    for(int k=0;k<=n;k++)
        for(int j=0;j<=n;j++)
            for(int i=0;i<=n;i++)
                if(i||j||k)
                {
                    int sum = i+j+k;
                    if(i) dp[i][j][k] += dp[i-1][j][k]*i/sum;
                    if(j) dp[i][j][k] += dp[i+1][j-1][k]*j/sum;
                    if(k) dp[i][j][k] += dp[i][j+1][k-1]*k/sum;
                    dp[i][j][k] += (double) n/sum;
                }
    printf("%.15lf\n",dp[cnt[1]][cnt[2]][cnt[3]]);

}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; ++i)

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

    int ans = 0;
    rep(i, n){
           int l, r;
           cin >> l >> r;

            ans += r -l +1;
    }


    cout << ans << endl;

    return 0;
}


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

import numpy as np

# TESTCASE #
test = ""
#test = \
"""
3 2
5 1 4
2 3
1 5
ans:
14
"""

"""
10 3
1 8 5 7 100 4 52 33 13 5
3 10
4 30
1 4
ans:
338
"""

"""
3 2
100 100 100
3 99
3 99
ans:
300
"""

"""
11 3
1 1 1 1 1 1 1 1 1 1 1
3 1000000000
4 1000000000
3 1000000000
ans:
10000000001
"""
############
test = list(reversed(test.strip().splitlines()))
if test:
    def input2():
        return test.pop()
else:
    def input2():
        return input()
### MAIN ###
        
n, m = map(int, input2().split())
a = np.array(list(map(int, input2().split())), dtype="int64")
bcs = [tuple(map(int, input2().split()))[::-1] for _ in range(m)]

a.sort()
bcs = sorted(bcs, reverse=True)

i = 0
for query in bcs:
    #print(query)
    a[i:i+query[1]] = np.maximum(a[i:i+query[1]], query[0])
    i += query[1]
    #print(a)    
print(np.sum(a))
    



Measured memory_bytes: 29448
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    char c;
    cin>>c;
    int k=c-'a';
    if(k>=0 && k<=26){
        cout<<'a'<<endl;
    }
    else{
        cout<<'A'<<endl;
    }
    return 0;
}


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

int main() {
  int H,W;
  cin>>H>>W;
  char a;
  char vec[H][W];
  for(int k=0; k<H; k++ ){
  for(int j=0; j<W; j++){
  cin>>a;
  vec[k][j]=a;}}
  for(int j=1; j<W-1; j++){
  if(vec[0][j]=='#'&&vec[0][j-1]=='.'&&vec[1][j]=='.'&&vec[0][j+1]=='.'){ 
  cout<<"No"<<endl;
  goto as;}}
  for(int j=1; j<W-1; j++){
  if(vec[H-1][j]=='#'&&vec[H-1][j+1]=='.'&&vec[H-2][j]=='.'&&vec[H-1][j-1]=='.'){ 
  cout<<"No"<<endl;
  goto as;}}
  for(int k=1; k<H-1; k++){
  if(vec[k][0]=='#'&&vec[k+1][0]=='.'&&vec[k-1][0]=='.'&&vec[k][1]=='.'){ 
  cout<<"No"<<endl;
  goto as;}}
  for(int k=1; k<H-1; k++){
  if(vec[k][W-1]=='#'&&vec[k+1][W-1]=='.'&&vec[k][W-2]=='.'&&vec[k-1][W-1]=='.'){ 
  cout<<"No"<<endl;
  goto as;}}
  for(int k=1; k<H-1; k++ ){
  for(int j=1; j<W-1; j++){
  if(vec[k][j]=='#'&&vec[k][j+1]=='.'&&vec[k+1][j]=='.'&&vec[k-1][j]=='.'&&vec[k][j-1]=='.'){ 
  cout<<"No"<<endl;
  goto as;}
  else if(k==H-2&&j==W-2)
  cout<<"Yes"<<endl;
  else continue;}}
  as:
  cout<<endl;}
  


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdio>
#define maxn 200005
#define mod 998244353
using namespace std;
int n,k,cnt;
long long A;
int l[maxn],r[maxn];
long long tree[maxn];

int lowbit(int x) {return x&(-x);}
void add(int x,long long v){for(;x<=n;x+=lowbit(x)) (tree[x]+=v)%=mod;}
long long getsum(int x){A=0;for(;x>=1;x-=lowbit(x)) (A+=tree[x])%=mod;return A%mod;}

int main()
{
	cin>>n>>k;
	for(int i=1;i<=k;i++) cin>>l[i]>>r[i];
	
	add(1,1);
	for(int i=1;i<=n;i++)
	for(int j=1;j<=k;j++)
	if(i>l[j]) {
		add(i,(getsum(i-l[j])-getsum(max(0,i-r[j]-1))+mod)%mod);
//		cout<<i-l[i]<<" "<<i-r[i]-1<<endl;
//		cout<<i<<" "<<getsum(i-l[i])<<" "<<getsum(max(0,i-r[i]-1))<<endl;
	}
//	for(int i=1;i<=n;i++) cout<<getsum(i)-getsum(i-1)<<" ";
//	cout<<endl;
	cout<<(getsum(n)%mod-getsum(n-1)%mod+mod)%mod<<endl;
}

Measured memory_bytes: 5180
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <map>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	int x, y;
	cin >> x >> y;
	int ans = x + (int)(y / 2);
	cout << ans << endl;
	return 0;
}

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

#define sz(x) (int)(x.size())
#define fr(i,a,b) for(int i=a;i<b;++i)
#define fdr(i,a,b) for(int i=b-1;i>=a;--i)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
/////////////////////

int const N = 1e5 + 41;
ll const INF = 1e9 * 1LL * 1e9 + 41;

priority_queue<int> q;

ll pr[N], suf[N];
pll d[N];
ll a[N], b[N], c[N];
int n, x, y, z;

void solve(){
	cin >> x >> y >> z;
	n = x + y + z;
	ll add = 0;
	
	fr(i, 0, n){
		cin >> a[i] >> b[i] >> c[i];
		add += c[i];
		a[i] -= c[i];
		b[i] -= c[i];
		d[i] = mp(a[i] - b[i], i);
	}
	sort(d, d+n);

	fr(i, 0, N) pr[i] = suf[i] = -INF;
	ll s = 0;
	fr(i, 0, n){
		ll id = d[i].second;
		s += b[id];
		q.push(-b[id]);
		if(i) pr[i] = pr[i-1];
		if(sz(q) > y){
			ll v = q.top();
			q.pop();
			s += v;
		}
		if(sz(q) >= y) pr[i] = s;
	}
	s = 0;
	while(!q.empty()) q.pop();

	
	fdr(i, 0, n){
		ll id = d[i].second;
		s += a[id];
		q.push(-a[id]);
		suf[i] = suf[i+1];
		if(sz(q) > x){
			ll v = q.top();
			q.pop();
			s += v;
		}
		if(sz(q) >= x) suf[i] = s;
	}
	
	ll ans = -(4LL * INF);
	fr(i, 0, n-1){
		ans = max(ans, pr[i] + suf[i+1]);
	}
	cout << ans + add << endl;
}

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

	solve();

	return 0;
}

Measured memory_bytes: 6396
#import sys
#input = sys.stdin.buffer.readline
import collections

def main():
    N,M = map(int,input().split())
    ans = [False for _ in range(N)]
    pe = [0 for _ in range(N)]
    count = 0
    for i in range(M):
        pro,judge = map(str,input().split())
        pro = int(pro)-1
        if ans[pro]:
            continue
        else:
            if judge == "AC":
                ans[pro] = True
                count += pe[pro]
            else:
                pe[pro] += 1
                
    ans = collections.Counter(ans)
                
    print(ans[True],count)
        
if __name__ == "__main__":
    main()

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

int main() {
    int D, N, ans;
    cin >> D >> N;
    switch(D) {
    case 0:
        ans = 1;
        break;
    case 1:
        ans = 100;
        break;
    case 2:
        ans = 10000;
        break;
    }
    if(N == 100) {
        cout << ans * N + ans << endl;
    } else {
        cout << ans * N << endl;
    }
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 100010;
const LL mod = 998244353;
LL fct[MC*3];
LL inv[MC*3];
int N,M;
bool A[MC] , B[MC] , C[MC] , D[MC];
int cA,cB,cC,cD;

void build(){
	fct[0] = 1;
	repp(i,1,MC*3) fct[i] = fct[i-1] * i % mod;
	LL z = fct[MC*3-1];
	inv[MC*3-1] = 1;
	for(int i = mod-2 ; i > 0 ; i >>= 1){
		if(i%2) (inv[MC*3-1] *= z) %= mod;
		z = z * z % mod;
	}
	repm(i,MC*3-1,0) inv[i-1] = inv[i] * i % mod;
}

LL comb(int x , int y){
	return fct[x+y] * inv[x] % mod * inv[y] % mod;
}

LL solve(){
	int w = cA , x = cB , y = 0 , z = 0;
	LL rv = 0 , tmp = 0;
	repp(i,0,N){
		if(A[i]||B[i]){
			(tmp += (cC?comb(y+z,cC-1):(y+z==0))) %= mod;
			if(A[i]&&B[i]) (tmp *= 2) %= mod;
			if(A[i]){--w; ++y;}
			if(B[i]){--x; ++z;}
			(rv += tmp * (cD?comb(w+x,cD-1):(w+x==0))) %= mod;
		}
	}
	return rv;
}

int main(){
	build();
	scanf("%d%d" , &N , &M);
	repp(i,0,N){
		char z;
		scanf(" %c" , &z);
		A[i] = z == '1';
		if(A[i]) ++cA;
	}
	repp(i,0,N){
		char z;
		scanf(" %c" , &z);
		B[i] = z == '1';
		if(B[i]) ++cB;
	}
	repp(i,0,M){
		char z;
		scanf(" %c" , &z);
		C[i] = z == '1';
		if(C[i]) ++cC;
	}
	repp(i,0,M){
		char z;
		scanf(" %c" , &z);
		D[i] = z == '1';
		if(D[i]) ++cD;
	}
	if(cA + cB + cC + cD == 0) return (printf("1\n"),0);
	LL ans = solve();
	swap(A,C);
	swap(B,D);
	swap(N,M);
	swap(cA,cC);
	swap(cB,cD);
	printf("%lld\n" , (ans + solve()) % mod);
	return 0;
}


Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int answer = 0;
		for (int i = 0; i <= (int) Math.pow(n,0.5)+1; i++) {
			if (Math.pow(i, 2) <= n && Math.pow(i, 2) > answer) {
				answer = (int) Math.pow(i, 2);	//powはdoubleを返すのでanswerに渡すにはintにキャストする
			}
		}
		System.out.println(answer);
		sc.close();
	}

}


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

const int MAX = 510000;
const int MOD = 1e+09 + 7;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    int64_t N,K;
    cin >> N >> K;
    COMinit();
    
    for ( int i = 1; i <= K; ++i){
        cout << ( COM(K-1,i-1) * COM(N-K+1,i) ) % MOD << endl;
    }
    
    return 0;
}


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

int main(){
	int n, t;
	cin >> n >> t;
	int ans = t, a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n - 1; i++){
		ans += min(t, a[i + 1] - a[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <list>
#include <map>
#include <vector>

using namespace std;



int main(void){
    map<int,int> mp,sumList;
    vector<int>input;
    int N,A,sum=0;

    cin>>N;

    for(int i=0;i<N-1;i++){
        cin>>A;
        mp[A]=mp[A]+1;
    }
    
    for(int i=0;i<N;i++){
        cout<< mp[i+1] <<endl;
    }








    return 0;
}



Measured memory_bytes: 13004
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
#define FF first
#define SS second
using namespace std ;
 
const lli dx4[] = {-1, 0, 1, 0};
const lli dy4[] = {0, 1, 0, -1};
const lli dx8[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const lli dy8[] = {0, 1, 0, -1, -1, 1, -1, 1};
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count()); // can give negative values too

#define N 200005

void solve()
{
	string s;
	cin>>s;

	cout<<s[0]<<s[1]<<s[2];
}

int main()
{
/////////////////////////////////////
    fastio;
/////////////////////////////////////  

    lli t;
    t=1;
    while(t--)
    	solve();
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int n;
    cin >> n;

    string s;
    cin >> s;

    int ans = 1;
    char prev = s[0];

    rep(i, 1, n) {
        if (prev != s[i]) {
            ++ans;
            prev = s[i];
        }
    }
    cout <<ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << v.first << " " << v.second;
    return ostr;
}

int nCr(int n, int r) {
    int result = 1;
    rep(i, r) {
        result *= (n - i);
    }
    rep(i, r) {
        result = result / (i + 1);
    }

    return result;
}

int main() {
    int N, W; cin >> N >> W;
    vector<int64> w(N), v(N); rep(i, N) cin >> w[i] >> v[i];

    int s = 1;
    rep(i, N) s += v[i];

    vector<vector<int64>> dp(N+1, vector<int64>(s, INF));

    rep(i, N) {
        dp[i+1] = dp[i];
        rep(j, s) {
            if (j <= v[i]) {
                dp[i+1][j] = min(dp[i+1][j], w[i]);
            }
            if (dp[i][j] != INF) {
                dp[i+1][j + v[i]] = min(dp[i+1][j + v[i]], dp[i][j] + w[i]);
            }
        }
    }

    int64 ans = 0;
    rep(i, s) {
        if (dp[N][i] <= W) {
            ans = i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 80256
#include <iostream>
#include <numeric>
#include <algorithm>
#include <vector>
#include <array>
#include <string>
#include <queue>
#include <cmath>
#include <iterator>
#include <math.h>
#include <cstdio>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <tuple>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

namespace atcoder{
    void judge_outer(bool judge_exp,string ok = "Yes",string ng = "No"){
        if(judge_exp){
            cout << ok << endl;
        }else{
            cout << ng << endl;
        }
    }
}

using namespace atcoder;


int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    if(a>c){
        cout <<"NO" << endl;
    }else if(a+b<c){
        cout <<"NO" << endl;
    }else{
        cout <<"YES" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll H, W;
    cin >> H >> W;
    vector<ll> cnt(26, 0);
    Rep (i, H*W) {
        char a;
        cin >> a;
        cnt[a-'a']++;
    }

    priority_queue<ll> q;
    for (ll e : cnt) {
        if (e != 0) {
            q.push(e);
        }
    }

    ll n4 = 0, n2 = 0, n1 = 0;

    if (H*W % 2 == 1) {
        n1 = 1;
        n2 = (H-1)/2 + (W-1)/2;
        n4 = (H-1/2) * (W-1)/2;
    } else if (H % 2 == 1 || W % 2 == 1) {
        if (W % 2 == 1) swap(H, W);
        n2 = W/2;
        n4 = W/2 * (H-1)/2;
    } else {
        n4 = W*H/4;
    }

    while (q.size()) {
        ll target = q.top();
        q.pop();
        if (n4 > 0 && target >= 4) {
            target -= 4;
            n4--;
        } else if (n2 > 0 && target >= 2) {
            target -= 2;
            n2--;
        } else if (n1 > 0 && target >= 1) {
            target--;
            n1--;
        } else {
            q.push(target);
            break;
        }

        if (target != 0) q.push(target);
    }

    if (q.size()) cout << "No\n";
    else cout << "Yes\n";
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
// #pragma GCC optimize("Ofast")
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define reps(i, s, n) for (int i = s; i < (int)(n); ++i)
using namespace std;
using ll = long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
constexpr int INF = 1e9 + 7;
constexpr ll LINF = 1LL << 60;

void solve() {
    int H, W, M;
    cin >> H >> W >> M;
    set<ll> bomb;
    V<int> H_bomb(H), W_bomb(W);
    rep(i, M) {
        int h, w;
        cin >> h >> w;
        h--;
        w--;
        bomb.insert(h * W + w);
        H_bomb[h]++;
        W_bomb[w]++;
    }
    int h_max = *max_element(H_bomb.begin(), H_bomb.end());
    int w_max = *max_element(W_bomb.begin(), W_bomb.end());
    V<int> h_max_p;
    V<int> w_max_p;
    rep(i, H) {
        if (H_bomb[i] == h_max) h_max_p.push_back(i);
    }
    rep(i, W) {
        if (W_bomb[i] == w_max) w_max_p.push_back(i);
    }
    int ans = h_max + w_max;
    if ((ll)h_max_p.size() * (ll)w_max_p.size() <= (ll)3e6) {
        // 爆破対象がマスにあるかチェック
        int aru = 1;
        for (auto&& hp : h_max_p) {
            for (auto&& wp : w_max_p) {
                auto ser = *bomb.lower_bound(hp * W + wp);
                if (ser != hp * W + wp) aru = 0;
            }
        }
        ans -= aru;
    }
    cout << ans << "\n";
}
int main() {
    cin.tie(nullptr);
    // ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 23748
n, k = map(int, input().split())
p = float(1 / n)

if (k > n):
    ans = 0
    loop = n

else:
    ans = float((n - k + 1) / n)
    loop = k - 1

for i in range(1, loop + 1):
    b = 0
    check = i
    while (check < k):
        check *= 2
        b += 1

    ans += float(p * 0.5 ** b)

print(ans)


Measured memory_bytes: 3060
#include <vector>
#include <iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> ans = { 2, 3, 4, 9 };
	if (N >= 4) {
		N -= 4;
	}
	else {
		ans = { 2, 3, 25 };
		N -= 3;
	}
	for (int i = 8; i <= 30000 && N >= 2; i += 6) {
		ans.push_back(i);
		ans.push_back(i + 2);
		N -= 2;
	}
	for (int i = 15; i <= 30000 && N >= 2; i += 12) {
		ans.push_back(i);
		ans.push_back(i + 6);
		N -= 2;
	}
	for (int i = 6; i <= 30000 && N >= 1; i += 6) {
		ans.push_back(i);
		N -= 1;
	}
	for (int i : ans) {
		cout << i << ' ';
	}
	return 0;
}

Measured memory_bytes: 760
# Problem D - Derangement

# input
n = int(input())
p_list = list(map(int, input().split()))

# initialization
min_cost = 0

# count step
for i in range(len(p_list) - 1):
    if p_list[i]==i+1:
        # swap
        tmp = p_list[i]
        p_list[i] = p_list[i+1]
        p_list[i+1] = tmp
        min_cost += 1

# last step
if p_list[n-1]==n:
    # swap
    tmp = p_list[n-1]
    p_list[n-1] = p_list[n-2]
    p_list[n-2] = tmp
    min_cost += 1

# output
print(min_cost)


Measured memory_bytes: 14008
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define ALL(v) v.begin(), v.end()
ll mod = 1e9 + 7;
ll mul(ll a, ll b)
{
	return (a*b) % mod;
}
ll power(ll a, ll b)
{
	ll  re = 1;
	while(b)
	{
		while(!(b&1))a=mul(a,a),b>>=1;;
		re = mul(re,a);
		b--;
	}
	return re;
}
vector<ll> vec(1000010);
ll ncr(ll a, ll b)
{
	return (mul(vec[a], power(mul(vec[a-b], vec[b]), mod -2 )) );
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	

	ll a;
	cin >> a;
	cout << a*a*3LL;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;


int main(){
  string S, T;
  cin>>S>>T;
  vector<vector<ll>> dp(3010, vector<ll>(3010, 0));
  ll SS, TT;
  SS=S.size();
  TT=T.size();
  rep(i, SS){
    rep(j, TT){
      dp[i+1][j+1]=max(dp[i][j+1], dp[i+1][j]);
      if(S.at(i)==T.at(j)){
        dp[i+1][j+1]=max(dp[i][j]+1, dp[i+1][j+1]);
      }
    }
  }
  /*rep(i, SS+1){
    rep(j, TT+1){
      cout<<dp[i][j]<<" ";
      
    }
    cout<<endl;
  }
  cout<<dp[SS][TT]<<endl;
  */
  ll Sd=SS;
  ll Td=TT;
  vector<char> Ans(0);
  while(dp[Sd][Td]>0){
    while(dp[Sd-1][Td]==dp[Sd][Td]){
      Sd--;
    }
    while(dp[Sd][Td-1]==dp[Sd][Td]){
      Td--;
    }
    Ans.push_back(S.at(Sd-1));
    Sd--;
    Td--;
  }
  cout<<"";
  per(i, dp[SS][TT]-1){
    cout<<Ans[i];
  }
  cout<<endl;
  return 0;
} 

Measured memory_bytes: 74256
#include<bits/stdc++.h>
using namespace std;
main(){
  string a;
  int h[1000]={},cnt=0;
  cin>>a;
  for(int i=0;i<a.size();i++)h[(int)a[i]]++;
  for(int i=0;i<1000;i++)if(h[i]%2==1)cnt++;
  cout<<cnt/2<<endl;
  return 0;
}

Measured memory_bytes: 3156
const Main = input => {
    input = input.split("\n");
    const n = parseInt(input[0], 10);
    const arr = input[1].split(" ").map(value => parseInt(value, 10));

    //10^18は精度外なのでBigIntを使わないといけない
    let result = 1n;
    if(arr.includes(0)) {
        result = 0;
    } else {
        for(let i = 0; i < n; i++) {
            result *= BigInt(arr[i]);
            if(result > BigInt(10 ** 18)) {
                result = -1;
                break;
            }
        }
    }

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

Measured memory_bytes: 44060
#![allow(non_snake_case)]

use proconio::input;
use proconio::marker::Usize1;
use proconio::fastout;

use std::collections::VecDeque;

#[fastout]
fn main() {
    input! {
        N: usize,
        M: usize
    }
    let mut g = vec![Vec::<usize>::new(); N];
    for _ in 0..M {
        input! {
            A: Usize1,
            B: Usize1
        }
        g[A].push(B);
        g[B].push(A);
    }

    let mut d = vec![N; N];
    let mut target = vec![0usize; N];

    let mut q = VecDeque::<usize>::new();
    d[0] = 0;
    q.push_back(0);


    while !q.is_empty() {
        let u = q.pop_front().unwrap();
        for &v in &g[u] {
            if d[v] > d[u] + 1 {
                d[v] = d[u] + 1;
                target[v] = u;
                q.push_back(v);
            }
        }
    }

    println!("Yes");
    for i in 1..N {
        println!("{}", target[i] + 1); // 1-based indexing
    }
}


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

int main()
{
    int n; cin >> n;
    long long d[n+1]; 
    for (int i = 1; i <= n; ++i)
        cin >> d[i];
    long long ans[n+1];
    long long num = 0;
    for (int i = 1; i <= n; ++i)
    {
        if (i&1) num += d[i];
        else num -= d[i];
    }
    ans[1] = num;
    for (int i = 2; i <= n; ++i)
    {
        long long prev = ans[i-1]/2;
        ans[i] = (d[i-1]-prev)*2;
    }
    for (int i = 1; i <= n; ++i)
        cout << ans[i] << ' ';
}

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
const ll N=1e7+7;
ll n;
ll divi[N];
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    cin>>n;
    repA(i,1,n)
    {
      for(ll j=i;j<=n;j+=i) ++divi[j];
    }
    ll ans=0;
    repA(i,1,n)
    {
      ans+=(i*divi[i]);
    }
    cout<<ans<<'\n';
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


Measured memory_bytes: 81772
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  string s,t;
  cin>>s>>t;
  ll m=s.length();
  ll n=t.length();
  ll l[m+1][n+1];
  for(ll i=0;i<=m;i++)
  {
    for(ll j=0;j<=n;j++)
    {
      if(i==0||j==0)
        l[i][j]=0;
      else if(s[i-1]==t[j-1])
        l[i][j]=1+l[i-1][j-1];
      else
        l[i][j]=max(l[i-1][j],l[i][j-1]);
    }
  }
  ll len=l[m][n];
  char lcs[len+1];
  lcs[len]='\0';
  ll i=m,j=n;
  while(i>0||j>0)
  {
    if(s[i-1]==t[j-1])
    {
      lcs[len-1]=s[i-1];
      i--;
      j--;
      len--;
    }
    else if(l[i-1][j]>l[i][j-1])
    {
      i--;
    }
    else
    {
      j--;
    }
  }
  cout<<lcs;
    return 0;
}

  

Measured memory_bytes: 73968
//
// Created by misclicked on 2020/3/14.
//

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

#define ONLINE_JUDGE
#ifdef ONLINE_JUDGE
#define cerr if (false) cerr
#endif

vector<int> vec;
int N;

void dfs(int n, int sz) {
    if (n == N) {
        for (auto it:vec) {
            cout << (char) ('a' + it);
        }
        cout << endl;
        return;
    }
    for (int i = 0; i <= sz; i++) {
        vec.push_back(i);
        if (i == sz)
            dfs(n + 1, sz + 1);
        else
            dfs(n + 1, sz);
        vec.pop_back();
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#else
    ios_base::sync_with_stdio(false);
    cin.tie();
#endif
    cin >> N;
    dfs(0, 0);
}

Measured memory_bytes: 1536
#include <stdio.h>

int main() {
  int n,i;
  scanf("%d",&n);
  for(i=0;i<=10000;){
    if(n>i&&n<=i+1000){
      printf("%d",i+1000-n);
      break;
    } else {
    i+=1000;
    }
  }
  return 0;
}


Measured memory_bytes: 1736
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <string.h>
#include <math.h>

using namespace std;

int main(){
	int N, K;
	cin >> N >> K;

	if (N % K != 0)
		cout << "1" << endl;
	else
		cout << "0" << endl;
	return 0;
}

Measured memory_bytes: 256
import           Data.List                      ( unfoldr )

main :: IO ()
main = do
  x <- solve <$> readLn
  putStrLn $ if x == "" then "0" else x

solve :: Int -> String
solve = reverse . unfoldr f . negate
 where
  f x =
    let (v, m) = x `divMod` (-2)
    in  if x == 0 then Nothing else Just (if m /= 0 then '1' else '0', v)


Measured memory_bytes: 508
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
     String[] nyu=sc.nextLine().split(" ");

String[] nyuA=nyu[0].split("");
String[] nyuB=nyu[1].split("");
String[] nyuC=nyu[2].split("");

//     String nyu=sc.nextLine();
//int A=Integer.parseInt(nyu[0]);
//int B=Integer.parseInt(nyu[1]);
//int C=Integer.parseInt(nyu[2]);
//int D=Integer.parseInt(nyu);



//StringBuffer sb = new StringBuffer(nyu);
//		String dst = sb.reverse().toString();

//     String nyu2=sc.nextLine();
//int E=Integer.parseInt(nyu2);



//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(C){
case 7:
case 5:
case 3:
System.out.println("YES") ;
break;
default:
System.out.println("NO") ;

break;
}
*/

//int res=Math.min((A*B),C);

//for(String tem:nyu){
//if(tem.equals("1"))res++;
//}
//int res=0;
//for(int i=0;i<300;i++){
//if(num[i]==1)res=i;
//}

//char[] c = nyu.toCharArray();


//System.out.println(nyu+"-"+line_r_2+"-"+nyu2+"-"+line_r_1);



if(nyuA[nyuA.length-1].equals(nyuB[0]) && nyuB[nyuB.length-1].equals(nyuC[0])){
//double res=Math.ceil((AB)/2);

System.out.println("YES");
//}else if((C-B)<A){
//System.out.println("safe");

}else{
System.out.println("NO");

}




	}
}

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

int main(void){
    char S[105];
    int i,j,k = 0;
    
    scanf("%s",S);
    j = strlen(S) - 1;
    
    for(i = 0;i < j;i++){
        if(S[i] != S[j]){
            k++;
        }
        j--;
    }
    printf("%d\n",k);
  
    return 0;
}

Measured memory_bytes: 128