akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int n;
	cin >> n;
	string s[2];
	cin >> s[0] >> s[1];

	ll ans = 0;
	int x = 0;
	int pre = -1;
	while (x < n) {
		if (s[0][x] == s[1][x]) {
			if (pre < 0) ans = 3;
			else if (pre == 0) (ans *= 2) %= mod;
			else if (pre == 1) (ans *= 1) %= mod;
			x++;
			pre = 0;
		}
		else {
			if (pre < 0) ans = 6;
			else if (pre == 0) (ans *= 2) %= mod;
			else if (pre == 1) (ans *= 3) %= mod;
			x += 2;
			pre = 1;
		}
	}

	out(ans);

	return 0;
}

Measured memory_bytes: 256
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#include <bits/stdc++.h>
using namespace std;

//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;

int n,t[101],tsum,m,p,x;

int main(){
    I(n);
    REP(i,n){
        I(t[i]);
        tsum += t[i];
    }
    I(m);
    REP(i,m){
        I(p); I(x);
        p--;
        cout << tsum - t[p] + x << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int n,a,b,c,d;
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		string t;
		cin>>t;
		if (t[0]=='A') a++;
		else if (t[0]=='W') b++;
		else if (t[0]=='T') c++;
		else d++;
	}
	cout<<"AC x "<<a<<endl;
	cout<<"WA x "<<b<<endl;
	cout<<"TLE x "<<c<<endl;
	cout<<"RE x "<<d<<endl;
}

Measured memory_bytes: 3624
n,m=map(int,input().split())
ks=[]
for i in range(m):
  t=list(map(int,input().split()))
  ks.append(t)
p=list(map(int,input().split()))

ans=0
for i in range(1<<n):
  on=0
  for j in range(m):
    cnt=0
    for k in range(ks[j][0]):
      if 1<<(ks[j][k+1]-1) & i:
        cnt+=1
    if cnt%2==p[j]:
      on+=1
    if on==m:
      ans+=1
print(ans)

Measured memory_bytes: 9164
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
nn = [a, b, c, d, e]
s = False
for i in nn:
    if s == False and i%10 != 0:
        chk = i%10
        last = i
        s = True
    elif s == False and i%10 == 0:
        pass
    elif s == True and i%10 != 0:
        if chk > i%10:
            chk = i%10
            last = i
if s == False:
    last = a
#print(last)
s = False
for i in nn:
    if s == False and i == last:
        ans += i
        s = True
    else:
        if i%10 == 0:
            ans += i
        else:
            ans += i + (10 - i%10)
    #print(ans)
print(ans)

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

int h,w;
int inp[101][101];
int dp[101][101][2];

bool inBound (int ,int );
int _dp (int , int , int );


void solve(){
    cin >> h >> w;
  for(int i = 1;i<=h;i++){
    for(int j = 1;j<=w;j++){
      char c; cin >> c;
      inp[i][j] = (c == '#' ? 0 : 1);
    }
  }
  int result;
  memset(dp,-1,sizeof(dp));
  if(inp[1][1] == 0) result = 1+_dp(1,1,0);
  else result = _dp(1,1,1);
  cout << result;
}

int32_t main() {
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }

}
bool inBound (int x,int y){
  if(x >= 1 and x <= h and y >= 1 and y<=w)
    return 1;
  return 0;
}
int _dp (int x,int y,int flag){
  if(x == h && y == w){
    return 0;
  }
  if(dp[x][y][flag]!=-1)
    return dp[x][y][flag];
  int result = 1e18;
  if(inBound(x+1,y)){
    if(inp[x+1][y] == flag)
      result = min(result,_dp(x+1,y,flag));
    else if(inp[x+1][y] == 1)
      result = min(result,_dp(x+1,y,1));
    else result = min(result,1+_dp(x+1,y,flag^1));
  }
  if(inBound(x,y+1)){
    if(inp[x][y+1] == flag)
      result = min(result,_dp(x,y+1,flag));
    else if(inp[x][y+1] == 1)
      result = min(result,_dp(x,y+1,1));
    else result = min(result,1+_dp(x,y+1,flag^1));
  }
  dp[x][y][flag] = result;
  return result;
}

Measured memory_bytes: 512
import java.util.Scanner;
import java.util.Arrays;
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
        	int n=sc.nextInt();
            int sum=1000000;
            if(n==0){
                break;
            }
            int[] a=new int[n];
            for(int i=0;i<n;i++){
                a[i]=sc.nextInt();
            }
            Arrays.sort(a);
            
            for(int i=0;i<n-1;i++){
                for(int j=i+1;j<n;j++){
                    if(a[j]-a[i]<sum){
                    	sum=a[j]-a[i];
                    }
                }
            }
            System.out.println(sum);
        }
        sc.close();
    }
}


Measured memory_bytes: 46692
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>
 
using namespace std;
 
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)
 
 
void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
 
Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}
 
bool comp(const string a, const string b) {
	return a.length() < b.length();
}
 
bool integer(double num) {
	return floor(num) == num;
}
 
string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}
 
 
int main() {
	int n, a, b; cin >> n >> a >> b;
	cout << min(n*a,b) << endl;
 
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
using Edge=pii;
#define l first
#define d second
bool isSame(vector<Edge> a, vector<Edge> b){
    int r=b[0].d-a[0].d;
    for(auto &e:a) e.d=(e.d+r+4)%4;
    return a==b;
}

int main(){
	int n;
	while(cin>>n,n){
		vector<vector<Edge>> edge(n+1,vector<Edge>(0));
		rep(i,n+1){
    		int t; cin>>t;
    		int x,y; cin>>x>>y;
    		rep(j,t-1){
    		    int tx,ty; cin>>tx>>ty;
    		    edge[i].eb(abs(tx+ty-x-y), x==tx?(ty>y?0:2):(tx>x?1:3));
    		    x=tx,y=ty;
    		}
		}
		range(i,1,n+1){
		    auto e=edge[i]; reverse(all(e));
		    if(isSame(edge[0],edge[i])||isSame(edge[0],e)){
		        cout<<i<<endl;
		    }
		}
		cout<<"+++++"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3028
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val Array(a, b, c) = sc.nextLine.split(" ").map(_.toInt)
    if ((1 to b).exists(i => i * a % b == c)) println("YES")
    else println("NO")
  }
}


Measured memory_bytes: 27336
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<string.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
#define MAX 200000
#define NIL -1

int N;
long long cnt;





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

	cin >> N;

	FOR(i, 1, N+1) {
		if (i % 3 != 0 && i % 5 != 0)cnt += i;
	}
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3192
#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 per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a <= b) {
        a = b;
        return true;
    }
    return false;
}

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main(){
    ll n;cin >> n;
    UnionFind uf(100000);
    vvl g(100000);
    rep(i,n){
        ll x,y;cin >> x >> y;x--;y--;
        g[x].pb(y);
    }
    rep(i,100000){
        if(g[i].size()<=1)continue;
        rep(j,g[i].size()-1){
           if(!uf.same(g[i][j],g[i][j+1]))uf.merge(g[i][j],g[i][j+1]);
        }
    }
    vector<pl> ans(100000);
    rep(i,100000){
        if(g[i].empty())continue;
        ans[uf.root(g[i][0])].fi++;
        ans[uf.root(g[i][0])].se+=g[i].size();
    }
    ll ret=0;
    rep(i,100000){
        if(ans[i].fi==0)continue;
        ret+=ans[i].fi*uf.size(i)-ans[i].se;
    }
    cout << ret <<endl;
}   

Measured memory_bytes: 9304
#include<iostream>

using namespace std;

int main(void) {
  string a,b,c;
  cin >> a;
  cin >> b;
  cin >> c;
  
  char x = 'a';
  while(1){
    switch(x){
      case 'a':
        if (a.size() == 0) {
      	  cout << "A" << endl;
          return 0;
        }
        x = a[0];
        a.erase(a.begin());
        break;
      case 'b':
        if (b.size() == 0) {
      	  cout << "B" << endl;
          return 0;
        }
        x = b[0];
        b.erase(b.begin());
        break;
      case 'c':
        if (c.size() == 0) {
      	  cout << "C" << endl;
          return 0;
        }
        x = c[0];
        c.erase(c.begin());
        break;
    }
//    cerr << a.size() << b.size() << c.size() << endl;

  } 
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>

int n, m;
char g[12][12];
char ans[35];
int LeafNum;
int endFlag;
char final_ans[35];

void BFS(int x, int y, int leaf_num, char dir)
{
    //printf("BFS : %d %d %d %d\n", x,y,leaf_num,dir);
    if(endFlag == 1)
        return;

    ans[LeafNum - leaf_num] = dir;

    if(leaf_num == 0)
    {
        endFlag = true;
        return;
    }

    //Up
    if(dir != 'D')
        for(int i = x - 1; i >= 0; i--)
            if(g[i][y] == 'o')
            {
                g[i][y] = '.';
                BFS(i, y, leaf_num - 1, 'U');
                g[i][y] = 'o';
                break;
            }

    //Down
    if(dir != 'U')
        for(int i = x + 1; i < n; i++)
            if(g[i][y] == 'o')
            {
                g[i][y] = '.';
                BFS(i, y, leaf_num - 1, 'D');
                g[i][y] = 'o';
                break;
            }

    //Left
    if(dir != 'R')
        for(int i = y - 1; i >= 0; i--)
            if(g[x][i] == 'o')
            {
                g[x][i] = '.';
                BFS(x, i, leaf_num - 1, 'L');
                g[x][i] = 'o';
                break;
            }

    //Right
    if(dir != 'L')
        for(int i = y + 1; i < m; i++)
            if(g[x][i] == 'o')
            {
                g[x][i] = '.';
                BFS(x, i, leaf_num - 1, 'R');
                g[x][i] = 'o';
                break;
            }

}

int main()
{
    scanf("%d %d", &n, &m);

    int x, y;
    int leaf_num = 0;
    char dir;// 0 is up, 1 is left, 2 is down, 3 is right

    for(int i = 0; i < n; i++)
    {
        scanf("%s", g[i]);
        for(int j = 0; j < m; j++)
        {
            if(g[i][j] == 'U' || g[i][j] == 'R' || g[i][j] == 'L' || g[i][j] == 'D')
            {
                x = i;
                y = j;

                dir = g[i][j];
            }
            if(g[i][j] == 'o')
                leaf_num++;
        }
    }

    LeafNum = leaf_num;
    endFlag = 0;

    BFS(x, y, leaf_num, dir);

    //printf("Leaf : %d\n", LeafNum);
    for (int i = 1; i <= LeafNum; ++i)
        printf("%c", ans[i]);
    printf("\n");

}

Measured memory_bytes: 1000
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
#define forinc(i,a,b) for(int i=a;i<=b;i++)
#define fordec(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define int long long
#define fi first
#define se second

const int maxn=3010;
int a[maxn],n,f[maxn][maxn];

int calc(int l,int r)
{
    if(l>r) return 0;
    if(f[l][r]!=-1) return f[l][r];
    int ret;
    if(((r+l)%2)!=n%2) ret=max(calc(l+1,r)+a[l],calc(l,r-1)+a[r]);
    else ret=min(calc(l+1,r)-a[l],calc(l,r-1)-a[r]);
    return f[l][r]=ret;
}
main()
{
   // ios_base::sync_with_stdio(false);
    cin>>n;
    forinc(i,1,n) cin>>a[i];
    memset(f,-1,sizeof f);
    cout<<calc(1,n);

}


Measured memory_bytes: 71168
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <cctype>
#include <fstream>
#include <cstring>

using namespace std;
typedef long long ll;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());

int V;
vector<int> G[100010];//元のグラフ
int indegree[100010];//頂点の入次数
vector<int> sortnum;//トポロジカルソートした時の番号

void pre_tsort(int from, int to) {
    G[from].push_back(to);
    indegree[to]++;//入次数
}

void tsort() {
    queue<int> que;//入次数が0の頂点
    rep(i, V) if (indegree[i] == 0)que.push(i);//入次数が最初から０
    //トポロジカルソートは入次数が0の頂点から行っていく。
    while (!que.empty()) {
        int v_from = que.front();//入次数0の頂点に現在いる
        que.pop();
        sortnum.push_back(v_from);
        for (auto& v_to : G[v_from]) {
            //行き先の頂点の入次数を-1
            indegree[v_to]--;
            //入次数が0になれば次の処理対象に
            if (indegree[v_to] == 0)que.push(v_to);
        }
    }
}
//Vを再定義しないように

int main(){
    int E;
    cin >> V >> E;
    rep(i, E) {
        int s, t;
        cin >> s >> t;
        pre_tsort(s,t);
    }

    tsort();

    rep(i,V)cout << sortnum[i] << endl;

}


Measured memory_bytes: 5892
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

int n,m;
set<P> s;

int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		s.insert({a,b});
		s.insert({b,a});
	}
	vi a(n);
	for(int i=0;i<n;i++) a[i]=i+1;
	int ans=0;
	do{
		bool flag=1;
		for(int i=0;i<n-1;i++) if(s.find({a[i],a[i+1]})==s.end()) flag=0;
		if(flag) ans++;
	}while(next_permutation(a.begin()+1,a.end()));
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main ()
{
	int i,n;
	long long int k=0;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		if(i%3!=0 && i%5!=0 && i%15!=0)
		{
			k=k+i;
		}
	}
	cout<<k;
	return 0;
}

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

vector<vector<int>> adj;
vector<bool> vis;

void dfs(int v, int p) {
	vis[v]=1;

	for (auto x:adj[v]) {
		if (x!=p && !vis[x]) dfs(x, v);
	}
}

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int n, m; cin >> n >> m;
	adj=vector<vector<int>>(n);
	vis=vector<bool>(n, false);

	for (int i=0; i<m; i++) {
		int a, b; cin >> a >> b; a--; b--;

		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	int ans=0;

	for (int i=0; i<n; i++) {
		if (!vis[i]) {
			dfs(i, -1);
			ans++;
		}
	}

	cout << ans-1;
}

Measured memory_bytes: 9536
#include<stdio.h>
int main(){
    
    char a[1205];
    
    scanf("%[^\n]",a);
    
    int p=0;
    
    while(a[p]!='\0'){
        p++;
    }
    
    for(int i=0;i<p;i++){
        if(a[i]>='a'&&a[i]<='z')
        {a[i]=a[i]-32;
    }
    
        else if(a[i]>='A'&&a[i]<='Z')
        {
            a[i]=a[i]+32;
    }
        
    }
    printf("%s",a);
    printf("\n");
    
    return(0);
    
}


Measured memory_bytes: 2048
#include<stdio.h>

int main (){
	int a;
	//a=jumlah sheets
	//b=jumlah kertas print
	
	//100sheets = 50x print
	//3sheets=1xprint +1print
	//5sheets =2xprint +1print
	
	scanf("%d",&a);
	int print =(a%2==0)?(a/2):((a/2)+1);
	printf ("%d\n", print);
	
	return 0;
}


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

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

typedef long long ll;

const int INF=1e9+7;

int abs(int x){return x<0?-1*x:x;}

int main(){
	int n,m;
	cin>>n>>m;
	if(abs(n-m)>1)cout<<0<<endl;
	else if(n==m){
		long long ans=1;
		for(ll i=1;i<=n;i++)ans=(ans*((i*i)%INF))%INF;
		ans=(ans*2)%INF;
		cout<<ans<<endl;
	}
	else{
		ll ans=1;
		for(ll i=1;i<=min(n,m);i++)ans=(ans*((i*i)%INF))%INF;
		ans=(ans*max(n,m))%INF;
		cout<<ans<<endl;
	}
}


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


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

    if(a >= b && a >= c){
        cout << a*10 + b + c << endl;
    }else if(b >= a && b >= c){
        cout << b*10 + a + c << endl;
    }else if(c >= b && c >= a){
        cout << c*10 + b + a << endl;
    }
	
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;

	int kotae = 0;
	int A = 0;
	int B = 0;
	int AB = 0;

	rep(i, N) {
		string s;
		cin >> s;
		int M = s.size();
		rep(j, M - 1) {
			if (s[j] == 'A' && s[j + 1] == 'B') kotae++;
		}
		if (s[0] == 'B') {
			if (s[M - 1] == 'A') AB++;
			else B++;
		}
		else if(s[M - 1] == 'A') A++;
	}

	if (A == 0 && B == 0) co(kotae + max(0, AB - 1));
	else co(kotae + min(A, B) + AB);

	Would you please return 0;
}

Measured memory_bytes: 256
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef long long lint;
typedef double ld;

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

    int a, b;
    cin >> a >> b;
    cout << a * b << '\n';
    return 0;
}
// Write Here


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

void Sieve(int n)
{
	bool prime[n+1];
	int c=0;
	memset(prime, true, sizeof(prime));
	int x=sqrt(n*1.0)+2;

	for (int p=2; p<=x; p++)
	{
		if (prime[p] == true)
		{
			for (int i=p*p; i<=n; i+=p)
				{
				    prime[i] = false;
				}

		}
	}
	for (int p=2; p<=n; p++)
	if (prime[p])
		c++;
		cout<<c<<endl;
}

int main()
{
	int n;
	while(cin>>n){
        Sieve(n);
	}

	return 0;
}

Measured memory_bytes: 3972
#include <iostream>
#include <climits>
using namespace std;
#define ll long long
#define N 100
#define V 100000
ll dp[N+1][V+1];
void solve()
{
	ll n,w;
	cin >> n >> w;
	ll wt[n],val[n];
	for(ll i=0;i<n;i++)
	{
		cin >> wt[i] >> val[i];
	}
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<=V;j++)
		{
			dp[i][j]=1e18;
		}
	}
	dp[0][0]=0;
	dp[0][val[0]]=wt[0];
	for(ll i=1;i<n;i++)
	{
		dp[i][0]=0;
		for(ll j=1;j<=V;j++)
		{
			dp[i][j]=dp[i-1][j];
			if(j>=val[i])
			{
				dp[i][j]=min(dp[i][j],dp[i-1][j-val[i]]+wt[i]);
			}
		}
	}
	for(ll i=V;i>=0;i--)
	{
		if(dp[n-1][i]<=w)
		{
			cout << i << "\n";
			return;
		}
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll t=1;
	// cin >> t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 81776
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
const int N = 5000 + 5, M = 50000 + 5, INF = 0x3f3f3f3f;
const ll MOD = 1e9 + 7;

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    for (ll i = 1; i <= n; ++i) {
        for (ll j = 1; i * j <= n; ++j) {
            if (i * j < n) {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3164
using System;

namespace cf17_final_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int[] count = new int[3];
            for (int i = 0; i < s.Length; i++)
            {
                count[s[i] - 'a']++;
            }
            bool ret = true; int remain = s.Length % 3;
            for (int i = 0; i < 3; i++)
            {
                if ((count[i] - 1) * 3 > s.Length) ret = false;
                else if (count[i] * 3 > s.Length) remain--;
            }
            Console.WriteLine(ret && remain >= 0 ? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 11232
import scala.io.StdIn

/**
  * AOJ
  */
object Main {

  def main(args: Array[String]): Unit = {

    val in = StdIn.readLine().split(" ").map(s => s.toInt)

    println(if(in(0) < in(1) && in(1) < in(2)){"Yes"}else{"No"})
  }
}

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

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

    while(A>0 && C>0){
        C = C-B;
        if(C<=0){
            break;
        }
        A = A-D;
        if(A<=0){
            break;
        }
    }

    if(A<=0){
        printf("No");
    }
    else{
        printf("Yes");
    }
}


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

int n,m,d[100000],p=0;
vector<int> e[100000];

int f(int v){
    if(d[v]==-1){
        d[v]=0;
        for(int i=0;i<e[v].size();i++){
            d[v]=max(d[v], f(e[v][i])+1);
        }
    }
    return d[v];
}

int main(void){
    cin>>n>>m;
    fill(d, d+n, -1);
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        x--;
        y--;
        e[x].push_back(y);
    }
    for(int i=0;i<n;i++){
        p=max(p, f(i));
    }
    cout<<p<<endl;
}


Measured memory_bytes: 8192
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef
tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))
#define relaxMax(a, b) a = max(a, b)
#define relaxMin(a, b) a = min(a, b)

typedef long long ll;
typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("amusing.in", "r", stdin);
    //freopen("amusing.out", "w", stdout);
}

void solve() {
    int n;
    cin >> n;
    vll a(n);
    map<ll, ll> cnt;
    ll ans = 0;
    forn(i, n){
        cin >> a[i];
        cnt[a[i]]++;
        ans += a[i];
    }
    int q;
    cin >> q;
    forn(i, q){
        int x, y;
        cin >> x >> y;
        ans += cnt[x] * (y - x);
        cnt[y] += cnt[x];
        cnt[x] = 0;
        cout << ans << '\n';
    }
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

Measured memory_bytes: 9912
#include <bits/stdc++.h>
using namespace std;
char a[105][105];
int dp[105][105];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int h, w;
	cin>>h>>w;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>a[i][j];
			dp[i][j]=INT_MAX;
		}
	}
	if(a[1][1]=='#') dp[1][1]=1;
	else dp[1][1]=0;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(i>1) dp[i][j]=min(dp[i][j], dp[i-1][j]+(int)(a[i-1][j]=='.' && a[i][j]=='#'));
			if(j>1) dp[i][j]=min(dp[i][j], dp[i][j-1]+(int)(a[i][j-1]=='.' && a[i][j]=='#'));
		}
	}
	cout<<dp[h][w];
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var S = cin.ReadLine;

            var sCount = S.Count()-2;

            int result = 1000000;
            int level = 753;
            for (int i = 0; i < sCount; i++)
            {
                var strNum = S[i].ToString() + S[i + 1].ToString() + S[i + 2].ToString();
                int tempVal = 0;
                int.TryParse(strNum, out tempVal);
                int dif = Math.Abs(level - tempVal);
                if (result > dif)
                {
                    result = dif;
                }
            }           

            Console.Write(result);

        }

    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

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

int main() {
  int x,t;
  cin >> x >> t;
  if(x>t){
    cout << x-t << endl;
  }else{
    cout << 0 << endl;
  } 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<pair<int,int>> V;
    int sum;
    if(N % 2 == 0) sum = N+1;
    else sum = N;

    REPP(i,1,N+1){
        REPP(j,1,i){
            if(i+j == sum) continue;
            V.pb({i,j});
        }
    }

    cout << V.size() << endl;
    REP(i,V.size()) cout << V[i].first << ' ' << V[i].second << endl;
}

Measured memory_bytes: 384
import fractions
from functools import reduce

def gcd(l):
    return reduce(fractions.gcd, l)

n, x = map(int, input().split())
l = list(map(int, input().split()))
l.append(x)
l.sort()

d = [l[i+1] - l[i] for i in range(n)]

d.sort()

print(gcd(d))

Measured memory_bytes: 89236
a = []
for i in range(3):
  a.append([int(i) for i in input().split()])
n = int(input())
b = []
for i in range(n):
  x = int(input())
  for j in range(3):
    for k in range(3):
      if a[j][k] == x:
        a[j][k] = 0
if a[0][0] == a[1][1] == a[2][2] == 0:
  print("Yes")
elif a[0][2] == a[1][1] == a[2][0] == 0:
  print("Yes")
elif a[0][0] == a[1][0] == a[2][0] == 0:
  print("Yes")
elif a[0][1] == a[1][1] == a[2][2] == 0:
  print("Yes")
elif a[0][2] == a[1][2] == a[2][2] == 0:
  print("Yes")
elif a[0][0] == a[0][1] == a[0][2] == 0:
  print("Yes")
elif a[1][0] == a[1][1] == a[1][2] == 0:
  print("Yes")
elif a[2][0] == a[2][1] == a[2][2] == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vii         vector<pair<int,int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define endl '\n'
#define int long long int
using namespace std;

const int mod = (int)1e9 + 7;
const int lim = (int)1e6 + 7;
int n;
int dp[lim] = {0};
bool vis[lim] = {0};
int tot[lim] = {0};
int solve(int pos){
    if(pos <= 0)return 1;
    tot[1] = n;
    dp[1] = n;
    for(int pos = 2; pos <= n; pos++){
        int& ans = dp[pos];
        ans = 0;
        ans += dp[pos-1];
        if(pos >= 3)ans += tot[pos -3];
        ans += (n - max(pos-1, 2LL) +1);
        ans %= mod;
        ans += (n-1)*(n - 1);
        ans %= mod;
        tot[pos] = tot[pos-1] + ans;
        tot[pos] %= mod;
    }
    /*
    debug(pos);
    if(vis[pos])return dp[pos];
    vis[pos] = true;
    int& ans = dp[pos];
    ans = 0;
    ans += solve(pos-1); //placing 1 here
    debug(ans);
    if(pos >= 3)ans += tot[pos-2-1];
    //we have not accounted val >= pos and val = pos-1;
    ans += (n - max(pos-1, 2LL) +1);
    ans %= mod;
    ans += (n-1)*(n - 1);
    ans %= mod;
       for(int val = 2; val <= n;val++){
       ans += solve(pos - val - 1);//placing val here and 1's in the next  
       ans += n-1;//after val value we place non-1 number 
       ans %= mod;
       }
    tot[pos] = tot[pos-1] + ans;
    debug(pos);
    debug(tot[pos]);
    tot[pos] %= mod;
    */
    return dp[n];
}
//111113111132222222222
//31111131111211121124444444
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin >> n; 

    cout << solve(n);
}





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

#define MAX 100000

int main() {
    int H, N;
    cin >> H >> N;
    int A[MAX];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    int sum = 0;
    for (int i = 0; i < N; i++) {
        sum += A[i];
    }
    if (sum >= H) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
using namespace std;
const int N=1002020;
#define int long long
const int inf=1e14;
int n,a[3],v[10][N];
#undef int
int main()
{
	#define int long long
    cin>>n; int sum;
    for(int i=0;i<n;i++){
        for(int j=0;j<2;j++)cin>>a[j];
        for(int j=0;j<4;j++){
            sum=0;
            for(int k=0;k<2;k++){
                if(j&(1<<k))sum+=a[k];
                else sum-=a[k];
            }
            v[j][i]=sum;
        }
    }
    int ans=-1;
    for(int i=0;i<2;i++){
        int a=-inf,b=inf;
    	for(int j=0;j<n;j++){
            if(v[i][j]>a) a=v[i][j];
            if(v[i][j]<b) b=v[i][j];
        }
        if(a-b>ans) ans=a-b;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 9884
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;
typedef complex<double> xy_t;

const lint mod = 1e9 + 7;

int main(){
    int h, w;
    scanf("%d%d", &h, &w);
    char c[h][w];
    int cnt = 0;
    rep(i, h)rep(j, w){
        scanf(" %c", &c[i][j]);
        if(c[i][j] == '#') ++cnt;
    }
    
    int dx[4] = {-1, 0, 1, 0};
    int dy[4] = {0, 1, 0, -1};
    int d[h][w];
    rep(i, h)rep(j, w) d[i][j] = 5000;
    d[0][0] = 0;
    queue<ppi> que;
    que.push(ppi(pii(0, 0), 0));
    while(!que.empty()){
        ppi p = que.front(); que.pop();
        int x = p.fi.fi;
        int y = p.fi.se;
        int dv = p.se;
        if(x == h-1 && y == w-1){
            printf("%d\n", h*w-dv-cnt-1);
            return 0;
        }
        if(dv > d[x][y]) continue;
        rep(i, 4){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(0<=nx && nx<h && 0<=ny && ny<w && c[nx][ny]=='.' && d[nx][ny] > d[x][y]+1){
                d[nx][ny] = d[x][y] + 1;
                que.push(ppi(pii(nx, ny), d[nx][ny]));
            }
        }
    }
    printf("-1\n");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

const int MX = 400005;
const int MM = 1000000007;

string D;

string f(string D, int &a){
	static int F[MX] = {};
	int N = D.size();
	for(int i = 0; i <= D.size(); i++) F[i] = -1;
	for(int i = 1; i <= D.size(); i++){
		F[i] = F[i-1];
		while(F[i] != -1 && D[F[i]] != D[i-1]) F[i] = F[F[i]];
		F[i] += 1;
	}
	a = F[N];
	while(a >= N/2) a = F[a];
	return D + D.substr(a, N-2*a);
}

void solve1(string A, ll ad, ll ans[26])
{
	for(int i = 0; i < 26; i++) ans[i] = 0;
	int cnt[26] = {};
	string B = A.substr(0, A.size()/2);
	for(char c : B) cnt[c-'a']++;
	for(int i = 0; i < ad%B.size(); i++) ans[B[i]-'a']++;
	for(int i = 0; i < 26; i++) ans[i] += cnt[i] * (ad/B.size());
}

void solve2(string A, string B, ll ad, ll ans[26])
{
	int c1[26] = {}, c2[26] = {};
	for(char c : A) c1[c-'a']++;
	for(char c : B) c2[c-'a']++;

	vector<pll> L;
	L.push_back(pll(1, 0));
	L.push_back(pll(0, 1));
	while(L.back().first * A.size() + L.back().second * B.size() <= ad){
		L.emplace_back(L[L.size()-2].first + L.back().first, L[L.size()-2].second + L.back().second);
	}
	reverse(L.begin(), L.end());
	L.pop_back(); L.pop_back();
	for(pll c : L){
		ll v = c.first * A.size() + c.second * B.size();
		if( ad < v ) continue;
		ad -= v;
		for(int i = 0; i < 26; i++){
			ans[i] += c1[i] * c.first + c2[i] * c.second;
		}
	}
	string C = A+B;
	for(int i = 0; i < ad; i++) ans[C[i]-'a'] ++;
}

int main()
{
	string A;
	int a;
	ll l, r;
	cin >> A >> l >> r; A = f(A, a);
	f(A, a);

	ll a1[26] = {}, a2[26] = {};
	if( a == 0 || a*4 == A.size() ) solve1(A, r, a1), solve1(A, l-1, a2);
	else{
		solve2(A.substr(0, a), A.substr(a, A.size()/2-a), r, a1);
		solve2(A.substr(0, a), A.substr(a, A.size()/2-a), l-1, a2);
	}
	for(int i = 0; i < 26; i++) printf("%lld ", a1[i] - a2[i]);
	printf("\n");
}


Measured memory_bytes: 3384
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N, K; cin >> N >> K;
    vector<int> H(N);
    REP(i, 0, N) cin >> H[i];
    sort(ALL(H), greater<int>());

    ll sum = 0;
    REP(i, 0, N) {
        if (i < K) continue;
        sum = sum + H[i];
    }

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

Measured memory_bytes: 1024
import java.util.Scanner;

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

    int a = sc.nextInt();

    int fh = a / 500;
    int rest = a - 500 * fh;
    int f = rest / 5;

    int happy = (fh * 1000) + (f * 5);
    System.out.println(happy);
  }
}


Measured memory_bytes: 23252
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

x = 0
for i in range(n):
    y = b[i] - a[i]
    if (y <= 0): #余力なし
        x += b[i]
    else:
        x += a[i]
        if (a[i+1] < y): #過剰勇者
            x += a[i+1]
            a[i+1] = 0
        else:
            x += y
            a[i+1] -= y

print(x)


Measured memory_bytes: 19116
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int a, b, c, d, ans, s, e; cin >> a >> b >> c >> d;
    ans = 0;
    s = min(a, c);
    e = max(b, d);
    for (int i = s; i < e; i++)
    {
        if (i >= a && i < b && i >= c && i < d)
        {
            ans++;
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<math.h>
#include<cstring>
using namespace std;

int main()
{
	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s,t;
    cin>>s>>t;

    int n=s.size();
    int m=t.size();
    int i;
    int count=0;
    for(i=0;i<n;i++)
    {
    	
       if(s[i]==t[i])
       {
       	
       	count++;
       	
	   }
    	
    	
    	
	}
	
	
	
	if(count==n&&m==n+1)
	{
		
		
		cout<<"Yes"<<endl;
		
	}
	
	
	else 
	{
		
		cout<<"No"<<endl;
		
	}
    
  
    
    return 0;
    
}

Measured memory_bytes: 3600
import itertools

n,m,x=map(int,input().split())
kin=[]
rika=[]
ans=10000000
for i in range(n):
    tmp=list(map(int,input().split()))
    kin.append(tmp[0])
    rika.append(tmp[1:])
#print(kin,rika)
tmpp=[0]*m
for i in range(1,n+1):
    for j in itertools.combinations(range(1,n+1), i):
        tmpp = [0] * m
        #print(j)
        for k in j:
            for l in range(m):
                tmpp[l]+=rika[k-1][l]
        #print(tmpp)
        if min(tmpp)>=x:
            kincou=0
            for k in j:
                kincou+=kin[k-1]
            ans=min(ans,kincou)
if ans==10000000:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 68504
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar(); getchar();return 0;
using namespace std;
typedef pair<ll, ll>P;
signed main() {
	ll r, g, b, n;
	cin >> r >> g >> b >> n;
	ll p = n / min({ r,g,b });
	ll ans = 0;
	rep(i, p + 1) {
		rep(j, p + 1) {
			ll memo = r * i + g * j;
			if (memo > n)continue;
			if ((n - memo) % b == 0)ans++;
		}
	}
	cout << ans << endl;
	ggr
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000001;
int n, s, j, skip, nextskip, lis;
vector<int> a, sz, top, p, nextp;

int PatienceSorting(int nexti){
    int r = -1, l = -1, h;
    if(p[0] == -1) r = 0;
    for(int i = 0; i < 2 * s; i++) { top[i] = INF; sz[i] = 0; }
    for(int i = 0; i < n; i++){
        // filtering out irrelevant elements
        if(i < skip) continue;
        else if(r + 1 < p.size() && a[i] == p[r + 1]) { r++; continue; }
        else if(r == -1 || a[i] < p[r] || (l >= j && a[i] > top[j])) continue;
        // push a[i] to the appropriate pile
        if(l == -1 || a[i] > top[l]) { l++; h = l; }
        else h = lower_bound(top.begin(), top.end(), a[i]) - top.begin();
        top[h] = a[i];
        sz[h]++;
        if(h == nexti){
            if(nextskip == -1) nextskip = i;
            nextp.push_back(a[i]);
        }
    }
    return l;
}

int main(){
    cin >> n;
    s = sqrt(n); j = 2 * s - 1;
    a.resize(n); sz.resize(2 * s); top.resize(2 * s);
    for(int i = 0; i < n; i++) cin >> a[i];
    p.push_back(-1);
    while(1){
        int l = PatienceSorting(-1);
        if(l < 2 * s - 1) { lis += l + 1; break; }
        int nexti = -1;
        for(int i = 2 * s - 1; i >= s; i--) if(sz[i] <= s && sz[i] > 0) { nexti = i; break; }
        nextp.clear(); nextskip = -1;
        PatienceSorting(nexti);
        p = nextp; skip = nextskip;
        lis += nexti + 1;
    }
    cout << lis << endl;
}


Measured memory_bytes: 3348
S=input()
is_ans=0
if S[0]=='A':
    S1=S[2:len(S)-1]
    if S1.count('C')==1:
        S0=list(S)

        S0.remove('A')
        S0.remove('C')

        S3=''.join(S0)
        S3=S3.lower()
        S3=list(S3)
        if S3==S0:
            is_ans=1
print("AC" if is_ans else "WA")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,k,a[200010],li[200010];

int main(){
	cin >> n >> k;
	REP(i,0,n) cin >> a[i],li[a[i]-1]++;
	sort(li,li+n);
	
	int c=0;
	REP(i,0,n) if(li[i]) c++;
	
	if(c<=k) cout << 0 << endl;
	else{
		int s=0; c-=k;
		REP(i,0,n) if(li[i] and c) s+=li[i],c--;
		cout << s << endl;
	}
	
	return 0;
}


Measured memory_bytes: 1792