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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
  int K;
  cin >> K;
  cout << (K / 2 * (K - K / 2)) << endl;

	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	int n; cin >> n;
	rep(i, n) {
		int a, b; cin >> a >> b;
		Cout(a%b == 0 ? b : a % b);
	}
}


Measured memory_bytes: 3104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClassLibrary1
{
    public class ListNode
    {
        public int val;
        public ListNode next;
        public ListNode(int x) { val = x; }
    }


    public class Class1
    {
        static Dictionary<Tuple<long, long>, long> dic = new Dictionary<Tuple<long, long>, long>();


        static void Main(string[] args)
        {

            var N = ReadLong();
            var pl = new PlayList[N];
            for(int i=0; i<N; i++)
            {
                var ss = ReadStringArr();
                pl[i] = new PlayList
                {
                    title = ss[0],
                    time = long.Parse(ss[1])
                };

            }
            
            var X = ReadString();

            var index = 0;
            for( int i=0; i<N; i++)
            {
                index = i;
                if (pl[i].title == X)
                {
                    break;
                }
            }

            long res = 0;

            for( int i= index+1; i<N; i++)
            {
                res += pl[i].time;
            }

            Console.WriteLine(res);

        }

        class PlayList
        {
            public string title;
            public long time;
        }




        private static string ReadString()
        {
            return Console.ReadLine();
        }
        private static string[] ReadStringArr()
        {
            return Console.ReadLine().Split(' ');
        }
        private static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadLongArr()
        {
            string[] s = ReadStringArr();
            long[] l = new long[s.Length];
            for(int i=0; i<l.Length; i++)
            {
                l[i] = long.Parse(s[i]);
            }

            return l;
        }
    }

}


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

signed main(){
  
  int n, m;
  cin>>n>>m;
  
  vector<int> to[10];
  
  for(int i=0;i<m;i++){
    int k;
    cin>>k;
    for(int j=0;j<k;j++){
      int idx;
      cin>>idx;
      to[i].push_back(idx-1);
    }
  }
  
  vector<int> p(m);
  
  for(int i=0;i<m;i++) cin>>p[i];
  
  int ans = 0;
  
  for(int S=0;S<(1<<n);S++){
    
    int flg = 1;
    
    for(int i=0;i<m;i++){
      
      int cnt = 0;
      
      for(int j : to[i]){
	cnt += ( S >> j ) & 1;
      }
      
      if( cnt % 2 != p[i] ) flg = 0;
	
    }
    
    ans += flg;
    
  }
  
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
using namespace std;


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

/* vector<int> A(N); */
/* xの二乗
 pow(x, 2.0) */
 
int main() {
  
  long long H,A=1,count=0;
  cin >> H;
  
  while (H>1){
    count++;
    H=H/2;
  }
  
  rep(i,count){
  	A+= pow(2, i+1);
  }
  
  
  cout << A << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define Fori(g) for(int i=0;i<g;i++)
#define	Forj(g) for(int j=0;j<g;j++)
#define min(aa,bb) (aa<bb)?aa:bb
#define max(aa,bb) (aa<bb)?bb:aa

int main(){
	char s[100],t[100],sum[300];
	int c=0;
	int n;
	scanf("%d",&n);
	scanf("%s%s",s,t);
	for(int i=0;i<strlen(s);i++){
		printf("%c",s[i]);
		printf("%c",t[i]);
	}

	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int a,b,c,count=0,d;
   scanf("%d %d %d",&a,&b,&c);
   for(int i=a;i<b+1;i++){
     if(c%i==0){count++;}
   }
   printf("%d\n",count);
   return 0;
   
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
long long oll = 0;
#define ll long long
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define pii pair<int,int>
#define lcm(a,b) a*b/__gcd(a,b)
#define fl(i,a,b) for(ll i = a;i < b;i++)
#define lf(i,a,b) for(ll i = b;i >= a;i--)
#define MEM(x,y) memset(x,y,sizeof(x))
#define mp make_pair
#define bs(x,y) binary_search(x.begin(),x.end(),y)
#define nl "\n"
#define sp " ";
#define srt(x) sort(x.begin(),x.end())

void solve()
{
    string a;
    cin>>a;
    string p,q;
    p = "ABC";
    q = "ARC";
    if(a == p)cout<<q<<nl;
    else if(a == q)cout<<p<<nl;
}

int main()
{
    FIO;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    solve();
    return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
#define pld pair<pll,ll>
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
	return (x>=0 and y>=0 and x<n and y<m);
}
bool isprime[100005];
vector<ll> prime;
void sievetoprime(ll n)
{
	mem(isprime,true);
	for(ll p=2;p*p<=n;p++)
	{
		if(isprime[p]==true)
		{
			for(ll i=p*p;i<=n;i+=p)
				isprime[i]=false;
		}
	}
}
void solve()
{	
	ll n;
	cin>>n;
	sievetoprime(100004);
	for(ll i=n;i<=100003;i++)
	{
		if(isprime[i])
		{
			cout<<i;
			return;
		}
	}
}	
int main()
{
	IOS
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>

using namespace std;

const long long LIM = 1e18;

long long V[4];
long long NV[4];

long long K;

int main(){

    cin >> V[1] >> V[2] >> V[3] >> K;
    long long ans = V[1] - V[2];
    if(K % 2){
        ans *= -1;
    }
    if(abs(ans) > LIM){
        cout << "Unfair";
    }
    else{
        cout << ans;
    }
    return 0;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
D = int(input())


count=0
res =0

for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            total = 500*a +100*b +50*c
            if total == D:
                res += 1
            
print(res)

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

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define fr(i,k) for(i=0;i<k;i++)
#define ALL(c) (c).begin(),(c).end()
#define deb(x) cerr<<#x<<"  = "<<x<<endl;
#define SZ(x) (x).size();
#define ll long long
#define MOD 1000000007
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define em emplace_back
#define ulli unsigned long long int
#define INF 1e18
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> ii;
void solve();

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main() {
	fastio;
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/

	int t;
	t=1;

    //cin>>t;
	while (t--)
	{
		solve();
	}
	return 0;
}

void solve()
{
	ll n,k, i,j, ans;
	cin >> n >> k;

	ll a[n+1];

	for (i = 1; i <= n; i++)
		cin >> a[i];

	vector<vector<ll>> dp(n + 2, vector<ll>(k + 2));

	for(j=0;j<=k;j++)
        dp[1][j]=(j>a[1])?0:1;

    for(i=2;i<=n;i++)
    {
        for(j=0;j<=k;j++)
        {
            if(j==0)
                dp[i][j]=dp[i-1][j];
            else
                dp[i][j] = (dp[i][j-1]+dp[i-1][j] - ( (j-a[i]-1 >=0)? dp[i-1][j-a[i]-1]:0)+MOD)%MOD;
        }
    }

    ans=dp[n][k];
	cout << ans << endl;
}


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

#define INF (1<<30)

int W;
int A[100001];

int Fa[100001];
int Fb[100001];
int main(){
  cin >> W;
  for(int i=0;i<W;i++) cin >> A[i];

  for(int i=0;i<W;i++){
    if( A[i] == 0 ) Fa[i] = INF;
    else if( A[i] < 0 )
      Fa[i] = min( Fa[i], -A[i] );
    Fa[i+1] = Fa[i]-1;
  }

  for(int i=W-1;i>=0;i--){
    if( A[i] == 0 ) Fb[i] = INF;
    else if( A[i] < 0 )
      Fb[i] = min( Fb[i], -A[i] );
    if( i == 0 ) break;
    Fb[i-1] = Fb[i]-1;
  }
  

  long long res = 0;
  for(int i=0;i<W;i++){
    if( A[i] > 0 ){
      int ret1=0, ret2=0;
      if( Fa[i] >  0 ) ret1 = min( Fa[i], A[i] );
      if( Fb[i] >  0 ) ret2 = min( Fb[i], A[i] ); 
      res += (long long)max(ret1,ret2);      
    }
  }
  cout << res << endl;
  
  
}

Measured memory_bytes: 2332
N = int(input())
res = int(1e18)

for i in range(1, (N+1)//2):
    A = map(int, list(str(i)))
    B = map(int, list(str(N-i)))
    res = min(res, sum(A)+sum(B))

if N == 2:
    res = 2

print(res)


Measured memory_bytes: 42088
function main()
  
  (A,B) = map(x -> parse(Int,x), split(readline()))
  
  count = 0
  
  for i in A:B

    check = split(string(i),"")

    if check[1]*check[2] == check[5]*check[4]
      count += 1
    end
    
  end
  
  println(count)
  
end

main()

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

long divide_sum(long, long, int);

int main()
{
    string n_str;
    int n_digits;
    long n, sum = 0;
    cin >> n_str;
    n_digits = n_str.size();
    n = stol(n_str);
    sum += divide_sum(0, n, n_digits);
    cout << sum << endl;
    return 0;
}

long divide_sum(long l, long r, int r_digits)
{
    if (r_digits == 1) return l + r;
    long sum = l + r;
    for (int i = 1; i < r_digits; i++)
    {
        long mod = long(pow(10, (r_digits - i)));
        long l_tmp = l;
        l_tmp += r / mod;
        long r_tmp = r % mod;
        sum += divide_sum(l_tmp, r_tmp, r_digits - i);
    }
    return sum;
}

Measured memory_bytes: 256
while True:
    try:
        cards = list(map(int, input().split(',')))
        cards.sort()

        if len(set(cards)) == 5:
            c = cards[0]
            if cards == [c, c+1, c+2, c+3, c+4]:
                print("straight")
            elif cards == [1,10,11,12,13]:
                print("straight")
            else:
                print("null")
        else:
            if len(set(cards)) == 2:
                t = cards.count(cards[0])
                if t == 1 or t == 4:
                    print("four card")
                else:
                    print("full house")
            elif len(set(cards)) == 3:
                flag = True
                i = 0
                while flag:
                    c = cards[i]
                    if cards.count(c) == 3:
                        print("three card")
                        flag = False
                    if cards.count(c) == 2:
                        print("two pair")
                        flag = False
                    i += 1
            else:
                print("one pair")
    except:
        break

Measured memory_bytes: 6740
/* ex9_1
   reo012 */

#include <stdio.h>
#include <stdlib.h>
//スタックに格納するデータの最大数
#define SIZE 11

//スタックの定義
typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;

//スタックの初期化
void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);  //初め、dataの先頭アドレスがtop
}

//データの追加
void push(stack *stk, char elem){
    if(stk->count >= stk->size){    //スタックのsize分しかデータを入れない決まり
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else{
        stk->top--; //元のスタックの前に追加していくので、アドレスは減ってく
        *(stk->top) = elem; //元のスタックの前に新たなデータ追加
        stk->count++;   //カウントは増える
    }
}

//データの削除
void pop(stack *stk){
    if(stk->count <= 0){    //スタックがからのときは削除できない
        fprintf(stdout, "Error: stack underflow.\n");
        exit(1);
    }
    else{
        stk->top++; //スタックの先頭を削除するのでアドレスは増える
        stk->count--;   //カウントは減る
        return;
    }
}

int main(void){
    stack stk;
    char input_s[11], *ptr;
    scanf("%s", input_s);

    //スタックを初期化（ポインタ渡しで関数にわたすこと）
    initialize_stack(&stk);

    //スタックへのデータの追加・削除
    ptr = input_s;
    while(*(ptr)!='\0'){
        if(*(ptr)=='0' || *(ptr)=='1'){ //0か1が入力されたとき
            push(&stk, *(ptr)); //スタックに0、1を追加
        }else if(stk.count > 0){    //Bが入力され、かつスタックが空でないとき
            pop(&stk);  //スタックの一番上（最後に入力されたもの）を削除
        }
        ptr++;
    }

    //スタックを下から順に表示
    for (int i=0; i<stk.count; i++){
        printf("%c", stk.data[SIZE-i-1]);   //最後尾から出力していく
    }
    printf("\n");
    return 0;
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()

using ll = std::int64_t;
using vint = std::vector<int>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

void Main() {
    string s;
    cin >> s;
    
    int ans1 = 0;
    rep(i, s.length()) {
        if (i % 2 == 0) {
            if (s[i] == '1')++ans1;
        }
        else{
            if (s[i] == '0')++ans1;
        }
    }
    int ans2 = 0;
    rep(i, s.length()) {
        if (i % 2 == 1) {
            if (s[i] == '1')++ans2;
        }
        else {
            if (s[i] == '0')++ans2;
        }
    }

    cout << min(ans1, ans2) << endl;
}

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


Measured memory_bytes: 512
import sys

n=int(sys.stdin.readline())
dic={}
#辞書作成
for i in range(n):
    a=int(sys.stdin.readline())
    dic[i+1]={}
    for _ in range(a):
        b=list(map(int,sys.stdin.readline().split()))
        dic[i+1][b[0]]=b[1]

#最大人数求める。
max=0
for i in range(2**n):
    out=[0]*n
    a=2**(n-1)
    num=0
    #2進数に変換
    for j in range(n):
        if i>=a:
            out[j]=1
            i-=a
            num+=1
        a=a//2
    #判定
    if num>max:
        ju=1
        for j in range(n):
            if out[j]==1:
                for k in dic[j+1].keys():
                    if dic[j+1][k]==out[k-1]:
                        continue
                    else:
                        ju=0
                        break
                if ju==0:
                    break
        if ju==1:
            max=num
print(max)
    
        
        


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

typedef long long ll;

ll solve(ll total[], ll patty[], ll n, ll x) {
    ll half = (total[n] >> 1);
    if (n == 0) {
        if (x <= 0)
            return 0;
        return 1;
    }
    if (x <= half)
        return solve(total, patty, n - 1, x - 1);
    if (x == half + 1)
        return 1 + solve(total, patty, n - 1, x - 2);
    return patty[n - 1] + 1 + solve(total, patty, n - 1, x - half - 1);
}

int main() {
    ll n, x;
    cin >> n >> x;
    ll total[n + 1], patty[n + 1];
    total[0] = 1;
    patty[0] = 1;
    for (int i = 1; i <= n; i++) {
        total[i] = (total[i - 1] << 1) + 3;
        patty[i] = (patty[i - 1] << 1) + 1;
    }
    cout << solve(total, patty, n, x) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int h = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();

		System.out.print((double) w * h / 2);
		if (!(w == x * 2 && h == y * 2)) {
			System.out.print(" 0");
		} else {
			System.out.print(" 1");
		}
	}
}

Measured memory_bytes: 21844
local h, w, k = io.read("*n", "*n", "*n")
local f = false
for i_h = 0, h do
  for i_w = 0, w do
    if(k == w * i_h + h * i_w - 2 * i_h * i_w) then
      f = true
      break
    end
  end
  if f then break end
end
print(f and "Yes" or "No")


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iterator>
#include <cmath>
#include <numeric>

long int Euclid(long int A, long int B){
  if(A<B) return Euclid(B, A);
  while(B!=0){
    long int R = A%B;
    A = B; B = R;
  }
  return A;
}

int main(){
  long int N;
  std::cin>>N;
  std::vector<int> A(N);
  std::copy_n(std::istream_iterator<int>(std::cin),N,A.begin());
  std::vector<long int> gcd_front(N+1);
  std::vector<long int>  gcd_back(N+1);
  gcd_front[1]=A[0];
  gcd_back[1] =A[N-1];
  long int gcd_f = A[0]; long int gcd_b = A[N-1];
  for(int i = 1 ; i < N ; i++ ){
    gcd_front[i+1]=Euclid(gcd_f, A[i]);
    gcd_back[i+1] =Euclid(gcd_b, A[N-i-1]);
    gcd_f = gcd_front[i+1];
    gcd_b = gcd_back[i+1];
  }
  /*
  for(auto && r : gcd_front){
    std::cout<<r<<" ";
  }
  std::cout<<std::endl;
  for(auto && r : gcd_back){
    std::cout<<r<<" ";
  }
  std::cout<<std::endl;
  */
  long int gcd = gcd_back[N-1];
  //  long int max_gcd = gcd_back[N-1];
  for(int i = 2 ; i < N ; i++ ){
    gcd = std::max(gcd, Euclid(gcd_front[i-1],gcd_back[N-i]));
  }
  gcd = std::max(gcd, gcd_front[N-1]);
  //  gcd = gcd_front[N-1];
  // if(max_gcd<=gcd) max_gcd = gcd;
  std::cout<<gcd<<std::endl;
  return 0;
}


Measured memory_bytes: 2176
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Data.List

main :: IO ()
main = do
    [n, m] <- readInts
    xs <- replicateM n readInts
    ys <- replicateM m readInts
    forM_ [0..(n - 1)] $ \i -> do
        ts <- forM [0..(m - 1)] $ \j -> return $ man (xs !! i) (ys !! j)
        print $ minIndex ts + 1
    where
        readInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine :: IO [Int]
        man [x1,y1] [x2,y2] = abs (x1 - x2) + abs (y1 - y2)
        minIndex ss = fromJust $ elemIndex (minimum ss) ss


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    IOS;
    int n ,a ,b;
    cin >>  n >> a >>b;
    string s;
    cin >> s;
    int count = 0;
    int bcount = 0;
    for(int i=0; i<n; i++){
        if(s[i]=='c'){
            cout << "No" <<endl;
        }else if(count < a+b && s[i]=='a'){
            cout << "Yes" <<endl;
            count++;
        }else if(count < a+b && s[i]=='b' && bcount<b){
            cout << "Yes" <<endl;
            count++;
            bcount++;
        }else{
            cout << "No" <<endl;
        }
    }
}

Measured memory_bytes: 3728
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
   int n;cin>>n;
   string s;cin>>s;
   int res = 0;
   rep(i,10)rep(j,10)rep(k,10){
       int pos = 0;
       vector<int> t(3);
       t = {i,j,k};
       rep(l,n){
           if(s[l]-'0'==t[pos]){
               ++pos;
               if(pos==3){
                   ++res;
                   break;
               }
           }
       }
   }
   cout<<res<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >> n;
    ll s[n];
    ll sum = 0;
    rp(i,n) {
        cin >> s[i];
        sum +=s[i];
    }
    if(sum %10 != 0) {cout << sum <<endl; return 0;}
    sort(s,s+n);
    ll art = -1;
    rp(i,n) if(s[i] % 10 != 0) {
        art = s[i];
        break;
    }
    if(art != -1) {cout << sum - art << endl; return 0;}
    cout << 0 <<endl;


    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n, k, c; cin >> n >> k >> c;
    string s; cin >> s;

    VI l, r;
    for (int i = 0; l.size() < k; ++i) {
        if (s[i] == 'x')continue;
        if (!l.empty() && i - c <= l.back())continue;
        l.push_back(i);
    }
    for (int i = n - 1; r.size() < k; --i) {
        if (s[i] == 'x')continue;
        if (!r.empty() && r.back() <= i + c)continue;
        r.push_back(i);
    }

    FOR(i, 0, k)if (l[i] == r[k - i - 1])cout << l[i] + 1 << "\n";
}

Measured memory_bytes: 3468
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char const *argv[]) {
  double a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  double water[2] = {100*a, 100*b}, sugar[2] = {c, d};
  vector<pair<double,int>> denvec;

  vector<double> wvec, svec;
  int mw0 = (int)(f/water[0])+1, mw1 = (int)(f/water[1])+1;
  for (size_t i = 0; i <= mw0; i++) {
    for (size_t j = 0; j <= mw1; j++) wvec.push_back(water[0]*i+water[1]*j);
  }
  int ms0 = (int)(f/sugar[0]), ms1 = (int)(f/sugar[1]);
  for (size_t i = 0; i <= ms0; i++) {
    for (size_t j = 0; j <= ms1; j++) svec.push_back(sugar[0]*i+sugar[1]*j);
  }
  sort(wvec.begin(), wvec.end());
  sort(svec.begin(), svec.end());
  wvec.erase(unique(wvec.begin(), wvec.end()), wvec.end());
  svec.erase(unique(svec.begin(), svec.end()), svec.end());
  wvec.erase(upper_bound(wvec.begin(), wvec.end(),f), wvec.end());
  svec.erase(upper_bound(svec.begin(), svec.end(),f), svec.end());
  wvec.erase(wvec.begin());


  double answ = wvec[0], anss=svec[0];

  for (size_t i = 0; i < wvec.size(); i++) {
    for (size_t j = 0; j < svec.size(); j++) {
      if (wvec[i]+svec[j] <= f and (svec[j])*100 <= e*wvec[i]) {
        if (svec[j]*(anss+answ) > anss*(wvec[i]+svec[j])) {
          answ = wvec[i];
          anss = svec[j];
        }
      }
    }
  }

  cout << answ + anss << ' ' << anss << endl;
  return 0;
}


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

long long N, P;

int main() {
    cin >> N;
    int a;
    for (int i = 0; i < N; i++) {
        cin >> a;
        if (a % 2) {
            cout << "first" << endl;
            return 0;
        }
    }
    cout << "second" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
  int n;
  cin>>n;
  vector<long long int> a(n);
  for(long long int i=0; i<n; i++){
    cin>>a.at(i);
  }
  bool flag=true;
  int ans=0;
  while(flag){
    flag=false;
    for(int j=n-1; j>=1; j--){
      if(a.at(j)<a.at(j-1)){
        int v=a.at(j);
        a.at(j)=a.at(j-1);
        a.at(j-1)=v;
        flag=true;
        ans++;
      }
    }
  }
  for (int i = 0; i < n; i++)
  {
    cout<<a.at(i);
    if(i!=n-1){
      cout<<" ";
    }else{
      cout<<endl;
    }
  }
  cout<<ans<<endl;
  return 0;
  
}


Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int main(void){
  int N, Y;
  cin >> N >> Y;
  int x = -1, y = -1, z = -1;

  for(int i = 0; i <= N; ++i){
    for(int j = 0; j <= N - i; ++j){
      int k = N -(i + j);
      if(10000*i + 5000*j + 1000*k == Y){
	x = i;
	y = j;
	z = k;
	cout << x << " " <<  y << " " << z << endl;
	return 0;
      }
    }
  }
  cout << x << " " <<  y << " " << z << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n,t;cin>>n>>t;
    vin a(n),b(n);
    rep(i,n)cin>>a[i]>>b[i];
    vvin dpa(n+1,vin(t+1)),dpb(n+1,vin(t+1));//dpaは最後の料理を時間をはみ出して食べるときのmax dpbは時間j以内に食べ終わるという条件下でのmax
    rep(i,n)rep2(j,1,t+1){
        dpb[i+1][j]=dpb[i][j];
        if(j>=a[i])dpb[i+1][j]=max(dpb[i+1][j],dpb[i][j-a[i]]+b[i]);
        dpa[i+1][j]=max(dpa[i][j],dpb[i+1][j]);
        //i+1番目の料理を最初と最後どっちにするかで場合分け
        if(j>=a[i])dpa[i+1][j]=max(dpa[i+1][j],dpa[i][j-a[i]]+b[i]);
        dpa[i+1][j]=max(dpa[i+1][j],dpb[i][j-1]+b[i]);
    }
    cout<<dpa[n][t]<<endl;
}

Measured memory_bytes: 73684
#include <iostream>
#include <vector>
using namespace std;
const int ma = 301;
double dp[ma][ma][ma];
main()
{
    int n;scanf( "%d", &n );
    vector< int > a(3);
    for( int i = 0; i < n; i++)
    {
        int x;
        scanf( "%d", &x );
        a[x - 1]++;
    }
    double p = 1.0 / n;
    for( int k = 0; k <= n; k++ )
    {
        for( int j = 0; j <= n; j++ )
        {
            for( int i = 0; i <= n; i++ )
            {
                int z = n - i - j - k;
                if( z < 0 ) break;
                if( z == n ) continue;
                double x = 1 - z * p;
                if( i ) dp[i][j][k] += dp[i - 1][j][k] * i * p;
                if( j ) dp[i][j][k] += dp[i + 1][j - 1][k] * j * p;
                if( k ) dp[i][j][k] += dp[i][j + 1][k - 1] * k * p;
                dp[i][j][k] += 1;
                dp[i][j][k] /= x;

            }
        }
    }
    printf( "%.10f\n", dp[a[0]][a[1]][a[2]] );
    return 0;
}

Measured memory_bytes: 213248
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    int ans=0,tmp=0;
    for(int i=0;i<n-1;i++){
        if(a[i]>=a[i+1])tmp++;
        else tmp=0;
        ans=max(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4016
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <functional>
#include <string>

int main() {
  std::string s[3];
  for (int i = 0; i < 3; ++i) {
    std::cin >> s[i];
  }

  for (int i = 0; i < 3; ++i) {
    std::cout << s[i][i];
  }
  std::cout << std::endl;

  return 0;
}

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

class Cmondai
{
    static void Main()
    {
        var N = Int32.Parse(Console.ReadLine());
        var ans = 0L;
        var count = new long[5];
        for (int i=0;i<N;++i)
        {
            var S=Console.ReadLine();
            switch (S[0])
            {
                case 'M':count[0]++;break;
                case 'A': count[1]++; break;
                case 'R': count[2]++; break;
                case 'C': count[3]++; break;
                case 'H': count[4]++; break;
                default:break;
            }
        }
        for (int i=0;i<5;++i) for (int j=i+1;j<5;++j) for (int k=j+1;k<5;++k) ans += count[i] * count[j] * count[k];
        Console.WriteLine(ans);
    }
}

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

int main(int argc, char const *argv[]) {
  int n,m,x,y;
  cin>>n>>m>>x>>y;
  int X[n+1],Y[m+1];
  X[0]=x,Y[0]=y;
  for(int i=1;i<n+1;i++){
    cin>>X[i];
  }
  for(int i=1;i<m+1;i++){
    cin>>Y[i];
  }
  sort(X,X+n+1);
  sort(Y,Y+m+1);
  if(X[n]<Y[0]){
    cout<<"No War"<<endl;
  }else{
    cout<<"War"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll n,y;
  cin >>n>>y;
  for(ll i=0;i<=n;i++){
    for(ll j=0;j<=n-i;j++){
      if(i*10000+j*5000+(n-i-j)*1000==y){
        cout <<i<<" "<<j<<" "<<n-i-j<<endl;
        return 0;
      }
    }
  }
  cout <<-1<<" "<<-1<<" "<<-1<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <cstring>
#include <string>
#include <cctype>
#include <cassert>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)
#define INF (1001001001)
#define EPS (1e-15)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define pra(x) do{rep(__i,(x).size()) pri(x,__i);}while(0)
#define pran(x,n) do{rep(__i,n) pri(x,__i);}while(0)
#define pral(x) do{cerr << (#x) << " =";rep(__i,(x).size()) cerr<<" "<<(x[__i]);cerr<<endl;}while(0)
#define prar(x,b,e) do{repr(__i,b,e) pri(x,__i);}while(0)

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool CHMAX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool CHMIN(T &l,const T &r){return l>r?l=r,1:0;}

ll MOD = 1000000007;

int in() {
	int a;
	scanf("%d ", &a);
	return a;
}

int tsf(int a, int b) {
	if (a == b) return 0;
	if (b >= (a + 1) / 2) return INF;
	for (int i = b + 1; ; i++) {
		if (a % i == b || a % i > b * 2) return i;
	}
	return a - b;
}

int main() {
	function<void(int,int)> tensi_no_3p=[&](int v,int d){
	};
	int N;
	cin >> N;
	vint A(N), B(N);
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> B[i];
	
	vector<set<int> > froms(N);
	rep(i, N) froms[i].insert(A[i]);
	vector<int> ok(N, 0);
	int oks = 0;
	ll ans = 0;
	rep(i, N) {
		if (tsf(A[i], B[i]) == INF) {
			cout << -1 << endl;
			return 0;
		}
	}
	for (;;) {
		int today = 0;
		rep(i, N) if (! ok[i]) {
			int kouho = INF;
			for (auto &&x : froms[i]) kouho = min(kouho, tsf(x, B[i]));
			if (kouho == 0) {
				ok[i] = 1;
				oks++;
			}
			today = max(today, kouho);
		}
		if (today == 0) break;
		ans += 1ll << today;
		rep(i, N) if (! ok[i]) {
			for (auto &&x : froms[i]) {
				int to = x % today;
				if (to == B[i] || (to > B[i] * 2 && froms[i].find(to) == froms[i].end())) froms[i].insert(to);
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

int main(){
    ll n;
    cin >> n;
    ll x[n] = {};
    rep(i,0,n) cin >> x[i];

    ll ans = LINF;
    rep(i,1,101){
        ll temp = 0;
        rep(j,0,n){
            temp += pow(x[j]-i,2);
        }
        ans = min(ans,temp);
    }
    cout << ans << endl;
    return 0;
}


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

int main() {

  int n;
  while( cin >> n, n ) {
    int ba;
    priority_queue<int, vector<int>, greater<int> > p[2];
    int card[201] = {0};

    for(int i=0; i<n; i++) {
      int a;
      cin >> a;
      p[0].push(a);
      card[a] = 1;
    }

    for(int i=1; i<=2*n; i++) {
      if( card[i] != 1 ) {
	p[1].push(i);
      }
    }

    int player = 1; // 0:taro / 1:hana
    int score[2] = {0}; //score[0]:taro_score / score[1]:hana_score
    ba = p[0].top(); p[0].pop();
    score[0]++;

    while( p[0].size() && p[1].size() ) { 
      vector<int> temp;
      while(1) {
	if( p[player].size() == 0 ) {
	  ba = 0;
	  break;
	}
	int drow = p[player].top(); p[player].pop();
	if( drow > ba ) {
	  ba = drow;
	  score[player] ++;
	  break;
	}
	else {
	  temp.push_back(drow);
	}
      }

      for(int i=0; i<temp.size(); i++) {
	p[player].push(temp[i]);
      }
      if( player ) player = 0;
      else player = 1;
    }
   
    cout << p[1].size() << endl << p[0].size() << endl;
  }
}

Measured memory_bytes: 1216
#pragma GCC target("sse4.2") // popcnt
#include <iostream>

using namespace std;
typedef long long ll;

constexpr ll MOD = 1000000007;

int n;
bool t[25][25];

ll dp[25][2100000];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			int x;
			cin >> x;
			t[i][j] = (x != 0);
		}
	}
	for (int i = 0; i <= n; ++i) {
		dp[i][0] = 1;
	}
	for (int k = 1; k <= n; ++k) {
		for (int s = 0; s < (1<<n); ++s) {
			if (__builtin_popcount(s) > k) continue;

			dp[k][s] = dp[k-1][s];
			for (int i = 0; i < n; ++i) {
				if ((s&(1<<i)) == 0) continue;
				if (!t[i][k-1]) continue;

				dp[k][s] += dp[k-1][s^(1<<i)];
				dp[k][s] %= MOD;
			}
		}
	}
	cout << dp[n][(1<<n)-1] << "\n";
	return 0;
}

/*
	bipartite graph with 2n vertices, n on each side
	count perfect matchings

	brute: try all permutations

	count matchings for all subsets?

	dp[S][k] = matchings from subset S of A to elements 1..k of B
	if S is empty, exactly 1 way
	if k = 0 and S is non-empty, 0 ways
	if |S| > k, 0 ways

	dp[S][k] = dp[S][k-1] + (for all x in S with edge x-k) DP[S^x][k-1]

*/


Measured memory_bytes: 336128
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, A[3]; cin >> a >> b;
    A[0] = a + b;
    A[1] = a - b;
    A[2] = a * b;
    sort(A, A+3);
    cout << A[2];
    cout << endl;
    return 0;
}





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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) if((x)>(y))(x)=(y)
#define chmax(x,y) if((x)<(y))(x)=(y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
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);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, dp[80080][11];
string s;

signed main() {
	while (1) {
		cin >> s;
		if (s=="0") break;
		int n = s.size();
		memset(dp,0,sizeof(dp));
		rep(i,n) {
			int m = s[i]-'0';
			if (i!=0) rep(j,11) dp[i][(j*10+m)%11] += dp[i-1][j];
			if (m!=0) dp[i][m]++;
		}
		int res = 0;
		rep(i,n) res += dp[i][0];
		cout << res << ln;
	}
}


Measured memory_bytes: 6728
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
	    	Scanner sc = new Scanner(System.in);
	    	int a = sc.nextInt();
	    	int b = sc.nextInt();
	    	if (a < 1 || a > 9) {
	    		System.out.println(-1);
	    		return;
	    	}
	    	if (b < 1 || b > 9) {
	    		System.out.println(-1);
	    		return;
	    	}
	    	System.out.println(a * b);
	}
}


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

int main(void){
        int N;
        string s, t;
        cin >> N >> s >> t;
        int ans = 2*N;
        rep(i,N) {
                if (s.substr(i,N-i) == t.substr(0,N-i) ){ ans = N+i; break;}
        }
        cout << ans << endl;

        return 0;
}

Measured memory_bytes: 3616
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long inf = 1ll << 61;
int a[3005];
vector<int>G[3005];
int in[3005];
int res[3005];
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n - 1) {
		int x, y; cin >> x >> y;
		x--; y--;
		if (a[x] < a[y]) {
			G[x].push_back(y);
			in[y]++;
		}
		if (a[x] > a[y]) {
			G[y].push_back(x);
			in[x]++;
		}
	}
	queue<int>S;
	rep(i, n) {
		if (!in[i])S.push(i);
	}
	while (S.size()) {
		int x = S.front(); S.pop();
		if (!res[x])res[x] = -1;
		for (int e : G[x]) {
			if(res[x]==-1)res[e] = 1;
			in[e]--;
			if (!in[e])S.push(e);
		}
	}
	rep(i, n) {
		if (res[i] == 1)cout << i+1 << ' ';
	}cout << endl;
}

Measured memory_bytes: 512
#include <stdio.h>

                                                                                                
  
int main(void){
                                                                                                
   
    long long n, i, t;

    long long p[100010];

    long long k = 0;
   
      
    scanf("%lld", &n );
     
   

    for( i = 1 ; i <= n ; i = i + 1 ){

         scanf("%lld", &p[i] );      

         }


    for( i = 1 ; i <= n ; i = i + 1 ){

         if( p[i] == i ){

             t = p[i];

             p[i] = p[i + 1];

             p[i + 1] = t;

             k += 1;

             }

         }


    printf("%lld\n", k );


    return 0;
                                                          
}

Measured memory_bytes: 896
package main
 
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)
 
var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  var line, buffer []byte
  var isPrefix bool = true
  var err error
  for isPrefix {
    line, isPrefix, err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n, _ = strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func Max(A *[]int) int {
  ans := (*A)[0]
  for _, a := range (*A) {
    if ans < a { ans  = a }
  }
  return ans
}

func main() {
  KT := NextIntVec()
  K := KT[0]
  A := NextIntVec()
  M := Max(&A)
  L := 2 * M - K - 1
  if L < 0 { L = 0 }
  Write(L)
  Output()
}

Measured memory_bytes: 640
#include <stdio.h>
int main(void)
{
	char s[4];
	
	scanf("%s", s);
	
	if((s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) ||
	   (s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) ||
	   (s[0] == s[3] && s[1] == s[2] && s[0] != s[1])){
	   	printf("Yes");
	}else{
		printf("No");
	}
	
	return 0;
}

Measured memory_bytes: 128