akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

constexpr int MOD = 998244353;

int main(void){
    Cin(int, n);
    Cins(int, n, a);
    if(a[0] > 0){
        Cout(0);
        return 0;
    }
    Sort(a);
    if(n > 1 && a[1] == 0){
        Cout(0);
        return 0;
    }
    
    vc<int> c(a.back()+1);
    For(i, n) c[a[i]] ++;
    // Couts(c);
    
    ll ans = 1;
    For(i, a.back()){
        Rep(c[i+1]) ans = (ans * c[i]) % MOD;
    }
    Cout(ans);
}




Measured memory_bytes: 1024
def main():
    buf = input()
    buflist = buf.split()
    A = int(buflist[0])
    B = int(buflist[1])
    C = int(buflist[2])
    len_list = list(sorted([A,B,C]))
    if len_list == [5,5,7]:
        print("YES")
    else:
        print("NO")

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
def main():
    n = int(input())
    A = [0]+list(map(int, input().split()))+[0]

    S = 0
    for i in range(n+1):
        S += abs(A[i] - A[i+1])
    for i in range(1,n+1):
        print(S - abs(A[i-1]-A[i])-abs(A[i]-A[i+1]) + abs(A[i-1]-A[i+1]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 64748
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,pre=1000000,x,ans=0;scanf("%d",&n);
	for(int i=1;i<n;i++){
		scanf("%d",&x);
		ans+=min(x,pre);
		pre=x;
	}
	printf("%d",ans+pre);
	return 0;
}

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

const int mod = 998244353;
int n, s, a[3000], dp[3001] = { 1 };

int main() {
	cin >> n >> s;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		for (int j = s; j >= 0; j--) {
			if (j + a[i] <= s)
				dp[j + a[i]] = (dp[j + a[i]] + dp[j]) % mod;
			dp[j] = dp[j] * 2 % mod;
		}
	cout << dp[s] << endl;

}


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

int main(){
  int n,k,c;
  for(;;){
    c=0;
    cin>>n;
    if(!n)break;

    for(int i=0;i<n*(n-1)/2;i++)
      cin>>k,c+=k;

    cout<<c/(n-1)<<endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007
 
signed main(){

	lli n;
	cin>>n;
	vector<lli> a(n);
	REP(i,0,n)cin>>a[i];

	lli ans = 0;
	lli before = a[n-1];
	lli now = before;
	if(a[0]!=0){
		cout<<-1<<endl;
		return 0;
	}
	for(lli i=n-2;i>=0;i--){
		if(DEBUG)cout<<"now="<<now<<" ans="<<ans<<endl;
		if(a[i]==now-1){

		}
		else if(a[i]>=now){
			ans+=before;
			now = a[i];
			before = a[i];
		}
		else{
			cout<<-1<<endl;
			return 0;
		}
		now = a[i];
	}
	ans += before;

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int cou[100000];
int main(){
    int N;
    cin>>N;
    for(int i=1;i<=100;i++){
        for(int j=1;j<=100;j++){
            for(int k=1;k<=100;k++){
                cou[i*i+j*j+k*k+i*j+j*k+k*i]++;
            }
        }
    }
    for(int i=1;i<=N;i++)cout<<cou[i]<<endl;
    return 0;
}


Measured memory_bytes: 3812
from operator import itemgetter
N, M = map(int, input().split())

A = []
for i in range(M):
  A.append([i] + list(map(int, input().split())) + ["x"])

A.sort(key=itemgetter(1,2))

keynum, count = 0, 1
for i in range(M):
  if keynum != A[i][1]:
    keynum = A[i][1]
    count = 1
  else:
    count += 1
    
  A[i][3] = str(keynum).zfill(6) + str(count).zfill(6)
  
A.sort(key=itemgetter(0))
for i in range(M):
  print(A[i][3])


Measured memory_bytes: 99544
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    if (C >= A && C <= B) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
   }
}

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

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    double N=gd();
	    double X=Math.floor(N/1.08);

	    if (Math.floor(X*1.08)==N) {
	    	System.out.println((int)X);
	    } else if (Math.floor((X+1)*1.08)==N)  {
	    	System.out.println((int)(X+1));
	    } else {
	    	System.out.println(":(");
	    }
	    //System.out.println(a);
	}


	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35892
from sys import stdin
import numpy as np
mod = 10**9+7
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
A = np.array(A)
ans = 0
d = 1

while d < (1 << 60):
    cnt = np.count_nonzero(A & d)
    ans += (N - cnt) * cnt * d
    ans %= mod
    d <<= 1
print(ans)

Measured memory_bytes: 48832
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n, m; cin >> n >> m;
	vector<int> v(n);
	rep(i, m)
	{
		int a, b; cin >> a >> b;
		--a, --b;
		++v[a], ++v[b];
	}
	bool ok = true;
	rep(i, n)if (v[i] % 2 != 0)ok = false;
	if (ok)cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

int main(){
	ll N, K;
	cin >> N >> K;
	N = N > K ? N%K : K-N;
	while(1){
		if(N == 0)
			break;
		ll absdif = (N > K ? N%K : K-N);
		if(N > absdif){
			N = absdif;
		}else{
			break;
		}
	}
	cout << N << endl;

	return 0;	
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vl = vector<ll>;
using vs = vector<string>;

constexpr int MOD = int(1e9 + 7);
constexpr int INF = int(1e9 + 1);
constexpr ll LLINF = ll(4 * 1e18 + 1);
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int n;
string s;

bool check(char a0, char a1){
	string a(n + 2, 'U');
	a[0] = a0;
	a[1] = a1;
	for(int i = 1; i <= n; ++i){
		if((a[i] == 'S' && s[i] == 'o') || (a[i] == 'W' && s[i] == 'x')) a[i + 1] = a[i - 1];
		else if(a[i - 1] == 'S') a[i + 1] = 'W';
		else a[i + 1] = 'S';
	}
	return a[0] == a[n] && a[1] == a[n + 1];
}

string make(char a0, char a1){
	string a(n, 'U');
	a[0] = a0;
	a[1] = a1;
	for(int i = 1; i < n - 1; ++i){
		if((a[i] == 'S' && s[i] == 'o') || (a[i] == 'W' && s[i] == 'x')) a[i + 1] = a[i - 1];
		else if(a[i - 1] == 'S') a[i + 1] = 'W';
		else a[i + 1] = 'S';
	}
	return a;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
	cin >> n >> s;
	s.push_back(s[0]);
	if(check('S', 'S')) cout << make('S', 'S') << "\n";
	else if(check('S', 'W')) cout << make('S', 'W') << "\n";
	else if(check('W', 'S')) cout << make('W', 'S') << "\n";
	else if(check('W', 'W')) cout << make('W', 'W') << "\n";
	else cout << "-1\n";
	return 0;
}


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


int main(){
	int H, W, K;
	cin >> H >> W >> K;
	vector<vector<char>> c(H,vector<char>(W));
	rep(i,H){
		rep(j,W){
			cin >> c[i][j];
		}
	}
	int ans = 0;
	rep(bit1,(1<<H)){
			rep(bit2,(1<<W)){
					vector<vector<char>> d(H,vector<char>(W));
					rep(i,H)rep(j,W) d[i][j] = c[i][j];
					rep(i,H){
						if(bit1 & (1 << i)){
							rep(j,W) d[i][j] = 'a';
							}
					}
					rep(i,W){
						if(bit2 & (1 << i)){
							rep(j,H) d[j][i] = 'a';
							}
					}
					int tmp = 0;
					rep(i,H)rep(j,W) if(d[i][j] == '#') tmp++;
					if(tmp == K){
					   	ans++;
					}
			}
	}
	cout << ans << endl;
					
					



}














Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const signed INF_=1001001001; const ll INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
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(a>b){a=b;return 1;}return 0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int a=IN,b=IN;
    if((a*b)&1) {
        cout<<"Odd"<<endl;
    } else {
        cout<<"Even"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
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; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;

int dp[3005][3005];

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

  int n, t;
  cin >> n >> t;
  vector<P> p(n);
  rep(i,n) {
    cin >> p[i].first >> p[i].second;
  }
  sort(p.begin(), p.end());
  int ans = 0;
  rep(i,n) {
    rep(j, t) {
      chmax(dp[i+1][j], dp[i][j]);
      int nj = j + p[i].first;
      if(nj < t) {
        chmax(dp[i+1][nj], dp[i][j] + p[i].second);
      }
    }
    int now = dp[i][t-1]+p[i].second;
    chmax(ans, now);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 35456
#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;
static const double pi = 3.141592653589793;





int main(){
    ll N, C;
    cin>>N>>C;
    vector<vector<ll>> D(C, vector<ll>(C));
    vector<vector<ll>> CC(N, vector<ll>(N));
    vector<vector<ll>> Sum(3, vector<ll>(C, 0));
    rep(i, C){
        rep(j, C){
            cin>>D[i][j];
        }
    }
    rep(i, N){
        rep(j, N){
            cin>>CC[i][j];
            CC[i][j]--;
            Sum[(i+j+2)%3][CC[i][j]]++;
        }
    }
    ll Ans=INF;
    for(ll i=0; i<C; i++){
        for(ll j=0; j<C; j++){
            for(ll k=0; k<C; k++){
                if(i==j||j==k||k==i)continue;
                ll Num=0;
                rep(l, C){
                    if(i==l)continue;
                    Num+=Sum[0][l]*D[l][i];
                }
                rep(l, C){
                    if(j==l)continue;
                    Num+=Sum[1][l]*D[l][j];
                }
                rep(l, C){
                    if(k==l)continue;
                    Num+=Sum[2][l]*D[l][k];
                }
                Ans=min(Ans, Num);
            }
        }
    }
    cout<<Ans<<endl;
}

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

typedef int in;
#define int long long
int MAX=1e9;
int MAXEST=1e18;
int MOD=1e9+7;

int d;
string s;
int dp[10005][101][2];

int f(int idx,int cur,bool gr)
{
    if(idx==s.size())
    {
        return (!cur);
    }
    int &ret=dp[idx][cur][gr];
    if(ret!=-1)
        return ret;
    ret=0;
    if(!gr)
    {
        for(int i=0; i<s[idx]-'0'; i++)
        {
            ret+=f(idx+1,(cur+i)%d,1);
            ret%=MOD;
        }
        ret+=f(idx+1,(cur+(s[idx]-'0'))%d,0);
        ret%=MOD;
    }
    else{
        for(int i=0;i<=9;i++){
            ret+=f(idx+1,(cur+i)%d,1);
            ret%=MOD;
        }
    }
    return ret;
}

in main()
{
    int tc=1;
//    cin>>tc;
    while(tc--)
    {
        cin>>s>>d;
        memset(dp,-1,sizeof dp);
        cout<<(f(0,0,0)+MOD-1)%MOD<<endl;
    }
    return 0;
}


Measured memory_bytes: 20176
s=input()
g=0
for i in range(len(s)):
    if i%2==0:
        if s[i]=='0':
            g+=1
    else:
        if s[i]=='1':
            g+=1
c=0
for i in range(len(s)):
    if i%2==0:
        if s[i]=='1':
            c+=1
    else:
        if s[i]=='0':
            c+=1
if g>c:
    print(c)
else:
    print(g)



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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}

int f(int x,int y,int z) { return x*x+y*y+z*z+x*y+y*z+z*x; }

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

  for(int i=1;i<=n;i++) {
    int a=0,b=0,c=0;

    for(int x=1;f(x,x,x)<=i;x++) {
      for(int y=x;f(x,x,y)<=i;y++) {
        for(int z=y;f(x,y,z)<=i;z++) {
          if( f(x,y,z)==i ) {
            if(x==y && y==z && z==x) { a++; }
            else if(x!=y && y!=z && z!=x) { c++; }
            else { b++; }
          }
        }
      }
    }

    printf("%d\n",a+3*b+6*c);
  }

  return 0;
}


Measured memory_bytes: 3644
//package AtCoder;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		int n=s.length();
		for(int i=0;i<n;i++)
			System.out.print('x');

	}

}


Measured memory_bytes: 23764
//Physical Experiments

#include<cstdio>
#include<cmath>
using namespace std;

int main(void){
    double v;
    int n;
    
    while(scanf("%lf", &v) != EOF){
        //??°?????????????¨??????????
        n = (int)(v*v / 98.0 + 1.0) + 1;
    
        printf("%d\n", n);
    }
    
    return 0; 
}

Measured memory_bytes: 1056
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std; 
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	vector<int> v;
	for(int i=0;i<3;i++){
		int a;cin>>a;
		bool flag = false;
		for(int j=0;j<v.size();j++){
			if(v[j]==a){
				flag = true; break;
			}
		}
		if(flag==false){
			v.push_back(a);
		}
	}
	if(v.size()==2){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define INF       numeric_limits<int>::max()
#define NINF      numeric_limits<int>::min()
#define MOD       1000000007

using namespace std;
using Int = long long;

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

    int N, M;
    std::cin >> N >> M;

    vector<bool> broken(N + 1, false);
    REP(i, M) {
        int a;
        std::cin >> a;
        broken[a] = true;
    }

    vector<int> dp(N + 1, 0);
    dp[0] = 1;

    REP(i, N) {
        dp[i] %= MOD;
        if(broken[i]) {
            dp[i] = 0;
        }

        if(i + 1 <= N) {
            dp[i + 1] += dp[i];
        }

        if(i + 2 <= N) {
            dp[i + 2] += dp[i];
        }
    }

    std::cout << dp[N] % MOD << std::endl;
    return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
#define pb push_back
#define __V vector
#define all(x) x.begin(), x.end()
#define oit ostream_iterator
#define mod 1000000007ll
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
}
template<typename X, typename Y>
istream& operator>>(istream& in, pair<X, Y> &a) {
	in >> a.first >> a.second;
	return in;
}
template<typename T>
void getv(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv(vector<T>& v, int n, Ns ... ns) {
	v.resize(n);
	for (auto& i : v)
		getv(i, ns...);
}
template<typename T>
void getv1(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv1(vector<T>& v, int n, Ns ... ns) {
	v.resize(n + 1);
	for (int i = 1; i <= n; i++)
		getv(v[i], ns...);
}
#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
inline void getch(char &x) {
	while (x = getchar_unlocked(), x < 33) {
		;
	}
}
inline void getstr(string &str) {
	str.clear();
	char cur;
	while (cur = getchar_unlocked(), cur < 33) {
		;
	}
	while (cur > 32) {
		str += cur;
		cur = getchar_unlocked();
	}
}
template<typename T> inline bool sc(T &num) {
	bool neg = 0;
	int c;
	num = 0;
	while (c = getchar_unlocked(), c < 33) {
		if (c == EOF)
			return false;
	}
	if (c == '-') {
		neg = 1;
		c = getchar_unlocked();
	}
	for (; c > 47; c = getchar_unlocked())
		num = num * 10 + c - 48;
	if (neg)
		num *= -1;
	return true;
}
typedef unsigned long long ull;
typedef long long ll;
typedef float ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
using AntonTsypko = void;
using arsijo = AntonTsypko;
using god = arsijo;
uniform_real_distribution<double> double_dist(0, 1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
	doin();
	string s;
	int n, k;
	cin >> n >> k >> s;
	k--;
	s[k] -= 'A'-'a';
	cout << s;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	defer flush()

	var t [501][501]int

	N := readInt()
	M := readInt()
	Q := readInt()

	for i := 0; i < M; i++ {
		L := readInt()
		R := readInt()
		t[L][R]++
	}

	for i := 0; i < N+1; i++ {
		for j := 0; j < N; j++ {
			t[i][j+1] += t[i][j]
		}
	}

	for i := 0; i < N; i++ {
		for j := 0; j < N+1; j++ {
			t[i+1][j] += t[i][j]
		}
	}

	for i := 0; i < Q; i++ {
		p := readInt()
		q := readInt()
		println(t[q][q] + t[p-1][p-1] - t[p-1][q] - t[q][p-1])
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdoutWriter, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


Measured memory_bytes: 7296
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC157A
int main(void) {
  int n, a[9], x[9], b, k, i, cou=0, tmp;
  for(i=0; i<9; i++){
    scanf(" %d", &a[i]);
    x[i]=0;
  }
  scanf(" %d", &n);

  for(i=0; i<n; i++){
    scanf(" %d", &b);
    for(k=0; k<9; k++)
      if(a[k]==b) x[k]=1;
  }

  if(x[0]==1&&x[1]==1&&x[2]==1) ;
  else if(x[3]==1&&x[4]==1&&x[5]==1) ;
  else if(x[6]==1&&x[7]==1&&x[8]==1) ;
  else if(x[0]==1&&x[3]==1&&x[6]==1) ;
  else if(x[1]==1&&x[4]==1&&x[7]==1) ;
  else if(x[2]==1&&x[5]==1&&x[8]==1) ;
  else if(x[0]==1&&x[4]==1&&x[8]==1) ;
  else if(x[2]==1&&x[4]==1&&x[6]==1) ;
  else{
    printf("No");
    return 0;
  }
  printf("Yes");
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    int i,j;
    for(i=0;i<n;i++)
    cin>>a[i];
    for(i=0;i<n-1;i++)
    {
    	for(j=i+1;j<n;j++)
    	{
    		if(a[i]<a[j])
    		{
    			swap(a[i],a[j]);
			}
		}
    	
	}
	int ans=0;
	for(i=0;i<k;i++)
	{
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int N;cin>>N;
    int max=0;
    string tmp;
    map<string,int>s;
    vector<string>s2(N);
    rep(i,N){
        cin>>tmp;
        if(s.count(tmp)){
            s[tmp]++;
        }else{
            s[tmp]=1;
        }
        if(s[tmp]>max){
            max=s[tmp];
        }
    }
    int j=0;
    for(auto p:s){
        auto key=p.first;
        auto value=p.second;
        if(value==max){
            cout<<key<<endl;
        }
    }

}

Measured memory_bytes: 25172
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

const int MX = 3000;
int dp[MX+1][MX];

int main()
{
    int n, t;
    cin >> n >> t;
    vector<pint> ab;
    rep(i,n) {
        int a, b;
        cin >> a >> b;
        ab.emplace_back(a,b);
    }
    ssort(ab);
    rep(i,MX) rep(j,MX) { dp[i][j] = 0; }
    repSE(i,1,n+1) {
        int a = ab[i-1].first, b = ab[i-1].second;
        rep(j,t) {
            chmax(dp[i][j], dp[i-1][j]);
            if (j + a < MX) chmax(dp[i][j+a], dp[i-1][j] + b);
        }
    }
    int ans = 0;
    rep(i,n) {
        int ret = dp[i+1][t-1];
        repSE(j,i+1,n) {
            chmax(ret, dp[i+1][t-1] + ab[j].second);
        }
        chmax(ans, ret);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 35456
import sys
import itertools
read = sys.stdin.buffer.read #全てまとめて文字列として格納
readline = sys.stdin.buffer.readline # 一行読む
readlines = sys.stdin.buffer.readlines # 全行リストに格納
N,K = map(int, readline().split())
H = list(map(int, readline().split()))
N -= K
if N <= 0 :
  print(0)
  exit()

H.sort()

count=0
for i in range(N):
  count+=H[i]
print(count)
exit()

Measured memory_bytes: 23368
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i=0;;i++) {
			if( isPalin(Integer.toString(n-i)) ) {
				System.out.println(n-i);
				break;
			}
			if( isPalin(Integer.toString(n+i)) ) {
				System.out.println(n+i);
				break;
			}
		}
	}
	
	boolean isPalin(String s) {
		for(int i=0;i<s.length()/2;i++) 
			if( s.charAt(i) != s.charAt(s.length()-i-1) ) return false;
		return true;
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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

Measured memory_bytes: 17360
text = input()
 
flg = 0
for i in range(len(text)):
	if i%2 == 0:
		if text[i:i+1] != 'R' and text[i:i+1] != 'U' and text[i:i+1] != 'D':
			flg = 1
	else:
		if  text[i:i+1] != 'L' and text[i:i+1] != 'U' and text[i:i+1] != 'D':
			flg = 1
if flg == 1:
	print('No')
else:
	print('Yes')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
//ll const mod=998244353;
ll const mod=1e9+7;
const ll MAX=1000005;
using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvl =vector<vector<ll>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}


//////////////////////////////////////
ll dp[100005][2];

int main(){
    string s;
    cin>>s;
    int n=s.size();
    dp[0][1]=1;
    dp[1][0]=1;
    rep(i,n){
        dp[i+1][0]+=dp[i][0]*3%mod;

        if(s[i]=='1'){
            dp[i+1][0]+=dp[i][1];
            dp[i+1][0]%=mod;
            dp[i+1][1]=dp[i][1]*2%mod;
        }
        if(s[i]=='0'){
            dp[i+1][1]=dp[i][1];
            dp[i+1][1]%=mod;
        }
        if(i==0)dp[1][0]=1;
    }
    ll ans=dp[n][0]+dp[n][1];
    ans%=mod;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5320
#include<stdio.h>
#include<math.h>
int main()
{
    int R;
    double pi = 3.1416,circumference;

    scanf("%d",&R);

    if(R>0 && R<101)
    {
        circumference = (2*pi*R);

    printf("%.2lf\n",circumference);
    }

    else{
        printf("this number not allow");
    }


}


Measured memory_bytes: 1736
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector> 
#include<map> 
using namespace std;
#define mid 1000000007  
int main(){
	int a,b,c,d,t=1;
	cin>>a>>b>>c>>d;
	while(a>0&&c>0){
		if(t==1){
			c-=b;
			t=2;
		}
		else{
			a-=d;
			t=1;
		}
	}
	if(a<=0)
	cout<<"No";
	else
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 3636
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int h = sc.nextInt();
		int w = sc.nextInt();
		int k = sc.nextInt();
		char[][] grid = new char[h][w];
		for(int i = 0; i < h; i++){
		    String s = sc.next();
		    grid[i] = s.toCharArray();
		}
		
		
		// 計算
		long result = 0;
		for(int ih = 0; ih < (1<<h); ih++){
			for(int iw = 0; iw < (1<<w); iw++){
			    int[][] g = new int[h][w];
		        for(int i = 0; i < h; i++){
		            for(int j = 0; j < w; j++){
		                if(grid[i][j] == '#') g[i][j] = 1;
		            }
		        }
			    for(int jh = 0; jh < h; jh++){
				    if(((ih>>jh)&1) == 1){
					    for(int i = 0; i < w; i++){
					        g[jh][i] = 0;
					    }
				    }
			    }
			    for(int jw = 0; jw < w; jw++){
				    if(((iw>>jw)&1) == 1){
					    for(int i = 0; i < h; i++){
					        g[i][jw] = 0;
					    }
				    }
			    }
			    int tmp = 0;
			    for(int i = 0; i < h; i++){
		            for(int j = 0; j < w; j++){
		                if(g[i][j] == 1) tmp++;
		            }
		        }
		        if(tmp == k) result++;
			}
		}
		
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}



Measured memory_bytes: 28460
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });

            var S = ReadLine();
            var ans = Mod;
            var snum = new List<long>();
            foreach (var c in S)
                snum.Add(long.Parse(c.ToString()));
            for (var i = 0; i < snum.Count - 2; ++i)
            {
                ans = Min(ans, Abs(753 - (100 * snum[i] + 10 * snum[i + 1] + snum[i + 2])));
            }
            WriteLine(ans);
            //Out.Flush();
        }
    }
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >
//------------------------------------------------------

int main() {

    while (1) {
        int n;
        cin >> n;
        if (n == 0) break;

        bool na = true;
        set<ll> st;
        map<ll, ll> mp;
        vector<ll> v;

        rep(k, n) {
            ll i, p, q;
            cin >> i >> p >> q;
            if (!st.count(i)) {
                v.push_back(i);
                st.insert(i);
            }
            mp[i] += p*q;
        }

        for (auto vi : v) {
            if (mp[vi] >= 1000000) {
                cout << vi << endl;
                na = false;
            }
        }

        if (na) cout << "NA" << endl;
    }

    return 0;
}



Measured memory_bytes: 3280
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			if (sc.next().charAt(0) == 'Y') {
				System.out.println("Four");
				return;
			}
		}
		System.out.println("Three");
	}

}

Measured memory_bytes: 27068
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;
int main(){
 string s,t;
  cin>>s>>t;
 int n=s.size();
 int m=t.size();
 int ans=t.size();
 rep(i,n-m+1){
 int count=0;
   rep(j,m){
     if(s[i+j]!=t[j]) count++;
   }
   if(ans>=count) ans=count;
 }
  cout<<ans;
return 0;
}

Measured memory_bytes: 3628
import java.util.*

val mod052: Long = (Math.pow(10.0, 9.0) + 7).toLong()

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()

    val p = mutableListOf<Long>()
    for (i in 1..n) {
        p += computePrimeFactorList(i.toLong())
    }
    var count = 0
    p.sort()
    val pCount = mutableListOf<Int>()
    p.forEachIndexed { index, i ->
        count++
        if (index == p.size - 1 || i != p[index + 1]) {
            pCount.add(count)
            count = 0
        }
    }
    var ans = 1L
    pCount.map { it + 1L }.forEach {
        ans = ans * it % mod052
    }
    println(ans)
}

/**
 * 素因数分解
 * 対象の値が1になるまで素数で順番に割っていき割った数を列挙する
 */
fun computePrimeFactorList(n: Long): List<Long> {
    val p = mutableListOf<Long>()
    var primeFactor = n
    for (i in 2..n) {
        while (primeFactor % i == 0L) {
            primeFactor /= i
            p.add(i)
        }
    }
    return p
}

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

int main(){

    int s;
    cin>>s;

    map<int,int> m;
    int count=0;

    while(1){
        count++;
        m[s]++;
        if(m[s]==2){
            cout<<count<<endl;
            break;
        }
        s%2==0?s/=2:s=3*s+1;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll, ll>;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18;
const ll dy[4] = {1, 0, -1, 0};
const ll dx[4] = {0, 1, 0, -1};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int a, b, c;
	cin >> a >> b >> c;
	int k;
	cin >> k;
	int ans = 0;
	ans = min(a, k);
	k -= min(a, k);
	k -= min(b, k);
	ans += min(c, k) * -1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int num[10010]={};

int main() {
	int N, P;
	cin >> N >> P;
	string S;
	cin >> S;
	ll ans=0;
	if(P==2 || P==5){
		for(int i=0; i<N; ++i){
			if((S[i]-'0')%P==0){
				ans += i+1;
			}
		}
	}else{
		int now=0, r=1;
		num[0]=1;
		for(int i=N-1; i>=0; --i){
			now=(now+(S[i]-'0')*r)%P;
			ans += num[now];
			++num[now];
			r=(r*10)%P;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 644
import math

H, W = map(int, raw_input().split())

while H > 0 or W > 0 :
    print "#" * W

    for i in xrange(H-2) :
        print "#" + "." * (W-2) + "#"

    print "#" * W
    print

    H, W = map(int, raw_input().split())

Measured memory_bytes: 6452
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

char c;

signed main() {
	cin >> c;
	cout <<char( c + 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll N;
    cin >> N;
    cout << (N - 1) * N / 2 << '\n';
}


Measured memory_bytes: 256
import java.util.Scanner;

public interface Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int count = 0;

		for(int i = 0; i < N; i++) {
			int begin = sc.nextInt();
			int end = sc.nextInt();
			count += end - begin + 1;
		}

		System.out.println(count);
	}

}

Measured memory_bytes: 26964
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

int main(int argc, const char * argv[]) {
  ll n, m;
  cin >> n >> m;
  
  if (abs(n - m) <= 1) {
    cout << "Brown" << endl;
  } else {
    cout << "Alice" << endl;
    
  }
  
  return 0;
}


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

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

    for(int i=0; i<n; i++){
        string order, m;
        cin >> order >> m;
        int len = m.length();
        for(int j=order.length()-1; j>=0; j--){
            switch(order[j]){
            case 'J':
                m = m.substr(len-1,1) + m.substr(0,len-1);
                break;
            case 'C':
                m = m.substr(1, len-1) + m.substr(0,1);
                break;
            case 'E':
                if(len%2==0){
                    m = m.substr((len+1)/2, len/2)
                        + m.substr(0, len/2);
                }else{
                    m = m.substr((len+2)/2, (len-1)/2)
                        + m.substr(len/2, 1)
                        + m.substr(0, (len-1)/2);
                }
                break;
            case 'A':
                reverse(m.begin(), m.end());
                break;
            case 'P':
                for(int d=0; d<len; d++){
                    if(m[d] >= '1' && m[d] <= '9'){
                        m[d]--;
                    }else if(m[d] == '0'){
                        m[d] = '9';
                    }
                }
                break;       
            case 'M':
                for(int d=0; d<len; d++){
                    if(m[d] >= '0' && m[d] <= '8'){
                        m[d]++;
                    }else if(m[d] == '9'){
                        m[d] = '0';
                    }
                }
                break;
            }
        }
        cout << m << endl;
    }
    return 0;
}

Measured memory_bytes: 3172
import sys
input = sys.stdin.readline

N, C = map(int, input().split())

STC = []
for _ in range(N):
    s, t, c = map(int, input().split())
    STC.append((s, t, c))

#print(STC)

import heapq
h = []
for s, t, c in STC:
    heapq.heappush(h, (s-0.5, 0, c))
    heapq.heappush(h, (t, 1, c))

ans = 0
cnt = 0
rec = [0] * (C+1)
while h:
    t, flag, c = heapq.heappop(h)
    if flag == 0:
        if rec[c] == 0:
            rec[c] += 1
            cnt += 1
        else:
            rec[c] += 1
    else:
        rec[c] -= 1
        if rec[c] == 0:
            cnt -= 1
        else:
            pass
        
    ans = max(ans, cnt)
print(ans)

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

int main()
{
  int64_t n,cost=0,ans=0;
  cin>>n;
  int a[n+2];
  a[0]=0,a[n+1]=0;
  for(int i=1;i<=n;i++)
    {
    cin>>a[i];
    cost+=abs(a[i-1]-a[i]);
    }
    cost+=abs(a[n]-a[n+1]);

  for(int i=1;i<=n;i++)
  {
   ans=cost-abs(a[i-1]-a[i])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]);
   cout<<ans<<endl;
  }

  return 0;

}
/*
 n=5;a[5]=1,1,1,2,0;
 i=4,
      sum           = 4
 -abs (a[i-1]-a[i]) =-1
 -abs (a[i]-a[i+1]) =-2
 +abs (a[i-1]+a[i+1])=+1
 ans=2;

*/



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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vi arr (N);
	F0R(i, N) cin >> arr[i];
	int L; cin >> L;

	vector<vi> far (N, vi (31)); // farthest point you can end up
	int r = 0;
	int sum = 0;
	for (int l = 0; l < N; ++l) {
		while (r+1 < N && sum + arr[r+1] - arr[r] <= L) {
			sum += arr[r+1] - arr[r];
			++r;
		}
		far[l][1] = r;
		if (l + 1 < N) sum -= arr[l+1] - arr[l];
	}
	for (int j = 2; j <= 30; ++j) {
		for (int i = 0; i < N; ++i) {
			far[i][j] = far[far[i][j-1]][j-1];
		}
	}
	int Q; cin >> Q;
	F0R(i, Q) {
		int a, b; cin >> a >> b; --a; --b;
		if (a > b) swap(a, b);
		int ans = 0;
		for (int x = 30; x > 0; --x) {
			if (far[a][x] < b) {
				ans += 1 << (x-1);
				a = far[a][x];
			}
		}
		print(ans+1);
	}
}

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

int main(){
	int N;
	string S;
	cin >> N;
	cin >> S;

	int sum = 1;
	for (int i = 0; i < N-1; i++){
		if (S[i] != S[i + 1]){
			sum++;
		}
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 512