akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

int dp[10010][10][110][2];

int mod = 1e9 + 7;

void clear() {
    for (int a = 0; a < 10010; a++) {
        for (int b = 0; b < 10; b++) {
            for (int c = 0; c < 110; c++) {
                for (int z = 0; z < 2; z++) {
                    dp[a][b][c][z] = 0;
                }
            }
        }
    }
}

inline int md(int a, const int &mod) {
    while (a >= mod) {
        a -= mod;
    }
    return a;
}

ll solve(string &k, int m) {
    clear();
    for (int i = 1; i < 10; i++) {
        if (k[0] - '0' > i) {
            dp[0][i][i % m][0] = 1;
        } else if (k[0] - '0' == i) {
            dp[0][i][i % m][1] = 1;
        }
    }
    for (int i = 1; i < k.size(); i++) {
        for (int d = 0; d < 10; d++) {
            for (int ld = 0; ld < 10; ld++) {
                for (int ost = 0; ost < m; ost++) {
                    if (k[i] - '0' > d) {
                        dp[i][d][md(ost + d, m)][0] = md(dp[i][d][md(ost + d, m)][0] + md(dp[i - 1][ld][ost][0] + dp[i - 1][ld][ost][1], mod), mod);
                    } else if (k[i] - '0' == d) {
                        dp[i][d][md(ost + d, m)][0] = md(dp[i][d][md(ost + d, m)][0] + dp[i - 1][ld][ost][0], mod);
                        dp[i][d][md(ost + d, m)][1] = md(dp[i][d][md(ost + d, m)][1] + dp[i - 1][ld][ost][1], mod);
                    } else {
                        dp[i][d][md(ost + d, m)][0] = md(dp[i][d][md(ost + d, m)][0] + dp[i - 1][ld][ost][0], mod);
                    }
                }
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < 10; i++) {
        ans = (ans + dp[k.size() - 1][i][0][0] + dp[k.size() - 1][i][0][1]) % mod;
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cout.tie(0); cin.tie(0);
    cout.precision(20); cout << fixed;
    string k;
    int d;
    cin >> k >> d;
    ll ans = solve(k, d);
    if (k.size() != 1) {
        string s = "";
        for (int i = 1; i < k.size(); i++) {
            s += '9';
        }
        solve(s, d);
        for (int t = 0; t < k.size() - 1; t++) {
            for (int i = 0; i < 10; i++) {
                ans = (ans + dp[t][i][0][0] + dp[t][i][0][1]) % mod;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 86400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
ll getPow(ll a,ll p){
  ll ret = 1,cp = a;
  while(p){
    if(p&1) ret = (ret*cp)%MOD;
    p >>= 1;
    cp = (cp*cp)%MOD;
  }
  return (ret+MOD)%MOD;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  ll ans = 1, n = s.size(), nb = 0;
  for(ll i = 0; i < n; ++i){
    if(s[i] == '1') ++nb,ans = (3*ans)%MOD;
    else ans = (3*ans-getPow(2,nb+1))%MOD;
  }
  cout << (ans+MOD)%MOD;
  return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */

int n, a;
void in(){
    cin >> n >> a;
}

void solve(){
    if(a >= n % 500){
        print("Yes");
    }else{
        print("No");
    }
}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
int n;
long long x,sum2,sum,ans;
int main()
{
	scanf("%d",&n); ans=1e18;
	for (int i=1;i<=n;i++)
	{
		scanf("%lld",&x);
		 sum+=x; sum2+=x*x;
	}
	for (long long k=sum/n-10;k<=sum/n+10;k++) ans=min(ans,1ll*n*k*k-2ll*sum*k+sum2);
	printf("%lld\n",ans);
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
int n, m;
double a;
multiset <double> tb;
int main(){
    cin >> n >> m;
    for(int i = 1 ; i <= n ;i++){
        cin >> a;
        tb.insert(a);
    }
    for(int i = 1 ; i <= m ;i++){
        auto it = tb.end();
        it--;
        int t = *(it);
        tb.erase(it);
        tb.insert((double)t/2);
    }
    long long s = 0;
    for(int i : tb)s += i;
    cout << s;
    return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>

int main(){
	int n;
	long long d;
	scanf("%d%lld", &n, &d);
	int x, y, cnt = 0;
	for(int i = 0; i < n; i++){
		scanf("%d%d", &x, &y);
		if(x * 1ll * x + y * 1ll * y <= d * d){
			cnt++;
		}
	}
	printf("%d", cnt);
	return 0;
	
}

Measured memory_bytes: 1732
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<map>

#define f first
#define s second

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

#define MAX 1000000
int s[MAX];

int main(){
  int n;
  int cnt = 1;
  vector<bool> isP(MAX,true);
  for(int i=2; i<MAX; i++){
    if(isP[i]){
      s[cnt] = s[cnt-1] + i; cnt++;
      for(int j=i+i; j<MAX; j+=i)
	isP[j] = false;
    }
  }
  while(cin>>n, n)
    cout << s[n] << endl;

  return 0;
}

Measured memory_bytes: 0
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        long h = sc.nextInt();
        long w = sc.nextInt();
        if(h % 3 == 0 || w % 3 == 0){
            System.out.println(0);
            return;
        }else{
            long ans = Math.min(h,w);
            for(long i = 1; i <= h/2; i++){
                long c1 = w*i;
                long max = Math.max((long)Math.ceil(w/2d)*(h-i),c1);
                long min = Math.min((long)Math.floor(w/2d)*(h-i),c1);
                ans = Math.min(ans,max-min);
            }
            for(int i = 1; i <= w/2; i++){
                long c1 = h*i;
                long max = Math.max((long)Math.ceil(h/2d)*(w-i),c1);
                long min = Math.min((long)Math.floor(h/2d)*(w-i),c1);
                ans = Math.min(ans,max-min);
            }
            System.out.println(ans);
        }
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define M 1000000007
#define pie 3.141592653589793238
using namespace std;



signed main(){  
    int n; cin >> n;
    int a[n];
    int s = 0;
    map<int,int> m;
    for(int i=0; i<n; i++){
        cin >> a[i];
        s += a[i];
        m[a[i]]++;
    }
    int q; cin >> q;
    while(q--){
        int c,d; cin >> c >> d;
        s -= (m[c]*c);
        s += (m[c]*d);
        m[d] += m[c];
        m[c] = 0;
        cout << s << "\n";
    }
    return 0;
}

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

int main()
{
    int n;
    cin>>n;
    int cnt[10001]={0};
    for(int i=1;i<=100;i++)
    {
        for(int j=1;j<=100;j++)
        {
            for(int k=1;k<=100;k++)
            {
                int res= i*i + j*j + k*k + i*j + j*k + k*i;
                if(res<10001)
                    cnt[res]++;
            }
        }
    }
    for(int i=1;i<=n;i++)
        cout<<cnt[i]<<endl;
    return 0;
}


Measured memory_bytes: 3668
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    h, w = list(map(int, readline().split()))
    if h % 3 == 0 or w % 3 == 0:
        print(0)
    else:
        mt = 10 ** 20
        for i in range(h):
            y = i * w
            x = (h - i) * (w // 2)
            z = h * w - x - y
            mt = min(mt, abs(max(x, y, z) - min(x, y, z)))

            x = (h - i) // 2 * w
            z = h * w - x - y
            mt = min(mt, abs(max(x, y, z) - min(x, y, z)))

        for i in range(w):
            y = i * h
            x = (w - i) * (h // 2)
            z = h * w - x - y
            mt = min(mt, abs(max(x, y, z) - min(x, y, z)))

            x = (w - i) // 2 * h
            z = h * w - x - y
            mt = min(mt, abs(max(x, y, z) - min(x, y, z)))

        print(mt)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 41328
import math

s=input()
k=int(input())

ss=[]
cont0=0
cont1=0
for i in range(len(s)):
    if s[i]!="1":
        ss.append(int(s[i]))
    else:
        if len(ss)==0:
            cont0=cont0+1
        else:
            cont1=cont1+1
        
k=k-cont0
    
n=5000*10000**3

if len(ss)==0:
    print(1)
elif k<=0:
    print(1)
else:
    logk=math.log10(k)

    logketa=n*math.log10(ss[0])
    if logketa>logk:
        print(ss[0])
    else:
        print(ss[1])
    

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

int main() {
  int N;
  cin >> N;
  int r = 7 % N;
  for (int i = 0; i < N; i++) {
    if (r == 0) {
      cout << i + 1 << endl;
      return 0;
    } else {
      r = (10*r + 7) % N;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 3596
// B.

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	string s;
	cin >> s;
	int ans = 0, cnt = 0;
	for (char c : s) {
		if (c == 'A' || c == 'C' || c == 'G' || c == 'T') {
			++cnt;
			ans = max(ans, cnt);
		} else {
			cnt = 0;
		}
	}
	cout << ans << 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 A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int max = Math.max(A, Math.max(B, C));
        int K = sc.nextInt();
        int ans = A + B + C - max;
        for(int i = 0; i < K; i++) max *= 2;
        System.out.println(ans + max);
        sc.close();

    }

}


Measured memory_bytes: 21716
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<b?(a=b,1):0)
#define chmin(a,b) (a>b?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

double p[20][20];
double dp[1<<16][17];
int m,n;

double solve(int S, int now) {
  if (now == n) return 1;
  double &r = dp[S][now];
  if (r >= 0) return r;
  double res = 0;
  REP(i,m) {
    if (S>>i&1) continue;
    double tmp = 0;
    double q = 1;
    for (int j=now; j<=n; ++j) {
      double qq = q*(1-p[i][j]);
      tmp += qq * solve(S|1<<i,j);
      q *= p[i][j];
    }
    chmax(res, tmp);
  }
  return r = res;
}

int main() {
  cin >> m >> n;
  REP(i,m) {
    REP(j,n) {
      cin >> p[i][j];
    }
  }
  memset(dp,-1,sizeof(dp));
  double ans = solve(0,0);
  printf("%.12f\n", ans);
}

Measured memory_bytes: 9960
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int a[100];
int b[100];
int memo[100][100];

int solve(int pos, int num){
  int ret = INT_MAX;
  if(num == 1) return 0;
  if(memo[pos][num]) return memo[pos][num];
  REP(i,num-1){
    int t = pos + i;
    int cost = solve(pos,i+1) + solve(pos+i+1,num-i-1);
    cost += a[pos] * b[t] * a[t+1] * b[pos+num-1];
    ret = min(ret, cost);
  }
  return memo[pos][num] = ret;
}

int main(){
  int n;
  scanf("%d",&n);
  REP(i,n) scanf("%d%d",&a[i],&b[i]);
  printf("%d\n",solve(0,n));
  return 0;
}

Measured memory_bytes: 0
/*       _________
        /|______/ \
        ||  _|_|\  |
        || |_|   | /
        ||    _ / |
        ||  _| \\  \    
        ||_|_|\ || |
        |/_|/ | /|_/
              /__/      Written by: Rishabh Roshan
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int            	long long
#define tree         	ped
#define integer        	int32_t
#define mod         	1000000007
#define vint        	vector<integer>
#define pint        	pair<integer, integer>
#define umint        	unordered_map<integer, integer>
#define mint        	map<integer, integer>
#define in(x)        	int x; cin>>x
#define setbits(x)    	__builtin_popcountll(x)
#define zerobits(x)    	__builtin_ctzll(x)
#define w(x)        	int x; cin>>x; while(x--)
#define sp(x, y)    	fixed<<setprecision(y)<<x
#define poll(x)        	x.front(); x.pop()
#define f(x)        	for(int i=0; i<x; i++)
#define endl         	'\n'
#define inf         	1e9 
#define order_set     	tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

// #include "functions.h"

void om_shree_ganeshaya_namah(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

vint dp;
unordered_map<int, vint> dict;

int dfs(int x){
	if(dict.find(x)==dict.end())
		return 0;

	if(dp[x])
		return dp[x];

	int max=0;
	vint v = dict[x];
	for(auto i:v){
		int a = dfs(i);
		if(a>max)
			max = a;
	}
	dp[x] = max+1;
	return dp[x];
}

int32_t main(){
    
    om_shree_ganeshaya_namah();

    in(n);
    w(m){
    	in(x); in(y);
    	dict[x].push_back(y);
    }

    dp = vint(n+1);
    for(auto it:dict){
		int max=0;
		for(auto i:it.second){
			int a = dfs(i);
			if(a>max)
				max = a;
		}
		dp[it.first] = max+1;
    }
    int ans = *max_element(dp.begin(), dp.end());
    cout<<ans;

}

Measured memory_bytes: 17544
//B-TAKOYAKI FESTIVAL 2019
#include <stdio.h>

int main(void){
    int n, i, j;
    int d[100]={0};
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &d[i]);
    }
    int sum= 0;
    for(i=0; i<n; i++){
        for(j=i+1; j<n; j++){
            sum += d[i]*d[j];
        }
    }
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 128
n = map(int,input())
s = input().strip()

def Check(x):
	a = [chr(x//100%10+48),chr(x//10%10+48),chr(x%10+48)]
	p = 0
	for c in s:
		if a[p] == c:
			p += 1
			if p == 3:
				return True
	return False

ans = 0
for i in range(1000):
	if Check(i):
		ans += 1
print(ans)


Measured memory_bytes: 42140
#include <bits/stdc++.h>
using namespace std;
constexpr int MOD = 1e9 + 7;
int A[2000][2000][2];
void solve()
{
	memset(A, 0, sizeof(A));
	int h, w;
	cin >> h >> w;
	auto S = vector<string>(h);
	for(auto& x : S)
		cin >> x;
	
	for(auto i = 0; i < h; ++i)
	{
		for(auto j = 0; j < w; ++j)
		{
			if(S[i][j] == '.') {
				if(i == 0)
					A[i][j][0] = 1;
				else
					A[i][j][0] = A[i-1][j][0] + 1;
				if(j == 0)
					A[i][j][1] = 1;
				else
					A[i][j][1] = A[i][j-1][1] + 1;
			}
		}
	}

	auto ans = 0;
	for(auto i = h-1; i >= 0; --i)
	{
		for(auto j = w-1; j >= 0; --j)
		{
			if(S[i][j] == '.') {
				if(i < h-1 && S[i+1][j] == '.')
					A[i][j][0] = A[i+1][j][0];
				if(j < w-1 && S[i][j+1] == '.')
					A[i][j][1] = A[i][j+1][1];

				ans = max(ans, A[i][j][0] + A[i][j][1] - 1);
			}
		}
	}
	cout << ans << endl;
}

int main()
{
	cin.sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	solve();
}

Measured memory_bytes: 35840
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 19 20:52:57 2020

@author: over-
"""


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


ans=-1
for i in range(2000):
    r=i*0.08
    if int(r) == A:
        l=i*0.1
        if int(l)==B:
            ans=i
            break

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int a[100005];
int main()
{
	int n,t1=0,t2=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]%2==0&&a[i]%4!=0) t1++;
		if(a[i]%4==0) t2++;
	}
	if(t1/2+t2>=n/2) printf("Yes");
	else printf("No");
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define int ll
using pint = pair<int,int>;
using Graph = vector<vector<int>>;
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 1e10; //10^10
const double PI = acos(-1.0L);
const int dx[4] = {1, 0, -1, 0} , dy[4] = {0, 1, 0, -1};
/*mod逆元*/long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
template< typename T >T mod_pow(T x, T n, T p=MOD) {T ret = 1;while(n > 0) {if(n & 1) (ret *= x) %= p;(x *= x) %= p;n >>= 1;}return ret;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}

//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    VI p(n); REP(i,n) cin >> p[i];
    int minn = n+1;
    int ans = 0;
    REP(i,n) if(minn>p[i]){ans++; minn=p[i];}
    out(ans);

    return 0;
}

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

int main(){
  	int a,b;	cin >> a;	cin >> b;
  	string ans = "";
  	for(int i = 0; i < max(a,b); ++i){
    	ans += to_string(min(a,b));
    }
  	cout << ans << endl; 
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 14:33:00 2020

@author: liang
"""
from math import gcd

N, M = map(int, input().split())
A = [int(i) for i in input().split()]

flag = False
res = 1
for a in A:
    a //= 2
    res *= a//gcd(res,a)
    if res > M:
        flag = True
        break
    #print(res)
"""
存在チェック
２で割り切れる個数同じ？
"""

for a in A:
    if int(res/a) == res/a:
        flag = True
        
if flag:
    ans = 0
    print(ans)
else:
    #ans = (M - res(A)//2)//res + 1
    #ans = (M-1)//res//2 + 1
    ans= (M//res + 1)//2
    print(ans)

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

vector<long long> primeFactorize(long long x) {
    vector<long long> res;

    for (long long i = 2; i * i <= x; i++) {
        if (x % i != 0) continue;
        long long ex = 0;

        while(x % i == 0) {
            ex++;
            x /= i;
            res.push_back(pow(i, ex));
        }

    }

    if (x != 1) res.push_back(x);
    return res;
    
}

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

    vector<long long> f = primeFactorize(n);

    sort(f.begin(), f.end());
    long long cnt = 0;
    for (long long i = 0; i < f.size(); i++) {
        if (n % f[i] == 0) {
            cnt++;
            n /= f[i];
        }
        if (n < f[i]) break;
    }

    cout << cnt << endl;

}

Measured memory_bytes: 4068
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  if(k<n){
    cout << k*x + (n-k)*y  << endl;
  }else{
    cout << n*x << endl;
  }

}

Measured memory_bytes: 256
// compil: add warnings to check for overflow
// add function for max on vector *max_element(..)

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);

  int n;
  cin >> n;
  vector<double> pi(n);
  for (int i = 0; i < n; ++i) {
    cin >> pi[i];
  }

  vector<vector<double>> dp(n+1, vector<double>(n+1));
  // dp[i][j]: proba d'avoir j heads sur les i premiers lancers

  dp[0][0] = 1;

  for (int i = 1; i <= n; ++i) {
    dp[i][0] = (1-pi[i-1]) * dp[i-1][0];
    for (int heads = 1; heads <= n; ++heads) {
      dp[i][heads] = (1-pi[i-1]) * dp[i-1][heads] + pi[i-1] * dp[i-1][heads-1];
    }
  }

  double ans = 0;
  for (int heads = n/2+1; heads <= n; ++heads) {
    ans += dp[n][heads];
  }
  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 70792
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include <unordered_set>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e9;
typedef std::pair<int,int> P;
struct edge {ll to,cost;};
#define VMAX 200000+10
    ll d[VMAX];
    ll N,M,L[VMAX],R[VMAX],D[VMAX];
    ll ans=0;
    std::vector<edge> G[VMAX];
    bool dijkstra(int s){
        //頂点数N 辺の数 E
        std::priority_queue<P,vector<P>,std::greater<P>> que;
        if(d[s]==INF)d[s]=0;
        que.push(P(d[s],s));
        while(!que.empty()){

            P p =que.top();que.pop();
            int v=p.second;
            for(int i=0;i<(signed)G[v].size();i++){
                edge e =G[v][i];
                    if(d[e.to]==INF){
                        d[e.to]=d[v]+e.cost;
                        que.push(P(d[e.to],e.to));
                    }
                    else if(d[e.to]!=d[v]+e.cost)return false;

            }
        }
        return true;
    }

int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>N>>M;
    REP(i,M){
		cin>>L[i]>>R[i]>>D[i];
			G[L[i]].push_back({R[i],D[i]});
            G[R[i]].push_back({L[i],-D[i]});
	}
    bool f=true;
    std::fill(d,d+N+1,INF);
    EREP(i,N){
        if(!dijkstra(i))f=false;
    }
    cout<<(f?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 21744
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int k = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();

    int mod = b / k;

    if (a <= mod * k) {
      System.out.println("OK");
    } else {
      System.out.println("NG");
    }

  }
}


Measured memory_bytes: 35840
A,B = map(int,input().split())
lists = list(range(A,B+1))
str_lists = list(str(lists[0]))
kaibun_lists = []
for i in range(len(lists)):
        for j in range(len(list(str(lists[i])))):
                kaibun = str(lists[i])[::-1]
        if lists[i] == int(kaibun):
                kaibun_lists.append(int(kaibun))
print(len(kaibun_lists))

Measured memory_bytes: 6516
# include <iostream>
# include <vector>


using namespace std;


int main() {
    int s; cin >> s;
    vector<int> a; a.push_back(s);

    for (int n=1; n<1e9+1; ++n) {
        if (find(a.begin(), a.end()-1, a.back()) != a.end()-1) {
            cout << n << endl;
            break;
        }

        if (a.back() % 2 == 0) {
            a.push_back(a.back()/2);
        }
        else {
            a.push_back(3*a.back()+1);
        }
    };

    return 0;
}



Measured memory_bytes: 256
# coding: utf-8
N, M, X, Y = map(int, input().split())

lst_x = list(map(int, input().split()))
lst_x.append(X)
lst_y = list(map(int, input().split()))
lst_y.append(Y)

x = max(lst_x)
y = min(lst_y)

ans = "War"
if x < y:
        ans = "No War"
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n, a; cin >> n >> a;
	if (n % 500 <= a) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

#define ll long long

int main(){
    int A, B;
    cin >> A >> B;
    if(A >= 13)cout << B << endl;
    else if(A >= 6)cout << B / 2 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e5 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;

ll a[N] , pos[N]  , dp[N];
int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    ll n ;
    cin >> n ;
    pos[0] = N - 1 ;
    for (int i = 1 ; i <= n ; i ++) cin >> a[i] , pos[a[i]] = i ;
    ll mx = 0 ;
    for (int i = 1 ; i <= n ; i ++) {
    	dp[i] = 1 ;
    	if (pos[i - 1] < pos[i]) dp[i] = dp[i - 1] + 1 ;
    	mx = max(mx , dp[i]) ;
	}
	cout << n - mx ;
	
    return (0) ;
}

Measured memory_bytes: 4992
"""#################################################################
【ABC115】
B_Christmas_Eve_Eve
#################################################################"""

#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

N = II()
lst = []
for i in range(N):
    lst.append(II())
lst = sorted(lst)
print(int(lst[-1]/2)+sum(lst[:-1]))

Measured memory_bytes: 3064
import * as fs from 'fs';
const input = fs.readFileSync("/dev/stdin", "utf8").split(/\n/);

// C-こだわり者いろはちゃん

let price = +input[0].split(' ')[0];
const dislikeNumbers = input[1].split(' ');
let flag: boolean = true;




while (flag === true) {
    flag = false;
    let target = String(price).split('');
    for (let i = 0; i < dislikeNumbers.length; i++) {
        if (target.indexOf(dislikeNumbers[i]) !== -1) {
            flag = true;
        }
    }

    if (flag === true) {
        price += 1;
    }
}

console.log(price);


Measured memory_bytes: 13068
import java.util.Arrays;

public class Main {

  private static void solve() {
    int n = ni();
    int[][] a = ntable(3, n);

    for (int[] v : a) {
      Arrays.sort(v);
    }
    
    long count = 0;

    int p0 = 0;
    int p2 = 0;
    for (int p1 = 0; p1 < n; p1 ++) {
      while (p0 < n && a[0][p0] < a[1][p1]) {
        p0 ++;
      }

      while (p2 < n && a[2][p2] <= a[1][p1]) {
        p2 ++;
      }
      count += (long)p0 * (n - p2);
    }
    System.out.println(count);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = System.getProperty("debug");
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
const ll MOD = (int)(1e9+7);


ll solve(ll H, ll W) {

  
  ll res = H * W;
  for (int h = 1; h < H; h++) {
    {
      ll a = h * W;
      ll b = (H-h) * (W/2);
      ll c = (H-h) * ((W+1)/2);
      ll s = max(a, max(b, c)) - min(a, min(b, c));
      chmin(res, s);
    }
    {
      ll a = h * W;
      ll b = (H-h)/2 * W;
      ll c = (H-h+1)/2 * W;
      ll s = max(a, max(b, c)) - min(a, min(b, c));
      chmin(res, s);
    }
  }
  return res;
}

int main2() {
  ll H = nextInt();
  ll W = nextInt();
  ll ans1 = solve(H, W);
  ll ans2 = solve(W, H);
  cout << min(ans1, ans2) << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int r;
	cin>>r;
	if(n>=10){
		cout<<r<<endl;
		return 0;
	}
	else{
		r+=100*(10-n);
		cout<<r<<endl;
	}
	return 0;
}

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

namespace ConsoleApp69 {
    class Program {
        static void Main(string[] args) {
            string S = Console.ReadLine();

            char[] S_ = S.ToCharArray();

            Console.WriteLine(S_.Count() == S_.Distinct().Count() ? "yes" : "no");

        }
    }
}


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
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};

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

    int N, Q;
    string s;
    cin >> N >> Q >> s;
    vector<int> v(N, 0);
    FOR(i, 1, N){
        if(s[i] == 'C' && s[i-1] == 'A') v[i]++;
        v[i] += v[i-1];
    }

    rep(_, Q){
        int l, r;
        cin >> l >> r;
        l--; r--;
        cout << v[r] - v[l] << endl;
    }

    return 0;
}

Measured memory_bytes: 1488
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: isize,
        b: isize,
    }
    let ans = if a > 9 || b > 9 { -1 } else { a * b };
    println!("{}", ans);
}


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

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


Measured memory_bytes: 8108
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)

using namespace std;

const int N=311,mod=998244353;
int n,a[N],f[N][N*N],g[N][N*N],all,sum,res;

inline void upd(int &x,int y){x+=y; x-=x>=mod?mod:0;}

int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	all=1;
	rep (i,1,n) cin>>a[i],all=all*3ll%mod;
	f[0][0]=1;
	rep (i,1,n){
		rep (j,0,sum) if (f[i-1][j]){
			upd(f[i][j],f[i-1][j]*2ll%mod);
			upd(f[i][j+a[i]],f[i-1][j]);
		}
		sum+=a[i];
	}
	rep (i,(sum+1)>>1,sum) upd(res,f[n][i]);
	if (!(sum&1)){
		sum=0;
		g[0][0]=1;
		rep (i,1,n){
			rep (j,0,sum) if (g[i-1][j]){
				upd(g[i][j],g[i-1][j]);
				upd(g[i][j+a[i]],g[i-1][j]);
			}
			sum+=a[i];
		}
		upd(res,mod-g[n][sum/2]);
	}
	upd(all,(mod-res)*3ll%mod);
	cout<<all;
	return 0;
}

Measured memory_bytes: 227584
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();
	int area = a*b;
	int length = 2*(a+b);
	System.out.println(area + " " + length);
	}
}

Measured memory_bytes: 25932
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,flag=0;
	cin>>a>>b>>c;
	if(a==b&&a!=c)
		flag=1;
	else if(a==c&&a!=b)
		flag=1;
	else if(b==c&&a!=b)
		flag=1;
	if(flag==1) cout<<"Yes";
	else cout<<"No";
	return 0; 
} 

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    long int n,a[100000],s=0,i;
    scanf("%ld",&n);
    for(i=1;i<=n;i++)
        scanf("%ld",&a[i]);
    i=1;
    while(s<=n){
        s++;
        if(a[i]==2)
            break;
        i=a[i];
    }
    if(s>n)
        s=-1;
    printf("%ld\n",s);
    return 0;
}

Measured memory_bytes: 2516
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String s = sc.nextLine();
    	String t = sc.nextLine();
    	
    	int ans = 0;
    	for (int i = 0; i < s.length(); i++) {
    		if (s.charAt(i) == t.charAt(i)) {
    			ans++;
    		}
    	}
    	
    	System.out.println(ans);

	}

}


Measured memory_bytes: 22868
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

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

ll MOD = 1000000007;
const ll INF = (1ll << 60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

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

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

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(vector<int> arr) {
    int result = arr[0];
    for (auto a: arr) {
        result = gcd(a, result);
    }
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
ll euler_phi(ll n) {
    ll ret = n;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            ret -= ret / i;
            while (n % i == 0) n /= i;
        }
    }
    if (n > 1) ret -= ret / n;
    return ret;
}

class Combination {
    long long powmod(long long a, long long p) {
        long long ans = 1LL;
        long long mul = a;
        while (p > 0) {
            if ((p & 1) == 1) {
                ans = (ans * mul) % MOD;
            }
            mul = (mul * mul) % MOD;
            p >>= 1;
        }
        return ans;
    }

public:
    int N;
    long long mod;
    vector<long long> fact;
    vector<long long> revfact;

    Combination(int n, long long m) : N(n), mod(m), fact(n + 1), revfact(n + 1) {
        fact[0] = 1;
        for (int i = 1; i <= N; i++) {
            fact[i] = fact[i - 1] * i;
            fact[i] %= mod;
        }

        revfact[N] = powmod(fact[N], mod - 2);
        for (int i = N - 1; i >= 0; i--) {
            revfact[i] = revfact[i + 1] * (i + 1) % mod;
        }
    }

    long long getCombination(int a, int b) {
        if (a < 0 || b < 0) return 0;
        if (b > a)return 0;
        return fact[a] * revfact[b] % mod * revfact[a - b] % mod;
    }
};




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

    int num = min(a,b);
    int loop = max(a,b);

    for(int i=0; i<loop; i++){
        cout << num;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <math.h>

using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    string ans;
    if((b-c)*(c-a)>0){
        ans = "Yes";
    }else{
        ans = "No";
    }
    cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  int x = N % 10;
  int y = N % 1000;
  if ( (N - x)  % 1110 == 0) {
    cout << "Yes" << endl;
  }
  else if (y % 111 == 0) {
    cout << "Yes" <<endl;
  }
  else {
    cout << "No" <<endl;
 }
}

Measured memory_bytes: 3608
#include <cstdio>
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(void){
    char s[100001];
    int result[100000]={};
    int t[100000]={};
    int i = 1, j = 0;

    scanf("%s",s);
    while(1){
        if (s[i]=='\0') break;
        if (s[i]==s[i-1]) {
            ++t[j];
        }else{
            ++j;
        }
        ++i;
    }

    int sum = 0;
    for (int k = 0; k < j; ++k,++k) {
        int R = t[k]+1, L = t[k+1]+1;
        sum += R;

        // RRRR
        result[sum-1]+=R/2+R%2; // pos R
        result[sum]+=R/2;       // pos L

        // LLLL
        result[sum-1]+=L/2;     // pos R
        result[sum]+=L/2+L%2;   // pos L

        sum += L;
    }

    printf("%d",result[0]);
    for (int k = 1; k < i ; ++k) {
        printf(" %d",result[k]);
    }



    return 0;
}


Measured memory_bytes: 1532
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int N,K,R,S,P;
    string T;
    cin>>N>>K>>R>>S>>P>>T;
    int ans=0;
    for(int i=0;i<K;i++){
                int bef=0;
        for(int j=i;j<N;j+=K){
            //printf("[%d][%c]\n",j,T[j]);
            if(bef==0){
                if(T[j]=='r'){
                    ans+=P;
                    bef=3;
                }
                if(T[j]=='s'){
                    ans+=R;
                    bef=1;
                }
                if(T[j]=='p'){
                    ans+=S;
                    bef=2;
                }
            }
            else if(bef==1){
                if(T[j]=='r'){
                    ans+=P;
                    bef=3;
                }
                if(T[j]=='s'){
                    bef=0;
                }
                if(T[j]=='p'){
                    ans+=S;
                    bef=2;
                }

            }
            else if(bef==2){
                if(T[j]=='r'){
                    ans+=P;
                    bef=3;
                }
                if(T[j]=='s'){
                    ans+=R;
                    bef=1;
                }
                if(T[j]=='p'){
                    bef=0;
                }
            }
            else if(bef==3){
                if(T[j]=='r'){
                    bef=0;
                }
                if(T[j]=='s'){
                    ans+=R;
                    bef=1;
                }
                if(T[j]=='p'){
                    ans+=S;
                    bef=2;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512