akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

class Dice {
	int *d;
public:
	Dice(int *pd);
	void roll(char dir);
	int me(int n);
	void top(int topn);
	void front(int frn);
};
Dice::Dice(int *pd) {
	d = pd;
}

void Dice::roll(char dir) {
	int tmp;
	if(dir=='E') {
		tmp = d[0];
		d[0] = d[3];
		d[3] = d[5];
		d[5] = d[2];
		d[2] = tmp;
		}
	else if(dir=='W') {
		tmp = d[0];
		d[0] = d[2];
		d[2] = d[5];
		d[5] = d[3];
		d[3] = tmp;
	}
	else if(dir=='S') {
		tmp = d[0];
		d[0] = d[4];
		d[4] = d[5];
		d[5] = d[1];
		d[1] = tmp;
	}
	else {
		tmp = d[0];
		d[0] = d[1];
		d[1] = d[5];
		d[5] = d[4];
		d[4] = tmp;
	}
}
int Dice::me(int n) {
	return d[n-1];
}
void Dice::top (int topn) {
	if(topn == d[1])
		roll('N');
	else if(topn == d[2])
		roll('W');
	else if(topn == d[3])
		roll('E');
	else if(topn == d[4])
		roll('S');
	else if(topn == d[5]) {
		roll('S');
		roll('S');
	}	 
}
void Dice::front (int frn) {
	if(frn == d[2]) {
		roll('W');
		roll('S');
		roll('E');		
	}
	if(frn == d[3]) {
		roll('E');
		roll('S');
		roll('W');		
	}
	if(frn == d[4]) {
		roll('W');
		roll('S');
		roll('S');
		roll('E');		
	}
}

int main()
{
	int d[6];
	int qn, tn, fn;
	for (int i=0; i < 6; i++)
		cin >> d[i];
	cin >> qn;
	Dice dice(d);
	for (int i = 0; i < qn; i++) {
		cin >> tn >> fn;
		dice.top(tn);
		dice.front(fn);
		cout << dice.me(3) << endl;
	}	
	return 0;
}

Measured memory_bytes: 3048
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<cstring>
#define INF 0x3f3f3f3f
#define mod 1000000007
using namespace std;

int main()
{
	
	int a,b,t;
	scanf("%d%d",&a,&b);
	int d=0,ans=1;
	for(int i=0;i<a;i++ )
	{
		scanf("%d",&t);
		d+=t;
		if(d<=b)
		{
			ans++;
		}
	}
	 printf("%d\n",ans);
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res

def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a,b,c = LI()
    c -= a-b
    print(max(0,c))
    return

#B
def B():

    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    A()


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

int main() {
    string s;
    cin >> s;
    if(s[0] == s[1] && s[1] == s[2]) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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++)
 
int main() {
    int a,b,h;
    cin>>a>>b>>h;
    cout<<(a+b)*h/2<<endl;
}

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

#define MT make_tuple
#define all(x) begin(x), end(x)
#define putchar(x) cout << (x)
static int fastio = [](){ ios_base::sync_with_stdio(false); cin.tie(0); cout.precision(17); return 0; }();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<typename ...T> string format(const string& fmt, T&&... args) {
    size_t sz = snprintf(nullptr, 0, fmt.c_str(), args...) + 1;
    unique_ptr<char[]> buf(new char[sz]);
    snprintf(buf.get(), sz, fmt.c_str(), args...);
    return string(buf.get(), buf.get() + sz - 1);
}

template<class T> struct rge { T b, e; auto begin() const { return b; } auto end() const { return e; } };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
template<class T> auto dud(T* x) -> decltype(cerr << *x, 0);
template<class T> char dud(...);

struct debug {
#ifdef LOCAL
    debug(int line) {
        if(line) cerr << "LINE(" << line << ") -> ";
    }
    template<class T> typename enable_if<sizeof dud<T>(0) != 1, debug&>::type operator<<(T i) {
        cerr << boolalpha << i; return * this;
    }
    template<class T> typename enable_if<sizeof dud<T>(0) == 1, debug&>::type operator<<(T i) {
        return *this << range(begin(i), end(i));
    }
    template<class T, class U> debug& operator<<(pair<T, U> d) {
        return *this << "(" << d.first << ", " << d.second << ")";
    }
    debug& operator<<(tuple<>&) { return *this << "()"; };
    template<class ...T> debug& operator<<(tuple<T...> d) {
        *this << "("; debug_tuple<sizeof...(T), 0>(d);
        return *this << ")";
    }
    template<size_t L, size_t I, class T> void debug_tuple(const T& t) {
        *this << (I == 0 ? "" : ", ") << get<I>(t);
        if(I + 1 < L) debug_tuple<L, (I + 1) % L>(t);
    }
    template<class T> debug & operator <<(rge<T> d) {
        *this << "[";
        for(auto it = d.b; it != d.e; ++it)
            *this << (it != d.b ?  ", " : "") << *it;
        return *this << "]";
    }
    debug& operator<<(ostream&(*pf)(std::ostream&)) {
        cerr << pf; return *this;
    }
#else
    debug(int) {}
    template<class T> debug& operator<<(T&&) { return *this; }
    debug& operator<<(ostream&(*)(std::ostream&)) { return *this; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ << ": " << (__VA_ARGS__) << "] "

#define debug0()  debug(__LINE__)
#define debug1(x) debug(0)
#define GET_MACRO(_0, _1, NAME, ...) NAME
#define debug(...) GET_MACRO(_0, ##__VA_ARGS__, debug1, debug0)(__VA_ARGS__)
/*}}}*/
using LL = long long;

const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const LL LLINF = 0x3f3f3f3f3f3f3f3f;
const int MAX_N = 200005;

void solve(int) {
    LL A;
    double B;
    cin >> A >> B;
    LL B2 = LL((B + 0.001) * 100);
    debug() << imie(A) imie(B) << imie(B2) << endl;
    cout << A * B2 / 100 << endl;
}

int main() {
    int T = 1;
    //cin >> T;
    for(int i = 1; i <= T; ++i) {
        solve(i);
    }
    return 0;
}


Measured memory_bytes: 3748
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int n;


int main() {

	cin >> n;

	for (int i = 1; i < 10; i++)
	{
		if (n % i == 0)
		{
			if (n / i < 10)
			{
				cout << "Yes";
				return 0;
			}
		}
	}
	cout << "No";

	return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

ll a[100][100], dp[100][100];
signed main(void)
{
  int n;
  cin >> n;
  REP(i, n) REP(j, n) cin >> a[i][j];
  ll ret = -LLINF;
  REP(i, n) REP(j, n) FOR(k, i, n) FOR(l, j, n) {
    if(k == i && l == j) dp[k][l] = a[k][l];
    else if(k == i) dp[k][l] = dp[k][l-1] + a[k][l];
    else if(l == j) dp[k][l] = dp[k-1][l] + a[k][l];
    else dp[k][l] = dp[k-1][l] + dp[k][l-1] - dp[k-1][l-1] + a[k][l];
    ret = max(ret, dp[k][l]);
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const int N = 2e6+5;
int g[10][10];
void solve(){
    int h,w,k;
    cin>>h>>w>>k;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            char c;
            cin>>c;
            if(c=='.')g[i][j] = 0;
            else g[i][j] = 1;
        }
    }
    int ans = 0;
    for(int i=0;i<(1<<h);i++){
        for(int j=0;j<(1<<w);j++){
            int cnt = 0;
            for(int ii=0;ii<h;ii++){
                for(int jj=0;jj<w;jj++){
                    int it = 0;
                    if(i&(1<<ii)){
                        it = 1;
                    }
                    int jt = 0;
                    if(j&(1<<jj)){
                        jt = 1;
                    }
                    int trt = g[ii][jj];
                    if(it==1 or jt==1){
                        trt = 0;
                    }
                    cnt+=trt;
                }
            }
            if(cnt==k)ans++;

        }
    }
    cout<<ans<<endl;

}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
  //  cin>>t;
    while(t--){
        solve();
    }
    return 0;
}



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

int main() {
  int a,b;
  cin>>a>>b;
  int c=max(a,b);
  int d=max(c-1,a),e=max(c-1,b);
  int f=min(d,e);
  cout<<c+f<<endl;
  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
 
#define pb push_back
#define mp make_pair

typedef long long ll; 

#define fi first
#define se second
 
#define all(x) (x).begin(), (x).end()
 
using namespace std;             
//using namespace __gnu_pbds;
 
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int INF = (int)1e10;

int n, m, c;

int b[205], a[205][205];

void solve() {       
    cin >> n >> m >> c;

    for (int i = 1; i <= m; i++) cin >> b[i];
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int sum = 0;
        for (int j = 1; j <= m; j++) {
            cin >> a[i][j];
            sum += (a[i][j] * b[j]);
        }
        if (sum + c > 0) ans++;
    }
    cout << ans;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int tt = 1;
 
    while (tt--) {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using  namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
#define INF 1e18+1


int main(){
	string s;
	cin>>s;
	int ans=0;
	REP(i,s.size()){
		if(ans==0&&s[i]=='C')ans++;
		if(ans==1&&s[i]=='F')ans++;
	}
	if(ans==2)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}
	
	

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
 const ll INF = 1e18;
//const ll MOD = 1e9+7;
const double pi = 3.14159265358979;
using vl = vector<ll>;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()

ll A, B, H, M;
string S;

int Main() {
    cin >> A >> B >> H >> M;
//    vl A(N);
    
    double aX = A * sin(H*pi/6 + M*pi / 360);
    double aY = A * cos(H*pi/6 + M*pi / 360);

    double bX = B * sin(M*pi / 30);
    double bY = B * cos(M*pi / 30);
    
//    cout << aX << endl;
//    cout << aY << endl;
//    cout << bX << endl;
//    cout << bY << endl;
    double dist = sqrt((double)(bX-aX) * (bX-aX) + (double)(bY-aY)*(bY-aY));
    cout << fixed << setprecision(20) << dist << endl;
    return 0;
}

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


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

int main(){
    string S, T;
    cin >> S >> T;
    int N = S.size(), M = T.size();
    int ans = 1e9;
    for(int s=0; s+M<=N; s++){
        int res = 0;
        for(int i=0; i<M; i++) res += (T[i] != S[s+i]);
        ans = min(ans, res);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int N, M, H[100010], MAX[100010];
  cin >> N >> M;
  for(int i=1; i<=N; i++){
    cin >> H[i];
    MAX[i] = 0;
  }
  for(int i=1;i<=M; i++){
    int A, B;
    cin >> A >> B;
    MAX[A] = max(MAX[A],H[B]);
    MAX[B] = max(MAX[B],H[A]);
  }
  int ans = 0;
  for(int i=1 ; i<=N ; i++){
    ans += H[i] > MAX[i];
  }
  cout << ans << endl; 
  return 0;
}

Measured memory_bytes: 3964
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var c = int.Parse(line[2]);
        var k = int.Parse(line[3]);
        Console.WriteLine(getAns(a, b, c, k));
    }
    static int getAns(int a, int b, int c, int k)
    {
        if (k <= a) return k;
        if (k <= a + b) return a;
        return 2 * a + b - k;
    }
}


Measured memory_bytes: 27552
#include <iostream>
using namespace std;
int main(void){
   int t,n;
   for(int i=0; i<4; i++) {
   cin >> t >> n;
   if(t == 1) {
       cout << 6000*n << endl;
   }
   else if(t == 2) {
       cout << 4000*n << endl;
   }
   else if(t == 3) {
       cout << 3000*n << endl;
   }
   else if(t == 4) {
       cout << 2000*n << endl;
   }
   }
}


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

template <typename t>
void mi(t& a, const t& b) { a = min(a, b); }

template <typename t>
void ma(t& a, const t& b) { a = max(a, b); }

int n;

bool is_pal(const char*const a, const int leng)
{
   const auto le = leng / 2;
   for (int i = 0; i < le; i++)
   {
      if (a[i] != a[leng - 1 - i])
      {
         return false;
      }
   }

   return true;
}

int cfo(const char* const a, const int pos)
{
   const auto& c = a[pos];
   int ret = 0;
   for (int i = pos; i < n; i++)
   {
      if (c != a[i])
      {
         return ret;
      }
      ++ret;
   }

   //assert(0);
   return ret;
}

int cba(const char* const a, const int pos)
{
   const auto& c = a[pos];
   int ret = 0;
   for (int i = pos; 0 <= i; --i)
   {
      if (c != a[i])
      {
         return ret;
      }
      ++ret;
   }

   //assert(0);
   return ret;
}


constexpr int g1 = 1000 * 1000 * 1000, si = 1024 * 1024, si_log = 10 + 10, mod = static_cast<int>(1e9) + 7;
constexpr long double eps = 1.0e-9;
int //n,
m;
char ar[si], br[si];

int64_t sol()
{
   auto ret = 0 * numeric_limits<int64_t>::max();

   if (is_pal(ar, n))
      return 0;

   m = 0;
   for (int i = 0; i < n; i++)
   {
      if ('x' == ar[i]) continue;
      br[m++] = ar[i];
   }

   if (!is_pal(br, m))
      return -1;

   int i = 0, j = n - 1;
   const auto be = cfo(ar, 0);
   const auto en = cba(ar, n - 1);
   if ('x' == ar[0] && 'x' == ar[n - 1])
   {
      ret += abs(be - en);
      i += be;
      j -= en;
   }
   else if ('x' == ar[0])
   {
      ret += abs(be);
      i += be;
   }
   else if ('x' == ar[n - 1])
   {
      ret += abs(en);
      j -= en;
   }

   while (i < j && 0 <= j && i < n)
   {
      if (ar[i] == ar[j])
      {
         ++i;
         --j;
         continue;
      }
      if ('x' == ar[i])
      {
         ++i;
         ret++;
         continue;
      }
      if ('x' == ar[j])
      {
         --j;
         ret++;
         continue;
      }
      assert(0);
   }

   return ret;
}

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

   while (1 == scanf("%123456s", ar) && 'a' <= ar[0] && ar[0] <= 'z')
   {
      n = static_cast<int>(strlen(ar));

      {
         auto s =
            sol();
         //puts(s ? "yes" : "no");
         cout << s << '\n';
      }
      memset(ar, 0, sizeof ar);
      memset(br, 0, sizeof br);
#ifndef _DEBUG
      break;
#endif
   }
   return 0;
}


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

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

    int x;
    cin>>x;

    int ma=1;

    for(int i=2;i<sqrt(x);i++)
    {
        int n=i;
        for(int j=0;j<10;j++)
        {
            n*=i;
            if(n>x)break;
            ma=max(ma,n);
        }
    }

    cout<<ma<<"\n";

    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include<map>
typedef long long ll;
using namespace std;
void read(int &x){int f=1;x=0;char s=getchar();while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}x*=f;}
//void write(int x){if(x<0){putchar('-');x=-x;}if(x>9)write}
int gcd(int x,int y){
	if(x<y){
		int w=x;
		x=y;
		y=w;
	}
	int h=x;
	while(h){
		h=x%y;
		x=y;
		y=h;
	}
	return x;
}
int GCD(int a,int b)
 
{
     
return b==0?a:GCD(b,a%b);
 
}
int main(){	
	int n,m;
	int a[100005];
	int b[100005];
	read(n);
	read(m);
	int h=0;
	int top=0;
	for(int i=0;i<n;i++){
		read(a[i]);
		b[top++]=abs(a[i]-m);
	}
	h=GCD(b[0],b[1]);
	for(int i=2;i<n;i++){
		h=GCD(b[i],h);
	}
	printf("%d\n",h);
}

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

int S, h, m, s;

int main() {
    cin >> S;
    
    h = S / 3600; S %= 3600;
    m = S / 60; S %= 60;
    s = S;
    
    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
}


Measured memory_bytes: 3088
// They can't break me, as long as I know who I am...

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

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

const int maxn = 1e5 + 10, mod = 1e9 + 7;
const ll inf = 1e18;

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

    ll n, a, b;
    cin>>n>>a>>b;
    if(a > b){
	swap(a, b);
    }
    if((a - b)&1){
	cout<<min(n-a + n-b + 1, a-1 + b-1 + 1) /2 <<endl;
    }
    else{
	cout<<(b-a) / 2 << endl;
    }
    return 0;
}
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


Measured memory_bytes: 256
import numpy as np
from itertools import combinations

n = int(input())
nums = list(map(int, input().split()))
count = 0
for i in combinations(nums,3):
    if len(np.unique(i)) == 3:
        sorts = np.sort(i)
        if sorts[2] < sorts[1] + sorts[0]:
            count +=1 
print(count)

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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  int n;
  const int max_n = 1e4;
  cin >> n;

  int ans = 0;
  int res;
  vector<int> f(1e5, 0);

  for(int i = 1; i < 120; i++){
    for(int j = 1; j < 120; j++){
      for(int k = 1; k < 120; k++){
        res = i*i + j*j + k*k + i*j + j*k + k*i;
        f[res] ++;
      }
    }
  }
  for(int i = 1; i <= n; i++){
    cout << f[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 3704
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

signed main() {
	int N;
	cin >> N;
	int four = 0, two = 0, odd = 0;
	rep(i, N) {
		int num;
		cin >> num;
		if (num % 4 == 0)four++;
		else if (num % 2 == 0)two++;
		else odd++;
	}
	if (two) {
		if (four >= odd)cout << "Yes";
		else cout << "No";
	}
	else {
		if (four >= odd - 1)cout << "Yes";
		else cout << "No";
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = 0;

		for(int i = 1; i <= 50000; i++) {
			X = (int) (i * 1.08);
			if(N == X) {
				System.out.println(i);
				break;
			}

			if(i == 50000) {
				System.out.println(":(");
			}
		}


	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i < (n); ++i)
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> inline bool change(T& a, T b) { if (a != b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;


int main(){
    ll n; cin>> n;
    n--;
    vector<char> v;
    ll d=26;
    int dig=1;
    while(n>=d){
        n-=d;
        d*=26;
        dig++;
    }
    //cout << dig << endl;
    for(int i=0;i<dig;i++){
        v.push_back(char(n%26)+'a');
        n/=26;
    }
    for(int i=v.size()-1;i>=0;i--){
        cout << v[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3628
N = int(input())
A = [int(i) for i in input().split()]

cnt = len([i for i in A if i < 0])
abs_A = sorted([abs(i) for i in A])

if cnt%2 == 0:
    print(sum(abs_A))
else:
    print(sum(abs_A)-2*abs_A[0])

Measured memory_bytes: 66664
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<cstring>
#include<map>
#include<vector>
#include<set>
#define rep(i,j,k) for(register int i = j; i <= k; i++) 
#define dow(i,j,k) for(register int i = j; i >= k; i--)
#define fi first
#define se second
#define P pair<int,int>
#define PP pair<int,pair<int,int> >
#define mp(a,b) make_pair(a,b)
#define ll long long
#define ull unsigned long long
using namespace std;

inline int read() { 
	int s = 0, t = 1; char c = getchar();
	while( !isdigit(c) ) { if( c == '-' ) t = -1; c = getchar(); }
	while( isdigit(c) ) s = s * 10 + c - 48, c = getchar();
	return s * t;
}

const int N = 1e5+5;
inline bool cmp(const int&a,const int&b) { return a > b; }
int v[N];

int main() {
	int n = read();
	rep(i,0,n-1) v[i] = read() - 1;
	sort(v,v+n,cmp);
	
	bool flag = 0;
	rep(i,0,n-1) { 
		if( i + 1 > v[i+1] ) { 
			int ret = 0;
			rep(j,i+1,n-1) if( v[j] == i ) ret++; else break;
			if( ret & 1 ) flag |= 1;
			if( (v[i] - i) & 1 ) flag |= 1;
			if( flag ) puts("First");
			else puts("Second"); 
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int clz(int x) { return 31 - __builtin_clz(x); }
int clz(ll x) { return 63 - __builtin_clzll(x); }
int ctz(int x) { return __builtin_ctz(x); }
int ctz(ll x) { return __builtin_ctzll(x); }

class compare {
public:
	bool operator()(tuple<ll, ll> a, tuple<ll, ll> b) {
		return (get<1>(a) > get<1>(b));
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll d,g;
	ll ans=LINF;
	cin>>d>>g;
	vl p(d),c(d);
	rep(i,d){
		cin>>p[i]>>c[i];
	}
	rep(i,1<<d){
		ll score=0,solve=0;
		rep(j,d){
			if(i&(1<<j)){
				score+=(j+1)*100*p[j]+c[j];
				solve+=p[j];
			}
		}
		ll ad=g-score;
		if(ad>0){
			rrep(j,d){
				if(!(i&(1<<j))){
					if(ad>=(j+1)*100*(p[j]-1)){
						solve+=(p[j]-1);
						ad-=(j+1)*100*(p[j]-1);
					}
					else{
						solve+=((ad+(j+1)*100-1)/((j+1)*100));
						ad=-1;
					}
				}
			}
		}
		if(ad<=0)ans=min(solve,ans);
	}
	cout<<ans<<endl;

}


Measured memory_bytes: 256
s=input()
k=int(input())
m=0
j=0
if len(set(list(s)))==1:print((len(s)*k)//2);exit()
for i in range(len(s)):
 if len(s)<=j+1:
  a=m*k
  if s[0]==s[-1]==s[len(s)//3]:print(a+k-1)
  else:print(a)
  break
 if s[j]==s[j+1]:m+=1;j+=1
 j+=1

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


int main(){
    int N;
    string S;
    cin >> N >> S;
    int count=0;
    for(int i=0;i<N-2;i++){
        if(S.at(i)=='A' &&  S.at(i+1)=='B' && S.at(i+2)=='C'){
            count++;
        }
    }
    cout << count << endl;

}

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    string s[3];
    while(cin >> s[0] >> s[1] >> s[2]) {
        int n[3] = {(int)s[0].size(), (int)s[1].size(), (int)s[2].size()};
        int i[3] = {0, 0, 0};
        int cur = 0;
        while(i[cur] < n[cur]) {
            cur = s[cur][i[cur]++] - 'a';
        }
        cout << (char)(cur + 'A') << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define MAX 1005
const ll MOD=1e9+7;
using namespace std;
int gcd(int a, int b) {
  if(a==0) return b;
  if(a>b) return gcd(a%b, b);
  else return gcd(b%a, a);
}

int main() {
  int a,b,k;
  cin >> a >> b >> k;
  int count=0;
  int g=gcd(a,b);
  vector<int> v;
  for(ll i=1;i<=g;i++){
    if(a%i==0&&b%i==0){
      count++;
      v.push_back(i);
    }
  }
  sort(All(v));
  cout << v[v.size()-k] << endl;
}


Measured memory_bytes: 256
/// You just can't beat the person who never gives up
/// ICPC next year

//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std ;
const int N = 2e5+5 ,mod = 1e9+7 ;

int n ,a[N] ;
long long sum ,ans ;
bool Never_give_up(){
    scanf("%d",&n);
    for(int i=0;i<n;++i) scanf("%d",a+i);
    for(int i=n-1;i>=0;--i){
        ans = (ans + sum*a[i])%mod ;
        sum = (sum + a[i])%mod ;
    }
    cout << ans << endl ;
    return 0;
}
int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt" ,"r" ,stdin);
    freopen("output.txt" ,"w" ,stdout);
#endif
    //std::ios::sync_with_stdio(0);
    //cin.tie(0) ,cout.tie(0);
    int t = 1 ;
    //scanf("%d",&t);
    while(t--){
        Never_give_up();
    }
    return 0;
}


Measured memory_bytes: 4540
n = int(input())
a = list(map(int, input().split()))
total = 0
for i in range(n - 1):
    if a[i] > a[i + 1]:
        diff = abs(a[i] - a[i + 1])
        total += diff
        a[i + 1] += diff
        
print(total)


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n,q;
    cin >> n >> q;
    int32 s[n], t[n], x[n];
    REP(i,n)cin >> s[i] >> t[i] >> x[i];
    vector<tuple<int32,bool,int32>> event;
    REP(i,n){
        if(t[i] - x[i] >= 0){
            event.pb(make_tuple(s[i] - x[i], true, x[i]));
            event.pb(make_tuple(t[i] - x[i], false, x[i]));
        }
    }
    sort(ALL(event));
    // REP(i,event.size()){
    //     cout << get<0>(event[i]) << " " << get<1>(event[i]) << " " << get<2>(event[i]) << endl;;
    // }
    vector<int32> d(q);
    REP(i,q)cin >> d[i];
    int32 index = 0;
    set<int32> st;
    int32 ans[n];
    REP(i,event.size()){
        while(index < q && get<0>(event[i]) > d[index]){
            // auto iter = min_element(ALL(st));
            // if(iter == st.end()){
            //     ANS(-1);
            // }else{
            //     ANS(*iter);
            // }
            if(st.empty()){
                ANS(-1);
            }else{
                ANS(*st.begin());
            }
            index++;
        }
        if(get<1>(event[i])){
            st.insert(get<2>(event[i]));
        }else{
            st.erase(get<2>(event[i]));
        }
        if(index == q)break;
    }
    int32 mn;
    if(st.empty()){
        mn = -1;
    }else{
        mn = *st.begin();
    }
    while(index < q){
        // auto iter = min_element(ALL(st));
        // if(iter == st.end()){
        //     ANS(-1);
        // }else{
        //     ANS(*iter);
        // }
        ANS(mn);
        index++;
    }
    return 0;
}

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


int main() {
    int h,w;cin>>h>>w;
    vector<string> s(h);
    rep(i,h)cin>>s[i];
    
    vector<int> di={-1,0,1,0};
    vector<int> dj={0,1,0,-1};
    
    rep(i,h)rep(j,w){
        if(s[i][j]=='.')continue;
        
        bool ok = false;
        
        rep(k,4){
            int ni = i+di[k];
            int nj = j+dj[k];
            
            if(ni<0 || ni>=h)continue;
            if(nj<0 || nj>=w)continue;
            
            if(s[ni][nj]=='#')
                ok = true;
        }
        
        if(!ok){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cmath>

intmax_t f(intmax_t b, intmax_t n) {
  intmax_t s=0;
  while (n) {
    s += n % b;
    n /= b;
  }

  return s;
}

int main() {
  intmax_t n, s;
  scanf("%jd %jd", &n, &s);

  if (s == n)
    return !printf("%jd\n", n+1);

  intmax_t sqrtn=sqrt(n);
  for (intmax_t b=2; b<=sqrtn; ++b)
    if (f(b, n) == s)
      return !printf("%jd\n", b);

  for (intmax_t p=sqrtn; p>0; --p) {
    intmax_t b=(n-s)/p+1;
    if (b < 2) continue;
    if (f(b, n) == s)
      return !printf("%jd\n", b);
  }

  printf("-1\n");
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
 
int main() {
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    if(b-a > k || c-a > k || d-a > k || e-a > k){
    	cout << ":(" << endl;
	}else if(c-b > k || d-b > k || e-b > k){
    	cout << ":(" << endl;
    }else if(d-c > k || e-c > k){
    	cout << ":(" << endl;
    }else if(e-d > k){
	    cout << ":(" << endl;
    }else{
        cout << "Yay!" << endl;
    }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;

using namespace std;

int main(){
    cs
    ld x;
    cin>>x;
    cout<<fixed<<setprecision(12)<<2*x*acos(-1);
}

Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int main(){
  in n,m,k;
  cin>>n>>m>>k;
  vector<in> a(n),b(m);
  rep(i,n)
    cin>>a.at(i);
  rep(i,m)
    cin>>b.at(i);
  
  vector<in> suma(n+1,0),sumb(m+1,0);
  rep(i,n)
    suma.at(i+1)=suma.at(i)+a.at(i);
  rep(i,m)
    sumb.at(i+1)=sumb.at(i)+b.at(i);
  int ans=0;
  
  /*rep(i,n+1)
    cout<<suma.at(i)<<" ";
  cout<<endl;
  rep(i,m+1)
    cout<<sumb.at(i)<<" ";
  cout<<endl;*/
  
  rep(i,n+1){
    auto itr = lower_bound(all(sumb),k-suma.at(i)+1);
    int nan = distance(sumb.begin(),itr)-1;
    nan+=i;
    if(suma.at(i)>k)
      nan=0;
    //cout<<nan<<endl;
    if(nan>ans)
      ans=nan;
  }
  cout<<ans<<endl;
}
    

Measured memory_bytes: 9592
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
int main()
{
	int n,m,sum=0;
	int temp;
	cin>>n>>m;
	int a[n];
	for(int i=0; i<n; i++)
	{
		cin>>a[i];
	}
	sort(a, a+n, greater<int>());
	for(int i=0; i<n; i++)
	{
		sum+=a[i];
	}
	temp= ceil(sum/float((4*m)));
	if(a[m-1]>=temp)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
}

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

int main() {
    int a,b;cin>>a>>b;
    if(a>9||b>9)cout<<-1<<endl;
    else cout<<a*b<<endl;
}

Measured memory_bytes: 256
import heapq

n,m=map(int,input().split())
g=[[] for _ in range(n)]

for _ in range(m):
    a,b,c=map(int,input().split())
    a-=1
    b-=1
    g[a].append((b,c))
    g[b].append((a,c))

used=set()

for i in range(n):
    q=[(0,i,-1)]
    dist=[10**10]*n
    dist[i]=0
    edge=[0]*n

    while len(q)>0:
        d,u,v=heapq.heappop(q)

        if d>dist[u]:
            continue

        edge[u]=v

        for w,nd in g[u]:
            tmp=nd+dist[u]
            if tmp<dist[w]:
                dist[w]=tmp
                heapq.heappush(q,(tmp,w,u))
    
    for u,v in enumerate(edge):
        if v==-1:
            continue
        used.add((max(u,v),min(u,v)))

print(m-len(used))


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);

int main() {
	cin.sync_with_stdio(false);
	char C[2][3];
	rep(i, 3)cin >> C[0][i];
	rep(i, 3)cin >> C[1][i];
	bool flag = true;
	rep(i, 3) {
		if (C[0][i] != C[1][2 - i])flag = false;
	}
	if (flag)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
//WrittenBiDP
//knapsack

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef vector <ll> vi;
typedef vector <vi> vvi;

vi weight, cost;
vvi ans;

int main() {
	//ifstream In("input.txt");
	//ofstream Out("output.txt");

	int n, w;

	cin >> n >> w;

	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		weight.push_back(a);
		cost.push_back(b);
	}

	ans.resize(n);
	for (int i = 0; i < n; i++) {
		ans[i].assign(w + 1, 0);
	}

	for (int i = weight[0]; i < w + 1; i++) {
		ans[0][i] = cost[0];
	}

	for (int i = 1; i < n; i++) {
		for (int j = 0; j <= w; j++) {
			if (j - weight[i] < 0) ans[i][j] = ans[i - 1][j];
			else
				ans[i][j] = max(ans[i - 1][j], ans[i - 1][j - weight[i]] + cost[i]);
		}
	}

	cout << ans[n - 1][w];
	return 0;
}

Measured memory_bytes: 78592
from itertools import permutations

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

p = 0
q = 0
for i, perm in enumerate(permutations([i for i in range(1, 1 + N)])):
    if perm == P:
        p = i
    if perm == Q:
        q = i
print(abs(p - q))


Measured memory_bytes: 3060
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
pred = -1
for a in A:
    ans += B[a-1]
    if (a-1) == pred:
        ans += C[pred-1]
    pred = a
print(ans)


Measured memory_bytes: 3060
s = int(input())
a = list(map(int, input().split()))

incFlg = True   #登る場合はTure,　降る場合はFalse
before_height = 0
sum = 0

for i in range(len(a)-1):
    #降る場合
    if a[i] > a[i+1]:
        #その前が登り
        if incFlg:
            sum += a[i] - before_height
            incFlg = False
        #その前が下り
        # else:
        #     # before_height = a[i]
    #登る場合
    else:
        if not incFlg:
            before_height = a[i]
        incFlg = True

if incFlg:
    sum += a[len(a)-1] - before_height

print(sum)


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

struct SegmentTree {
  int n;
  vector<int> data;
  SegmentTree(int size) {
    n = 1;
    while (n < size) n*=2;
    data.resize(2*n-1, 0);
  }
  // （0-indexed）k番目 を aに更新
  void update(int k, char a) {
    k += n - 1;
    int p = a-'a';
    data[k] = (1<<p);
    // cout<<a<<':'<<p<<':'<<(1<<p)<<endl;
    while(k>0){
      k = (k - 1) / 2;
      data[k] = (data[k*2+1] | data[k*2+2]);
    }
  }
  // [a, b)の最小値を求める
  int query(int a, int b) {
    return __builtin_popcount ( _query(a, b, 0, 0, n) );
  }
  int _query(int a, int b, int k, int l, int r) {
    // [a, b) と [l, r)が交わらない
    if (r<= a || b <= l) return 0;
    // [a, b)が[l, r)を含んでいるので節点の値
    if (a <= l && r <= b) return data[k];
    int vl = _query(a, b, k * 2 + 1, l, (l + r) / 2);
    int vr = _query(a, b, k * 2 + 2, (l + r) / 2, r);
    return (vl | vr);
  }
};

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  int n;cin>>n;
  string s;cin>>s;
  int q;cin>>q;

  SegmentTree st = SegmentTree(n);

  for(int i=0;i<n;i++){
    st.update(i, s[i]);
  }

  while(q--){
    int a,b;cin>>a>>b;
    if(a==1){
      char c;cin>>c;
      st.update(b-1,c);
    }else{
      int c;cin>>c;
      cout<<st.query(b-1, c)<<endl;
    }
  }

  
  return 0;
}


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

#define   ipr         	pair<int, int>
#define   pb            push_back
#define   ff            first
#define   ss            second
#define   fr(i, j, k)   for (int i = j; i < k; i++)
#define   rf(i, j, k)   for (int i = j; i >= k;i--)
#define   int           long long
#define   ll 			unsigned long long
#define   ld            long double
#define   all(x)        x.begin(), x.end()
#define   rall(x)       x.rbegin(),x.rend()
#define   mp            make_pair
#define   inf           INT_MAX
#define   read_file();	freopen("input.txt", "r", stdin);	freopen("output.txt", "w", stdout);
#define   IOS           std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int Maxn  =  10000;
const ld  pi   =  acos(-1);
const int mod =  1000000007;


template<class T> ostream& operator <<(ostream &out,vector<T> &A){for(auto x:A) out<<x<<" ";return out;}
template<class T> ostream& operator <<(ostream &out,set<T> &A){for(auto x:A) out<<x<<" ";return out;}
template <class T1,class T2>T1 powr(T1 a,T2 b){T1 res = 1;fr(i,1,b+1)res = res*a;return res;}


int32_t main(){IOS
  
  float a,b;
  int flag=1;
  cin>>a>>b;
  fr(i, 1, 10000) {
        if ((i * 8) / 100 == a && (i * 10) / 100 == b) {
            cout << i << endl; 
            flag=0;
            break;
        }
    }
    if(flag==1)
    cout << -1 << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
int a,b,c;
int tmp,i,j;

scanf("%d %d %d",&a,&b,&c);

if (a>b)
{
tmp = a;
a = b;
b = tmp;
}

if (a>c)
{
tmp = a;
a = c;
c = tmp;
}

if (b>c)
{
tmp = b;
b = c;
c = tmp;
}
printf("%d %d %d\n",a,b,c);

return 0;
}

Measured memory_bytes: 596
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:108777216")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <bitset>
#include <queue>
#include <algorithm>
using namespace std;
 
int const MAX_N = 128 * 1024;
int const INT_INF= 1000000000;
long long const MODULE = 1000000007;

int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
 
	int n;
	scanf("%d",&n);
	int x = 0, y = 0, t_last = 0;
	for (int i=0; i<n; i++) {
		int tt,xx,yy;
		scanf("%d%d%d",&tt,&xx,&yy);
		int dx = x - xx;
		if (dx<0) dx = -dx;
		int dy = y-yy;
		if (dy<0) dy = -dy;
		int bbs = dx + dy;
		int dt = tt - t_last;
		if (bbs > dt) {
			cout<<"No";
			return 0;
		}
		if (bbs % 2 != dt % 2) {
			cout<<"No";
			return 0;
		}
		t_last = tt;
		x = xx;
		y = yy;
	}

	cout<<"Yes";
    return 0;
}  


Measured memory_bytes: 256
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<ll> > mat;

int main()
{
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  for (int i = 0; i < n; i++)
  {
    if (i + 1 == k)
    {
      int x = s[i] - 'A';
      cout << char('a' + x);
    }
    else
    {
      cout << s[i];
    }
  }
  cout << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << "\n"
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int main() {
	int n, m; cin >> n >> m;
	vi C(m, 0); rep(i, 0, m) cin >> C[i];
	vi dp(n + 1, 1e9);
	dp[0] = 0;
	rep(i, 0, m) {
		rep(j, C[i], n + 1) {
			chmin(dp[j], dp[j - C[i]] + 1);
		}
	}
	P(dp[n]);
	return 0;
}

Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N, K;
	scanf("%d %d", &N, &K);
	int ans = 1;
	for(int i = 0; i < N; i++){
		if(ans < K) ans *= 2;
		else ans += K;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
H, W = list(map(int, input().split()))
s = []
black = 0
for i in range(H):
    s.append(input())
    black += s[i].count('#')

# re = max(-1, H * W - (H + W - 1) - black)

queue = [[0,0,1]] # h,w,深さ
check = [[0,0]]
root = 0
hCurrent, wCurrent = 0, 0
while True:
    root += 1
#    print(queue)
    if hCurrent == H - 1 and wCurrent == W - 1:
        break
    if len(queue) == 0:
        root = -1
        break

    hCurrent, wCurrent, depth = queue[0]
    queue.pop(0)

    if hCurrent < H - 1:
        if s[hCurrent + 1][wCurrent] != "#" and [hCurrent + 1, wCurrent] not in check:
            queue.append([hCurrent + 1, wCurrent, depth+1])
            check.append([hCurrent + 1, wCurrent])
    if wCurrent < W - 1:
        if s[hCurrent][wCurrent+1] != "#" and [hCurrent, wCurrent + 1] not in check:
            queue.append([hCurrent, wCurrent + 1,depth+1])
            check.append([hCurrent, wCurrent + 1])
    if hCurrent > 0:
        if s[hCurrent - 1][wCurrent] != "#" and [hCurrent - 1, wCurrent] not in check:
            queue.append([hCurrent - 1, wCurrent,depth+1])
            check.append([hCurrent - 1, wCurrent])
    if wCurrent > 0:
        if s[hCurrent][wCurrent - 1] != "#" and [hCurrent, wCurrent - 1] not in check:
            queue.append([hCurrent, wCurrent-1,depth+1])
            check.append([hCurrent, wCurrent-1])

if root == -1:
    re = -1
else:
    re = max(-1, H * W - depth - black)
    #re = H * W - black - root

print(re)


Measured memory_bytes: 3188
while True:
    N = int(input())
    if N == 0:
        break
    ans = 0
    change = 1000 - N
    while change >= 500:
        change -= 500
        ans += 1
    while change >= 100:
        change -= 100
        ans += 1
    while change >= 50:
        change -= 50
        ans += 1
    while change >= 10:
        change -= 10
        ans += 1
    while change >= 5:
        change -= 5
        ans += 1
    ans += change
    print(ans)


Measured memory_bytes: 5592
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <bitset>
using namespace std;

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

const int MAX_X = 1000002;
int N, X, p[32];

int main() {
  bitset<1000002> prime;
  prime.set();
  prime.reset(0);
  prime.reset(1);
  for (int i = 4; i < MAX_X; i+=2) prime.reset(i);
  for (int i = 3; i < MAX_X; i+=2) {
    if (prime[i]) {
      //printf("%d\n",i);
      for (int j = i+i; j < MAX_X; j+=i) prime.reset(j);
    }
  }
  
  while (scanf("%d%d",&N,&X),N|X) {
    //printf("%d %d\n", N, X);
    rep(i,N) scanf("%d",p+i);
    //rep(i,N) printf("%d\n",p[i]);
    bitset<1000002> bs;
    bs.set(0);
    rep(i,N) {
      rep(j,X) {
        if (bs[j] && j + p[i] <= X && !bs[j+p[i]]) {
          //printf("%d\n",j+p[i]);
          bs.set(j+p[i]);
        }
      }
    }
    bool ok = false;
    for (int i = X; i > 1; --i) {
      if (prime[i] && bs[i]) {
        printf("%d\n",i);
        ok = true;
        break;
      }
    }
    if (!ok) {
      puts("NA");
    }
  }
  return 0;
}

Measured memory_bytes: 1124
readline = open(0).readline
ans = []
while 1:
    m, f, r = map(int, readline().split())
    if m == f == r == -1:
        break
    v = m+f
    if m == -1 or f == -1 or v < 30:
        ans.append("F\n")
    elif v >= 80:
        ans.append("A\n")
    elif v >= 65:
        ans.append("B\n")
    elif v >= 50 or (v >= 30 and r >= 50):
        ans.append("C\n")
    else:
        ans.append("D\n")
open(1, 'w').writelines(ans)


Measured memory_bytes: 5604
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();

		int ans = 0;
		for (int i = 0, size = s.length; i < size; i++) {
			if (s[i] == t[i]) {
				ans++;
			}
		}

		pr.println(ans);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<char> vec(N);
	for (int i=0; i < N; i++)
		cin >> vec.at(i);
	bool four=false;

	for (int i = 0; i < N; i++)
		if (vec.at(i) == 'Y') {
			four = true;
			break;
		}
	if (four)
		cout << "Four" << endl;
	else
		cout << "Three" << endl;
	return 0;
}



Measured memory_bytes: 256
package main

import (
	"fmt"
)

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func main() {
	var s string
	fmt.Scan(&s)

	ans := 0
	count := 0
	for _, v := range s {
		if v == 'A' || v == 'G' || v == 'C' || v == 'T' {
			count++
		} else {
			count = 0
		}
		ans = max(ans, count)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int r,g,b,n;cin>>r>>g>>b>>n;
  int res=0;
  for(int i=0;i<=n;++i){
    for(int j=0;j<=n;++j){
      int buf=n-i*r-j*g;
      if(buf>=0&&buf%b==0)++res;
    }
  }
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 256