akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int A, B, m;
int a[100000];
int b[100000];
int x[100000], y[100000], c[100000];

int main() {
	int i;
	
	cin >> A >> B >> m;
	rep(i, A) cin >> a[i];
	rep(i, B) cin >> b[i];
	
	int minA = a[0];
	rep(i, A) minA = min(minA, a[i]);
	
	int minB = b[0];
	rep(i, B) minB = min(minB, b[i]);
	
	int ans = minA + minB;
	rep(i, m) {
		cin >> x[i] >> y[i] >> c[i];
		x[i]--; y[i]--;
		
		int hoge = a[x[i]] + b[y[i]] - c[i];
		if (hoge < 0) hoge = 0;
		ans = min(ans, hoge);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2176
fun main(args: Array<String>) {
    val S = next().groupBy { it }.mapValues { it.value.size }
    val C0 = S.getOrElse('0', { 0 })
    val C1 = S.getOrElse('1', { 0 })
    println(2 * Math.min(C0, C1))
}
fun next() = readLine()!!

Measured memory_bytes: 35848
#include <stdio.h>
#include <iostream>
#include <vector>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define vecll vector<ll>
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string strin(){string s;cin>>s;return s;}
bool func(ll n){
    ll sum=0,cnt=0,p=n*(n+1)/2;
    vecll a(n),b(n);
    rep(i,n) sum+=a[i]=lin();
    if(sum%p!=0)return false;
    ll num=sum/p;
    rep(i,n){
        b[i]=a[(i+1)%n]-a[i]-num;
        if(b[i]>0||b[i]%n!=0)return false;
        cnt-=b[i]/n;
    }
    if(cnt!=num)return false;
    return true;
}
int main(){
    string ans=func(in())?"YES":"NO";
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
/*
   Created by Rahul Goel.
*/

#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1e9;
const ll LINF = 1e18;

#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(c) (c).begin(), (c).end()
#define pii pair < ll, ll >
#define vi vector < ll >
#define vb vector < bool >
#define vvi vector < vector < ll > >
#define vvb vector < vector < bool > >
#define vpii vector < pair < ll, ll > >
#define vvpii vector < vector < pair < ll, ll > > >
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define min_pq(t) priority_queue < t, vector < t >, greater < t > >
#define max_pq(t) priority_queue < t >
#define pb push_back
#define ff first
#define ss second

ll mod_sum() { return 0ll; }
template<typename T, typename... Args>
T mod_sum(T a, Args... args) { return ((a + mod_sum(args...))%mod + mod)%mod; }

ll mod_prod() { return 1ll; }
template<typename T, typename... Args>
T mod_product(T a, Args... args) { return (a*mod_product(args...))%mod; }

// --------------------------------------------------------------

ll solve(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k <= a+b)
        cout << min(k, a) << endl;
    else cout << a - (k - a - b) << endl;
    return 0;
}

int main(){
    fastio;

    ll t = 1;
    while(t--)
        solve();

    return 0;
}



Measured memory_bytes: 3612
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <cmath>
#include <functional>

using namespace std;

const int MAX_V = 201;
const int INF = 1000000000;
int d[MAX_V][MAX_V];

void floyd(int n)
{
	for (int k = 1; k <= n; k++)
	{
		for (int i = 1; i <= n; i++)
		{
			for (int j = 1; j <= n; j++)
			{
				if (d[i][j] > d[i][k] + d[k][j])
				{
					d[i][j] = d[i][k] + d[k][j];
				}
			}
		}
	}
}

int main(void)
{
	int n, m, r, a, b, c;
	vector <int> v;
	int res = INF;
	cin >> n >> m >> r;	

	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			if (i == j)
			{
				d[i][j] = 0;
			}
			else
			{
				d[i][j] = INF;
			}
		}
	}

	for (int i = 0; i < r; i++)
	{
		cin >> a;
		v.push_back(a);
	}

	for (int i = 0; i < m; i++)
	{
		cin >> a >> b >> c;
		d[a][b] = c;
		d[b][a] = c;

	}

	floyd(n);
	sort(v.begin(), v.end());
	do
	{
		int sum = 0;
		for (int i = 0; i < v.size() - 1; i++)
		{
			sum += d[v[i]][v[i + 1]];
		}
		res = min(sum, res);
	} while (next_permutation(v.begin(), v.end()));

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

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
inline int read(){
    int x = 0; char c = getchar();
    while (!isdigit(c)) c = getchar();
    while (isdigit(c)) x = x * 10 + c - '0',c = getchar();
    return x;
}
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }
const int N = 200050;
int n,L,A;
struct Monster{
	int xi,hp;
	bool operator < (const Monster w) const{
		return xi < w.xi;
	} 
}a[200050];

int ql,qr,qx[N],qcnt[N],qsum; long long ans = 0;
int main(){
	int i;
	read(n); read(L),L<<=1,read(A);
	for (i = 1; i <= n; ++i) read(a[i].xi),read(a[i].hp);
	for (i = 1; i <= n; ++i) a[i].hp = ((a[i].hp%A) ? (1) : (0)) + a[i].hp / A;
	sort(a+1,a+n+1);
	ql = 1,qr = 0;
	for (i = 1; i <= n; ++i){
		while (ql <= qr && qx[ql] + L < a[i].xi){
			qsum -= qcnt[ql]; ++ql;
		}
		if (qsum < a[i].hp){
			ans += a[i].hp - qsum;
			++qr; qcnt[qr] = a[i].hp - qsum; qx[qr] = a[i].xi;
			qsum = a[i].hp;
		}
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3328
n = int(input())
minv = int(input())
maxv = -1000000000

for i in range(1,n):
  r = int(input())
  m = r-minv
  if maxv < m < 0:
    maxv = m
    minv = r
  elif maxv < m:
    maxv = m
  elif m < 0:
    minv = r

print(maxv)

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

int main(){
  ll A,B,N;
  std::cin >> A>>B>>N;

  ll ans=-1;


    if(N>=(B-1)){
      ll a = floor((double)(A*(B-1))/B);
      ll b = A*floor((double)(B-1)/B);
      ans = a-b;
    }
    else{
      ll a = floor((double)(A*N/B));
      ll b = A*floor((double)(N)/B);
      ans = a-b;
    }

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const int MAX_N=2e5+3;


const unsigned long long B=1e12+7;


int main(){
    LL N,K;
    cin>>N>>K;
    cout<<min(N%K,K-(N%K))<<endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    n = [int(i) for i in input().split()]
    bridge = set()
    counter = 0
    reqs = [[int(j) for j in input().split()] for i in range(n[1])]
    reqs.sort(key=lambda x:(x[0],x[1]))
    
    preset = 0
    for i in range(1, n[0]+1):
        if i in bridge:
            bridge.clear()
            counter += 1
        for j in range(preset, len(reqs)):
            if reqs[j][0] == i:
                bridge.add(reqs[j][1])
            else:
                preset = j
                break
    
    print(counter)

main()

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    ll n; cin >> n;

    vector<ll> s(n, 0);
    for (ll i = 0; i < n; ++i) {
        ll a; cin >> a;
        if (i == 0) {
            s[i] = a;
        } else {
            s[i] = s[i-1] + a;
        }
    }

    ll ans = 1LL<<60;

    for (ll i = 0; i < n-1; ++i) {
        ans = min(ans, abs(s[i] - (s[n-1] - s[i])));
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
# import sys
# input = sys.stdin.readline
# def main():
N = int( input())
A = list( map( int, input().split()))
B = list( map( int ,input().split()))
dpOne = [0]*(N+1)
for i in range(3):
    a, b = A[i], B[i]
    for j in range(N-a+1):
        if dpOne[j+a] < dpOne[j]+b:
            dpOne[j+a] = dpOne[j]+b
donguri = N
for i in range(N+1):
    if donguri < N-i+dpOne[i]:
        donguri = N - i +dpOne[i]
K = donguri
dpTwo = [0]*(K+1)
for i in range(3):
    a, b  = A[i], B[i]
    for j in range(K-b+1):
        if dpTwo[j+b] < dpTwo[j]+a:
            dpTwo[j+b] = dpTwo[j]+a
ans = K
for i in range(K+1):
    if ans < K - i + dpTwo[i]:
        ans = K-i+dpTwo[i]
print( ans)
# if __name__ == '__main__':
#     main()


Measured memory_bytes: 230424
M, D = (int(x) for x in input().split())
ans = 0

M_list = list(range(1,M+1))
D_list = list(range(1,D+1))

for i in M_list:
    for j in D_list:
        if j // 10 >= 2:
            if j % 10 >= 2:
                if i == (j // 10) * (j % 10):
                    ans += 1
                    # print(str(i) + "月" + str(j) + "日")
print(ans)


Measured memory_bytes: 3060
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
#include<iomanip>
#include<map>
#include<iostream>
using namespace std;
int main(){
int a,b,c,d;
int vis[1001]={0},ans=0;
cin>>a>>b>>c>>d;
for(int i=a+1;i<=b;i++)vis[i]++;
for(int i=c+1;i<=d;i++)vis[i]++;
for(int i=0;i<=max(b,d);i++){
	if(vis[i]==2)ans++;
}
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<cmath>

using namespace std;

int main(){
	int n;
	long long ans = (long long)1e18;
	cin >> n;
	vector<long long> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 1; i < n; i++){
		a[i] += a[i - 1];
	}
	long long l = 0, r = 2;
	for(int i = 2; i < n - 1; i++){
		while(l <= i && abs(a[i - 1] - a[l] - a[l]) > abs(a[i - 1] - a[l + 1] - a[l + 1])) l++;
		while(r <= n - 2 && abs((a[n - 1] - a[r]) - (a[r] - a[i - 1])) > abs((a[n - 1] - a[r + 1]) - (a[r + 1] - a[i - 1]))) r++;
		long long b, c, d, e;
		b = a[l];
		c = a[i - 1] - a[l];
		d = a[r] - a[i - 1];
		e = a[n - 1] - a[r];
		ans = min(ans, max({b, c, d, e}) - min({b, c, d, e}));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
import java.io.FileInputStream;
import java.util.Scanner;


public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) throws Exception{
//        System.setIn(new FileInputStream("text"));
        while(hasNext()){
            StringBuilder s = new StringBuilder(NS());
            StringBuilder ans=new StringBuilder();
            if(s.length()==0)return;
            for (int i = 0; i < s.length(); i++) {
                if(s.charAt(i)=='@'){
                    i++;
                    int len = s.charAt(i)-'0';
                    i++;
                    for (int j = 0; j < len; j++) {
                        ans.append(s.charAt(i));
                    }
                } else {
                    ans.append(s.charAt(i));
                }
            }
            System.out.println(ans);
        }
    }

    
    static int c=-2;
    static int NI(){
        return (int)NL();
    }
    
    static long NL(){
        try {
            long r = 0;
            skip();
            if(c=='-') return -NL();
            for(;'0'<=c&&c<='9';c=System.in.read())
                r = r * 10 + c - '0';
            return r;
        } catch (Exception e) {
            return -1;
        }
    }
    
    static char NC(){
        try {
            skip();
            return (char)c;
        } catch (Exception e) {
            return 0;
        }
    }
    
    static String NS(){
        StringBuilder sb=new StringBuilder();
        try {
            skip();
            for(;!isSkip();){
                sb.append((char)c);
                c=System.in.read();
            }
            return sb.toString();
        } catch (Exception e) {
            return "";
        }
    }
    
    static String NLine(){
        StringBuilder sb=new StringBuilder();
        try {
            if(c==-2){
                c=System.in.read();
            }
            for(;c!='\n'&&c!='\r';){
                sb.append((char)c);
                c=System.in.read();
//                System.out.println(c);
            }
//            c=System.in.read();
            skip();
            return sb.toString();
        } catch (Exception e) {
            return "";
        }
    }
    
    static void skip(){
        try{
            while(isSkip()){
                c=System.in.read();
            }
        } catch (Exception e){}
        
    }
    
    static boolean hasNext(){
        skip();
        return c!=-1;
    }
    
    static boolean isSkip(){
        return 0 <= c && c <= ' ' || c == -2;
    }
}

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

string st;
int p = -1, ind,N,ans=1e9;

int main(){
  cin >> st;
  st += '2';
  N = st.size();
  ans = N-1;
  for (int i=0;i<N;++i){
    int x = st[i] - '0';
    if (x == p)continue;
    if(i != 0 && p){
      int t = max({ind , N-i-1, i-ind, min(i, N - ind-1)});
      ans = min(ans, t);
    }
    ind = i; p = st[i] - '0';
  }
  cout<<ans<<'\n';
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

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

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


int main() 
{
    long long N;
    cin >> N;
    
    long long ans = 0; 
    for (long long i = 1; i <= N; i++) {
        if (i % 3 == 0 && i % 5 == 0) {
            continue;
        }
        if (i % 3 == 0) {
            continue;
        }
        if (i % 5 == 0) {
            continue;
        }
        ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
X,Y,Z,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()

def condition(num):
    count=0
    for i in range(0,Z):
        subcount=0
        a=num-C[i]
        s=0
        t=Y-1
        while X-1>=s and t>=0:
            if A[s]+B[t]>=a:
                t-=1
            else:
                subcount+=t+1
                s+=1
        count+=X*Y-subcount
    return count>=K

start=0
end=10**12
while end-start>1:
    test=(end+start)//2
    if condition(test):
        start=test
    else:
        end=test

Kth=0
if condition(end):
    Kth=end
else:
    Kth=start

ans=[]
for i in range(0,Z):
    a=Kth+1-C[i]
    s=0
    t=Y-1
    while X-1>=s and t>=0:
        if A[s]+B[t]>=a:
            for j in range(s,X):
                ans.append(A[j]+B[t]+C[i])
            t-=1
        else:
            s+=1

for i in range(0,K-len(ans)):
    ans.append(Kth)
ans.sort()
for i in range(0,K):
    print(ans[-i-1])


Measured memory_bytes: 47580
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 314159


int n,w;
vector<int>weights(101,0),value(101,0),dp(100005,MOD*MOD);
signed main() 
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    cin>>n>>w;
	int sum=0;
	
	forn(i,1,n)cin>>weights[i]>>value[i];
	dp[0]=0;
	for(auto i : value)sum+=i;
	forn(i,1,n)
	{
		rfor(j,sum,value[i])
			dp[j]=min(dp[j],dp[j-value[i]]+weights[i]);
	}

	
	int ans=0;
	forn(i,1,100000)
	if(dp[i]<=w)
		ans=max(ans,i);
		cout<<ans;


     return 0;

}

//       g++ -g c.cpp ; ./a.exe

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  cin>>N;
  
  vector<int> A(N+1);
for (int i = 1; i < N; i++) {
  cin >> A.at(i);
}
  
  vector<int> B(N+1);
  for (int i = 1; i < N+1; i++) {
  B.at(i)=0;
}
for (int i = 1; i < N+1; i++) {
  //if(i==A.at(i)){
    B.at(A.at(i))++;
 // }
}
  
  for (int i = 1; i < N+1; i++) {
  cout<<B.at(i)<<endl;
}
  
  
  
}



Measured memory_bytes: 4788
(defun solve (a b c d)
  (if (or
        (equal a b)
        (equal b c)
        (equal c d))
      "Bad"
      "Good")
  )


(let* ((s (read-line))
       (a (elt s 0))
       (b (elt s 1))
       (c (elt s 2))
       (d (elt s 3)))
  (format t "~A~%" (solve a b c d)))

Measured memory_bytes: 10212
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9

int n,m,q;
vector<int>ans;
int res=0,t=0;;
class query
{
    public:
    int a,b,c,d;
    query(int x,int y,int z,int u)
    {
        a=x;b=y;c=z;d=u;
    }
};
vector<query>v;
void func()
{
    t+=1;
    int sc=0;
    // for(int i=0;i<ans.size();i++)
    //     cout << ans[i] << " ";
    // cout << endl;
    for(int i=0;i<v.size();i++)
    {
        int a=v[i].a,b=v[i].b,c=v[i].c,d=v[i].d;
        if(ans[b-1]-ans[a-1]==c)
            sc+=d;
    }
    res=max(res,sc);
}

void perm(int ind)
{
    if(ind==m)
    {
        int req=n-ans.size();
        for(int i=0;i<req;i++)
            ans.push_back(ind);
        func();
        for(int i=0;i<req;i++)
            ans.erase(ans.end()-1);
        return;
    }
    else
    {
        int n1=n-ans.size();
        for(int i=0;i<n1;i++)
        {
            int t=n-ans.size();
            for(int j=0;j<min(i,t);j++)
                ans.push_back(ind);
            perm(ind+1);
            while(ans.size()>0 and ans[ans.size()-1]==ind)
                ans.erase(ans.end()-1);
        }   
    }
}

int main()
{
    fastio;
    cin >> n >> m >>q;
    for(int i=0;i<q;i++)
    {
        int a,b,c,d;
        cin >>a >> b >> c >> d;
        query t(a,b,c,d);
        v.push_back(t);
    }
    perm(1);
    cout << res << endl;
}

Measured memory_bytes: 3576
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c,d,i,ans=0;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a>b) swap(a,b);
    if(c>d) swap(c,d);
    for(i=0; i<=100; i++)
    {
        if(a<=i&&i<b&&c<=i&&i<d)
            ans++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

void dfs(int n, char biggest, string s, const int N) {
    if (n == N) {
        cout << s << endl;
        return;
    }

    for (char c = 'a'; c <= biggest + 1; c++) {
        dfs(n + 1, max(c, biggest), s + c, N);
    }
}

int main(void) {
    int N;
    cin >> N;

    dfs(1, 'a', "a", N);

    return 0;
}


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

# define ll long long

int main(){
  
  bool allNumbersEven = true;
  int n, p;
  cin >> n >> p;
  
  for(int i=0; i<n; i++){
    int num;
    cin >> num;
    if(num % 2 == 1) allNumbersEven = false;
  }
  
  ll ans;
  if(allNumbersEven){
    if(p == 0) ans = 1ll << n;
    else ans = 0;
  } else {
    ans = 1ll << (n-1);
  }
  
  cout << ans << endl;
  return 0;
} 



Measured memory_bytes: 3636
#!/usr/bin/python3
# -*- coding: utf-8 -*-
s = int(input())
mod = 10**9 + 7
a_list = [0] * (2000 + 1)
a_list[0] = 1
a_list[1] = 0
a_list[2] = 0
a_list[3] = 1
for i in range(4, s + 1):
    a_list[i] = a_list[i - 1] + a_list[i - 3]
    a_list[i] %= mod
print(a_list[s])

Measured memory_bytes: 9208
#include<iostream>
#include<stack>
#include<vector>
#include<cmath>
#define ll long long
#define rep(i,a,b) for(ll i = a;i < b;i++)
#define N 55

using namespace std;

ll n,s,ar[N];

bool check(ll k)
{
    ll cur = 0;

    rep(i,0,n)
        cur = cur+(ar[i]+k+1)/(n+1);

    return (cur==k);
}

int main()
{
    cin >> n;

    rep(i,0,n)
    {
        cin >> ar[i];
        s+=ar[i];
    }

    for(ll test = max((ll)0,s-n*n);test <= s;test++)
    {
        if(check(test))
        {
            cout << test;
            return 0;
        }
    }

    return 0;
}



Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cout.setf(ios::fixed);
	cout.precision(20);
	ll n, m, d;
	cin >> n >> m >> d;
	ll cnt = 0;
	if (d == 0)
		cnt = n;
	else
		cnt = 2 * (n - d);
	cout << (m - 1) * cnt / ld(n * n);
	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b;
  cin >>a>>b;
  int x=0;
  
  if(a==1||b==1)
    x += 100;
  
  if(a==2||b==2)
    x += 10;
  
  if(a==3||b==3)
    x += 1;
  
  if(x==110)
    cout <<"3"<< endl;
  if(x==101)
    cout <<"2"<< endl;
  if(x==11)
    cout <<"1"<< endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
bool a[10];
bool right(int n){
  while(n>0){
    if(a[n%10]==1)return true;
    n/=10;
  }
  return false;



}
int main()
{
   int n,k;
   cin>>n>>k;
   //int a[10];
   for(int i=0;i<k;i++){
      int s;
      cin>>s;
      a[s]=1;
   }
   while(right(n)){
    n++;
   }
   cout<<n<<endl;
    return 0;
}


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

#define int long long

using namespace std;

const int oo = 2e18;



int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int N;
    cin >> N;

    vector<int> arr(N);

    for(int i = 0 ; i < N-1 ; i++)
    {
    	int n;
    	cin >> n;
    	arr[n-1]++;
    }

    for(auto x : arr)cout << x << '\n';

    return 0;
}

Measured memory_bytes: 4780
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <vector>

using namespace std;


int main(int argc, char const *argv[])
{
    int MOD = 1000000007;
    int N, K;
    cin >> N >> K;
    unordered_map<int, vector<long long int>> comb;
    comb[0].push_back(1LL);
    comb[1].push_back(1LL);
    comb[1].push_back(1LL);
    for (int i = 2; i <= max(N - K + 1, K - 1); i++) {
        for (int j = 0; j <= i; j++) {
            if (j == 0 || j == i) {
                comb[i].push_back(1LL);
            } else {
                long long int value = (comb[i - 1][j - 1] + comb[i - 1][j]) % MOD;
                comb[i].push_back(value);
            }
        }
    }
    // for (int i = 1; i <= N; i++) {
    //     auto vec = comb[i];
    //     for (auto v: vec) {
    //         cout << v << ", ";
    //     }
    //     cout << endl;
    // }

    long long int ans;
    for (int l = 1; l <= K; l++) {
        if (l > N - K + 1) {
            ans = 0;
        } else {
            // N-K+1_C_l * (K + l - 1)_C_K
            ans = comb[N - K + 1][l] * comb[K - 1][l - 1] % MOD;
        }
        cout << ans << endl;

    }
    return 0;
}


Measured memory_bytes: 20480
#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 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<<55;
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;
vi p;
vl a,b,c;

int main(){
	cin>>n>>m;
	p=vi(m);
	a=b=c=vl(n-1);
	for(int i=0;i<m;i++){
		cin>>p[i];
		p[i]--;
	}
	for(int i=0;i<n-1;i++) cin>>a[i]>>b[i]>>c[i];
	vi s(n);
	for(int i=0;i<m-1;i++){
		int A=p[i],B=p[i+1];
		s[min(A,B)]++;
		s[max(A,B)]--;
	}
	for(int i=1;i<n;i++) s[i]+=s[i-1];
	ll ans=0;
	for(int i=0;i<n-1;i++){
		ans+=min(a[i]*s[i],b[i]*s[i]+c[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6216
n, d = map(int,input().split())

total = []
for i in range(n):
    x = list(map(int,input().split()))
    total.append(x)

ans = 0
for i in range(n):
    for j in range(i+1,n):
        temp = 0
        for y,z in zip(range(d),range(d)):
            temp += (total[i][y] - total[j][z])**2
        if temp**0.5 == int(temp**0.5):
            ans += 1

print(ans)

Measured memory_bytes: 9464
N = int(input())
a, b, c = 1, 1, 1
for i in range(N):
  a *= 10
  b *= 9
  c *= 8
  a %= 10**9+7
  b %= 10**9+7
  c %= 10**9+7
print((a-b*2+c)%(10**9+7))

Measured memory_bytes: 9172
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

int main() {

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

        if (n == 0) break;
        int *s = new int[n];

        double m = 0.0;
        for (int i = 0; i < n; ++i) {
            cin >> s[i];
            m += s[i];
        }
        m /= n;

        double sigma = 0.0;
        for (int i = 0; i < n; ++i) {
            sigma += pow(s[i] - m, 2);
        }
        sigma /= n;
        sigma = sqrt(sigma);

        cout << fixed << setprecision(7) << sigma << endl;
        delete[] s;
    }

    return 0;
}

Measured memory_bytes: 1268
# https://atcoder.jp/contests/abc126/tasks/abc126_a
import itertools
from collections import Counter
from collections import defaultdict
import bisect

def main():
    N, K = map(int, input().split())
    S = list(input())
    S[K-1] = S[K-1].lower()
    print(''.join(S))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

/* add vars here */

ll a,b;
string s;

/* add your algorithm here */

int main() {
  cin >> a >> b;
  ll t = a * b;
  if (t % 2 == 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int n,ans=0;
	cin >> n;
	vector<int>	a(n),b(n);
	for(int i=0;i<n;i++)	cin >> a[i];
	for(int i=0;i<n;i++)	cin >> b[i];
 	for(int i=1;i<n;i++)	a[i]+=a[i-1];
	for(int i=n-2;i>=0;i--)	b[i]+=b[i+1];
	for(int i=0;i<n;i++)	ans = max(ans,a[i]+b[i]);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
using namespace std;
const int MAXN = 100005;
const LL MOD = 998244353;

int n, h[MAXN], dp[MAXN];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> h[i];
	
	dp[1] = 0;
	dp[2] = abs(h[1] - h[2]);
	for (int i = 3; i <= n; i++) {
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	
	cout << dp[n] << "\n";
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  vector<int> vec;
  vector<bool> used(N, false);
  function<bool(int)> dfs = [&](int u) {
    for (int v : G[u]) {
      if (used[v]) continue;
      used[v] = true;
      if (dfs(v)) {
        vec.emplace_back(v);
        return true;
      }
      used[v] = false;
    }
    return true;
  };
  used[0] = true;
  dfs(0);
  auto res = vec;
  res.emplace_back(0);
  vec.resize(0);
  dfs(0);
  for (int i = (int)vec.size() - 1; i > -1; i--) {
    res.emplace_back(vec[i]);
  }
  cout << res.size() << '\n';
  for (const auto& e : res) {
    cout << e + 1 << (&e == &res.back() ? '\n' : ' ');
  }
  return 0;
}


Measured memory_bytes: 15700
inf = 10**9
n = int(input())
lst = list(map(int,input().split()))
cnt = 0
m = inf
total = 0
for i in range(n):
    if lst[i] < 0:
        cnt += 1
    if abs(lst[i]) < m:
        m = abs(lst[i])
    total += abs(lst[i])
if cnt%2==0:
    print(total)
else:
    print(total - 2*m)

Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

char field[6][6];

void solve(istream& cin, ostream& cout) {
  int h, w, k;
  cin >> h >> w >> k;
  REP(i, h) {
    REP(j, w) {
      cin >> field[i][j];
    }
  }
  int ans = 0;
  REP(bit1, (1 << h) - 1) {
    REP(bit2, (1 << w) - 1) {
      int cnt = 0;
      REP(i, h) {
        REP(j, w) {
          // 塗られなかった行・列の黒色をカウント
          if (!(bit1 & (1 << i)) && !(bit2 & (1 << j)) && field[i][j] == '#')
            cnt++;
        }
      }
      if (cnt == k) ans++;
    }
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 3640
### SNIPPET
  # n = gets.split.map(&:to_i)
  # array = n.times.map { gets.split.map(&:to_i) }
  # [].all?(&:even?)
  # a = [*1..m].repeated_combination(n).to_a
  # [1,2,3,4,5].select { |num| num.even? }  # => [2, 4]
  # ["a","a","b"].group_by(&:itself).map{|k,v| [k, v.count]}.to_h #=> {"a"=>2, "b"=>1}
  # 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
  # 3.upto(6) do |i|, 6.downto(3) do |i|
  # 公約数125.gcd(100)、公倍数125.lcm(100)
  # PI = Math::PI
  # 高さ = a * Math.sin(w / 180.0 * Math::PI), 底辺 = a * Math.cos(w / 180.0 * Math::PI)
  # def chmax(a, b) a > b ? a : b end
  # INF = Float::INFINITY
  # def chmin(a, b) a < b ? a : b end

n,l = gets.split.map(&:to_i)
s = []
n.times {s << gets.chomp}


puts s.sort.join

Measured memory_bytes: 1788
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {

    int n;
    while(true){
        cin>>n;
        if(n==0)break;
        vector<int> v(26,0);
        vector<char> in(n);
        pair<int,int> ans;
        rep(i,n){cin>>in[i];}
        for(int i=0;i<n;i++){
            int index=in[i]-'A';
            v[index]++;
            int nokori=n-(i+1);

            vector<pair<int,int>> c;
            rep(j,26){
                if(v[j]!=0)c.push_back({v[j],j});
            }

            sort(c.rbegin(),c.rend());
            if(c.size()==1){
                if(c[0].first>nokori){
                    ans.first=c[0].second;
                    ans.second=i+1;
                    break;
                }
            }else{
                if(c[0].first>c[1].first+nokori){
                    ans.first=c[0].second;
                    ans.second=i+1;
                    break;
                }
            }

        }

        if(ans.first==0&&ans.second==0){
            cout<<"TIE"<<endl;
        }else{
            cout<<char(ans.first+'A')<<" "<<ans.second<<endl;
        }



    }

    return 0;
}



Measured memory_bytes: 3020
#include <iostream>
#include <set>
using namespace std;
multiset<int> ans;

int main() {
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) {
    int a;
    cin >> a;
    auto itr = ans.lower_bound(a);

    if(itr == ans.begin()) ans.insert(a);
    else {
      --itr;
      ans.erase(itr);
      ans.insert(a);
    }
  }

  /*for(auto itr = ans.begin(); itr != ans.end(); ++itr) {
    cout << *itr << endl;
    }*/

  cout << ans.size() << endl;
      
  
}


Measured memory_bytes: 4992
#include <stdio.h>

int main(void)
{
	int H,W,i,j;
	while (1){
		scanf("%d %d", &H, &W);
		if (H==0 && W==0)
			break;
		for(i=1; i<=H; i++){
			for(j=1; j<=W; j++)
				putchar('#');
			putchar('\n');
		}
	putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 572
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int INF = 1e9 + 5;
bool comp(const int a , const int b) {
	return a < b;
}
int main() {
	int n,k;
	cin>>n;
	vector<int> dp[2];
	dp[0].resize(3);
	dp[1].resize(3);
	for(int i=1;i<=n;i++) {
		int a, b, c;
		cin>>a>>b>>c;
		dp[i&1][0] = max(dp[(i-1)&1][1], dp[(i-1)&1][2]) + a;
		dp[i&1][1] = max(dp[(i-1)&1][0], dp[(i-1)&1][2]) + b;
		dp[i&1][2] = max(dp[(i-1)&1][0], dp[(i-1)&1][1]) + c;
	}
	int ans = max({dp[n&1][0], dp[n&1][1],dp[n&1][2]});
	cout<<ans<<endl; 
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define X 100

int main(){
	int D, N;
	scanf("%d %d", &D, &N);
	int i, ans, num=1, temp;
	
	for(i=0;i<D;i++){
		num*=X;
	}
	ans=num*N;
	temp=ans;
	for(i=0;i<=D&&temp%100==0;i++){
		temp/=X;
	}
	if(i!=D){
		for(i=0;;i++){
			ans+=num;
			temp=ans;
			for(i=0;i<=D&&temp%100==0;i++){
				temp/=X;
			}
			if(i==D){
				break;
			}
		}
	}
	
	printf("%d", ans);
}

Measured memory_bytes: 128
/* ex9_2
   UMAboogie */
#include <stdio.h>
#include <stdlib.h>
#define SIZE 100000

//リストのノードの定義
typedef struct node{
  char elem;
  struct node *next;
} node;

//スタックにデータを追加
void push(node **first, char elem){
  //追加する分の領域を確保
  node *new = calloc(1, sizeof(node));
  if(new == NULL){
    exit(1); //確保できなかったら終了
  }
  new->elem = elem; //新しいノードの中身を追加
  new->next = *first;
  *first = new;
}

//スタックからデータを取り出す
char pop(node **first){
  char elem;
  node *tmp = *first;
  if(tmp == NULL){
    exit(1);
  }
  elem = tmp->elem;
  *first = tmp->next;
  //取り出したノードのメモリを解放
  free(tmp);
  return elem;
}

int main(void){
  int count = 0,i = 0;
  node *first = NULL; //最初のノードの指す先
  char str[SIZE+1]; //入力を一時的に保存する配列を宣言
  scanf("%s",str); //入力
  while(str[i] != '\0'){
    if(first == NULL || str[i] == first->elem){ //最初のキューブか前の色と同じ時
      push(&first,str[i]); //リストに追加
    }else{ //前の色と違う時
      pop(&first); //リストから取り出す
      count += 2; //取り除いた数を2加算
    }
    i ++;
  }

  printf("%d\n",count); //結果を出力
  return 0;
}

Measured memory_bytes: 4952
import java.util.*;

class Main{
	int a;
	int b;
	public Main(){
		Scanner scan = new Scanner(System.in);
		for(;;){
			a=scan.nextInt();
			b=scan.nextInt();
			if(a==0 || b==0)break;
			for(int i=0; i<a; i++){
				if(i%2==1){
					for(int j=0; j<b; j++){
						if(j%2==1){
							System.out.print("#");
							}else{
								System.out.print(".");
							}
					}
				}else{
					for(int k=0; k<b; k++){
						if(k%2==1){
							System.out.print(".");
						}else{
							System.out.print("#");
						}
					}
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
	public static void main(String[]args){
		new Main();
	}
}

Measured memory_bytes: 33112
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <tuple>
#include <cmath>
#include <array>
using namespace std;

int main(){
    int a,b,c,d,e,f,g,h,i;
    cin>>a>>b>>c>>d>>e>>f>>g>>h>>i;
    if (a-d!=b-e || a-d!=c-f || b-e!=c-f || a-g!=b-h || a-g!=c-i || b-h!= c-i || d-g!=e-h || d-g!= f-i || e-h!=f-i || a-b!=d-e || a-b!=g-h || d-e!=g-h || a-c!=d-f || a-c!=g-i || d-f!=g-i || b-c!=e-f || b-c!=h-i || e-f!=h-i){
        cout<<"No"<<endl;
    }
    else cout<<"Yes"<<endl;
}


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

#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string outputYesNo(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int x,y;cin>>x>>y;
  map<int,int> m;
  m[1]=0;
  m[2]=2;
  m[3]=0;
  m[4]=1;
  m[5]=0;
  m[6]=1;
  m[7]=0;
  m[8]=0;
  m[9]=1;
  m[10]=0;
  m[11]=1;
  m[12]=0;
  cout<<outputYesNo(m[x]==m[y])<<endl;
  return 0;
}


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

N = int(input())
H = list(map(int, input().split()))
ret = 0

for c in range(100):
    f = False
    cnt = 0
    if H.count(0) == N: break
    for i in range(N):
        if H[i] > 0:
            H[i] -= 1
            f = True
        else:
            if f == True:
                cnt += 1
                f = False

        if i == N-1 and f == True:
            cnt += 1

    ret += cnt

print(ret)


Measured memory_bytes: 9092
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	cout << t << s << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
#include <bitset>
typedef long long ll;
typedef long double ld;

#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
    string S;
    cin >> S;
    if (S == "ABC"){
        cout << "ARC" << endl;
    }
    else {
        cout << "ABC" << endl;
    }
    return 0;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define intt int64_t
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007

int main() {
    int a, b;
    scanf("%d %d", &a, &b);
    if (a+b>9) printf("error\n");
    else printf("%d\n", a+b);
}


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

using namespace std;
typedef long long ll;
#define sz(x) (ll)((x).size())
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)

int main(){
	//input
	string s;
	ll K; cin>>s>>K;
	set<string> se;

	rep1(i,K){
		if(i<=sz(s)){
			rep(j,sz(s)+1-i){ //始点
				string t="";
				t+=s[j];
				rep1(k,i-1){
					t+=s[j+k];
				}
				se.insert(t);
			}
		}
	}

	ll sub=1;
	for(auto it=se.bg;it!=se.ed;it++){
		if(sub++==K){
			cout<<*it;
			return 0;
		}
	}
}

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

int main() {
  string a; cin>>a;
  int n = a.size();

  vector<int> s(26, 0);
  for (int i = 0; i < n; i++) ++s[a[i] - 'a'];

  long long ans = 0;
  for (int i = 0; i < 26; i++) ans += (long long)s[i] * (n-s[i]);
  ans = ans / 2 + 1;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		var x = Console.ReadLine().Split().ToArray();
		long a = long.Parse(x[0]);
		decimal c = decimal.Parse(x[1]);
		c *= 100;
		long b = (long)c;
		long ans = a*b;
		ans /= 100;
		Console.WriteLine(ans);
		
		
	}
}

Measured memory_bytes: 28028
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    long A;
    long long B,N,x;
    cin >> A >> B >> N;
    if(N>=B-1)x=B-1;
    else x=N;
    long long result = floor(A*x/B)-A*floor(x/B);
    cout << result << '\n';
    return 0;
}

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

int main() {
  int N, f=1;
  cin>>N;
  vector<int> vec(N);
  for(int i=0; i<N; i++) {
    cin>>vec.at(i);
    }
  for(int i=1; i<N;i++){
    for(int j=0;j<i;j++){
      if(vec.at(i)-vec.at(j)<0)break;
      else if(i==j+1)f++;
    }
  }
  cout<<f<<endl;
} 

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

int main() {
    int n; cin >> n;
    int q; cin >> q;
    string s; cin >> s;
    vector<int> sum(n+1, 0);
    vector<int> begin_point(q), end_point(q);
    for (int i = 0; i < q; i++){
        cin >> begin_point[i] >> end_point[i];
    }
    for (int i = 1; i < n; i++){
        if (s[i-1] == 'A' && s[i] == 'C'){
            sum[i+1] = sum[i]+1;
        }else{
            sum[i+1] = sum[i];
        }
    }
    for (int i = 0; i < q; i++){
        cout << sum[end_point[i]] - sum[begin_point[i]] << endl;
    }

    return 0;
}

Measured memory_bytes: 2176
n=int(input())
a=list(map(int,input().split()))
dif1=[0 for _ in range(n)]
dif2=dif1[:]
ans=[0 for _ in range(n)]
s=sum(a)
for i in range(n):
  dif2[i]=a[(i+1)%n]-a[i%n]
p=0  
for i in range(1,n):
  j=(2*i)%n
  dif1[j]=p+a[j-1]-a[j-2]
  p=dif1[j]
ans[0]=(s-sum(dif1)*2)//n
p=ans[0]
for i in range(1,n):
  ans[i]=p+dif1[i]*2


#print(dif2,dif1,ans[0])
print(*ans)

Measured memory_bytes: 22048
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

from collections import deque


N, M = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(M):
    i, j = map(int, input().split())
    G[i-1].append(j-1)
    G[j-1].append(i-1)


# dはparent
def bfs(start):
    distance = [-1 for _ in range(N)]
    Q = deque()
    Q.append(start)
    d = [-2 for _ in range(N)]
    d[start] = -1
    distance[start] = 0
    while len(Q) > 0:
        u = Q.popleft()
        for v in G[u]:
            if d[v] == -2:
                Q.append(v)
                d[v] = u  # 親のノード
                distance[v] = distance[u] + 1
    
    return d, distance

p, distance = bfs(0)


for path in p:
    if path == -2:
        print("No")
else:
    print("Yes")
    for path in p[1:]:
        print(path + 1)

Measured memory_bytes: 98892
#include "bits/stdc++.h"
using namespace std;
int Array[100005] , Freq[100005];

int main(){
    int N , i;
    long long Sum = 0LL;
    scanf( "%d" , &N );
    
    for( i = 1 ; i <= N ; ++i ){
        scanf( "%d" , Array + i );
        Sum = Sum + Array[i];
        ++Freq[Array[i]];
    } 

    int Q , B , C;
    scanf( "%d" , &Q );

    for( i = 1 ; i <= Q ; ++i ){
        scanf( "%d%d" , &B , &C );
        
        if( Freq[B] > 0 ){
            Sum -= Freq[B] * 1LL * B;
            Sum += Freq[B] * 1LL * C;
            Freq[C] += Freq[B];
            Freq[B] = 0;
        }   

        printf( "%lld\n" , Sum );
    }

    return 0;
}

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

int F[102][102];

bool DFS(int X, int Y, int Xg, int Yg, int c){
	if(F[Y][X] != c){
		return false;
	}else if(F[Y][X] == c && X == Xg && Y == Yg){
		return true;
	}
	F[Y][X] = -1;
	if(DFS(X, Y - 1, Xg, Yg, c)){
		return true;
	}else if(DFS(X + 1, Y, Xg, Yg, c)){
		return true;
	}else if(DFS(X, Y + 1, Xg, Yg, c)){
		return true;
	}else if(DFS(X - 1, Y, Xg, Yg, c)){
		return true;
	}
	
	return false;
}

int main(){
while(true){
	int w, h;
	cin >> w >> h;
	if(w == 0 && h == 0){
		break;
	}
	int xs, ys, xg, yg;
	cin >> xs >> ys >> xg >> yg;
	int n;
	cin >> n;
	for(int y = 0; y < 102; y++){
		for(int x = 0; x < 102; x++){
			F[y][x] = -1;
		}
	}
	for(int i = 0; i < n; i++){
		int c, d, x, y;
		cin >> c >> d >> x >> y;
		if(d == 0){
			for(int X = x; X < x + 4; X++){
				for(int Y = y; Y < y + 2; Y++){
					F[Y][X] = c;
				}
			}
		}else if(d == 1){
			for(int X = x; X < x + 2; X++){
				for(int Y = y; Y < y + 4; Y++){
					F[Y][X] = c;
				}
			}
		}
	}
	if(F[ys][xs] != -1){
		if(DFS(xs, ys, xg, yg, F[ys][xs])){
			cout << "OK" << endl;
		}else{
			cout << "NG" << endl;
		}
	}else{
			cout << "NG" << endl;
	}
}
	return 0;
}

Measured memory_bytes: 3040
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <math.h>
#include <algorithm>

using namespace std;

#define _INF_ 10000000

int N,A,B,C;

int dfs(vector<int>& l, int cur, int a, int b, int c)
{
  if (cur == N) {
    if (a == 0 || b == 0 || c == 0) return _INF_;
    return abs(A-a) + abs(B-b) + abs(C-c) - 30;
  }
  int ret0 = dfs(l, cur+1, a, b, c);
  int ret1 = dfs(l, cur+1, a+l[cur], b, c) + 10;
  int ret2 = dfs(l, cur+1, a, b+l[cur], c) + 10;
  int ret3 = dfs(l, cur+1, a, b, c+l[cur]) + 10;
  return min(ret0, min(ret1, min(ret2, ret3)));
}

int main()
{
  cin >> N >> A >> B >> C;
  vector<int> l(N, 0);
  for (int i=0;i<N;i++) {
    cin >> l[i];
  }
  int ans = dfs(l, 0, 0, 0, 0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256