akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int K; cin >> K;
    cout << (K / 2) * ((K + 1) / 2) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int n; cin >> n;
	int ans = 100000;
	int tmp;
	for (int i=0; i<n; i++) {
		ans *= 1.05;
		tmp = ans / 1000 * 1000;
		if (tmp != ans) ans = tmp + 1000;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <string>
using namespace std;
string S;
int main() {
  cin >> S;
  if(S == "SUN") cout << 7 << endl;
  else if(S == "MON") cout << 6 << endl;
  else if(S == "TUE") cout << 5 << endl;
  else if(S == "WED") cout << 4 << endl;
  else if(S == "THU") cout << 3 << endl;
  else if(S == "FRI") cout << 2 << endl;
  else if(S == "SAT") cout << 1 << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=list(input())

    for n in N:
        if n=="7":
            print("Yes")
            exit()

    print("No")









if __name__ == "__main__":
    main()

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

const int inf = 1e9;
typedef pair<int,int> P;

class Dijkstra{
public:
	vector<int> d;
	vector<vector<P> > G;
	int V;
	void init(int n){
		V = n;
		d.resize(n);
		G.resize(n);
	}
	void connect(int s, int t, int c){
		G[s].push_back(P(t, c));
	}
	void calc(int s){
		priority_queue<P, vector<P>, greater<P> > q;
		fill(d.begin(), d.end(), inf);
		d[s] = 0;
		q.push(P(0, s));
		
		while(!q.empty()){
			P p = q.top();q.pop();
			int from = p.second;
			if(d[p.second] < p.first)continue;
			
			for(int i = 0;i < G[from].size();i++){
				int to = G[from][i].first;
				int cost = G[from][i].second;
				
				if(d[to] > d[from]+cost){
					d[to] = d[from]+cost;
					q.push(P(d[to], to));
				}
			}
		}
	}
};

int main(){
	Dijkstra D;
	int n, m, s;
	scanf("%d%d%d", &n, &m, &s);
	D.init(n);
	for(int i = 0;i < m;i++){
		int x, y, c;
		scanf("%d%d%d", &x, &y, &c);
		D.connect(x, y, c);
	}
	D.calc(s);
	for(int i = 0;i < n;i++){
		int ans = D.d[i];
		if(ans == inf)printf("INF\n");
		else printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 13004
package main

import (
    "fmt"
    "math"
)

func main() {
    var n, d int
    fmt.Scan(&n, &d)
    xs := make([][]int, n)
    for i := range xs {
        xs[i] = make([]int, d)
        for j := range xs[i] {
            fmt.Scan(&xs[i][j])
        }
    }
    var cnt int
    for i := 0; i < n-1; i++ {
        for j := i + 1; j < n; j++ {
            var sum int
            for k := 0; k < d; k++ {
                t := xs[i][k] - xs[j][k]
                sum += t * t
            }
            s := int(math.Sqrt(float64(sum)))
            if s*s == sum {
                cnt++
            }
        }
    }

    fmt.Println(cnt)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007
#define ll long long int
#define pair <ll, ll> pi
#define vector <ll> vi
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define SQ(a) (a) * (a)
#define ordered_set tree<ll, null_type, greater_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> //greater_equal<ll> or less<ll>
// find_by_key()   order_of_key()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
/*bool comp(string a, string b) {
if (a.size() != b.size()) return a.size() < b.size();
return a < b;
}*/

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen('input.txt', 'r', stdin);
    //freopen('output.txt', 'w', stdout);
    ll i, j, k, n, m, b, d, t, ans = 0,a,x,y;
    cin>>k>>x;
    if(500*k>=x){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

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

    cout << min(n * a, b) << endl;

    return 0;
}

Measured memory_bytes: 764
#include <stdio.h>
int main ()
{
	int a,b,c,d;
	scanf("%d %d %d",&a,&b,&c);
    d=a+b;
    if(a<=c&&d>=c)
    printf("YES\n");
    else
    printf("NO\n");
	return 0;

}
	
	

Measured memory_bytes: 1620
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, t1, t2;
vector<pair<int, int> > vec;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t1 >> t2;
		vec.pb(make_pair(t2, t1));
	}
	sort(vec.begin(), vec.end());
	int cnt = 0, cur = 0;
	while (1) {
		if (cnt == n) break;
		if (vec[cnt].fi - cur < vec[cnt].se) {
			cout << "No\n";
			return 0;
		}
		else {
			cur += vec[cnt].se;
		}
		cnt++;
	}
	cout << "Yes\n";
	//system("pause");
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll N, W;
  cin >> N >> W;

  vector<ll> w(N+1);
  vector<ll> v(N+1);
  for (ll i = 0; i < N; ++i) {
    cin >> w[i+1];
    cin >> v[i+1];
  }

  ll MAX_V = N*1000;
  vector<vector<ll>> dp(N+10, vector<ll>(MAX_V+10, 0));
  dp[0][0] = 0;
  for (ll i = 1; i <= MAX_V; ++i) dp[0][i] = 10000000000;
  for (ll i = 1; i <= N; ++i) {
    for (ll j = 1; j <= MAX_V; ++j) {
      if (j-v[i] >= 0) {
        dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]] + w[i]);
      } else {
        dp[i][j] = dp[i-1][j];
      }
    }
  }

  ll ans = 0;
  for (ll i = 1; i <= MAX_V; ++i) {
    if (dp[N][i] <= W) {
      ans = i;
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 87296
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int main() {
	ll A, B, K;
	cin >> A >> B >> K;
	if(A+B<=K) cout << "0 0" << endl;
	else if(K<=A) cout << A-K << ' ' << B << endl;
	else cout << 0 << ' ' << A+B-K << endl;
	return 0;
}

Measured memory_bytes: 256
/*raghav0307 - Raghav Gupta*/

#include <bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define pb push_back
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

typedef long long ll;
#define int ll

signed main(){
	fast_io();
	int n;	cin >> n;
	int sum = 0;
	int mmin = 1e9 + 5;
	int neg = 0;
	for(int i = 0; i < n; i++){
		int temp;	cin >> temp;
		if(temp < 0){
			neg++;
			temp *= -1;
		}
		sum += temp;
		mmin = min(mmin, temp);
	}
	if(neg%2)
		cout << sum - 2*mmin;
	else	cout << sum;
	return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
const int INF = 1 << 29;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int N, M, S, T;
vector<int> edge[100000];
int minDist[100000][3];

struct State {
  int pos, dist, ken;
  State(int p, int d, int k) : pos(p), dist(d), ken(k) {}
  bool operator<(const State &stt) const { return stt.dist < dist; }
};

int solve() {
  priority_queue<State> pq;
  pq.push(State(S, 0, 0));
  minDist[S][0] = 0;

  while (!pq.empty()) {
    State stt = pq.top();
    pq.pop();

    rep(i, edge[stt.pos].size()) {
      int to = edge[stt.pos][i];
      int nk = (stt.ken + 1) % 3;
      int dist = stt.dist;
      if(nk == 0) dist++;
      if (minDist[to][nk] > dist) {
        minDist[to][nk] = dist;
        if (nk == 0 && to == T) {
          return minDist[to][nk];
        }
        pq.push(State(to, minDist[to][nk], nk));
      }
    }
  }
  return -1;
}

int main() {
  cin >> N >> M;
  rep(i, M) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    edge[u].eb(v);
  }
  cin >> S >> T;
  S--;
  T--;

  rep(i, N) rep(j, 3) minDist[i][j] = INF;

  cout << solve() << endl;
}


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

#include <string>
using namespace std;
#define rep(i, n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define pb push_back

int main(int argc, char const* argv[]){

	string s;


	cin>>s;

	int n=s.size();
	for(int i=s.size()-2;i>0;i-=2){
		s.erase(s.size()-2);
		// cout<<s<<endl;
		// cout<<i<<endl;

		string str1=s.substr(0,i/2);
		string str2=s.substr(i/2,i);

		if(str1==str2){
			cout<<str1.size()*2<<endl;
			return 0;
		}
		// cout<<str1<<" "<<str2<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n;
	ll m;
	scanf("%lld%lld",&n,&m);
	ll res=-1;
	if(n==m)
	{
		res=n+1;
	}
	for(ll i=2;i*i<=n;i++)
	{	
		ll ans=0;
		ll k=n;
		while(k)
		{
			ans+=(k%i);
			k/=i;
		}
		if(ans==m)
		{
			res=i;
			break;
		}
	}
//	printf("**%lld**\n",res);

		ll o=n-m;
		int o2=sqrt(o);
	//	printf("%lld\n",o);
		for(ll i=1;i*i<=o;i++)
		{
			if(o%i==0)
			{
				ll k=o/i+1;
			//	printf("%lld\n",k);
				ll x=n/k;
				ll y=n%k;
				if(x==k)
				{
					x=1;
				}
				if(x+y==m)
				{
					if(res!=-1)
					{
						res=min(res,k);
					}
					else
					{
						res=k;
					}
				}
			}
		//	printf("**%lld**\n",res);
		}

	printf("%lld\n",res);
	return 0;
}

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

int n;
int a[100005];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		a[i]--;
	}
	int cnt=0;
	for(int i=0;i<n;i++){
		if(a[i]==i && a[i+1]==i){
			cnt++;
			swap(a[i],a[i+1]);
		}else if(a[i]==i){
			cnt++;
			swap(a[i],a[i+1]);
		}
	}
	printf("%d\n",cnt);
	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<unsigned int> A(N+5);
    int fl;

    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }

    sort(A.rbegin(), A.rend());

    for (int i = 0; i < N-1; i++)
    {
        if (A.at(i) == A.at(i+1))
        {
            fl++;
        }
    }
    if (fl) cout << "NO";
    else cout << "YES";
}

Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int32_t main(){
	boost;
	//freopen(".in","r",stdin);
	string p;
	cin>>p;
	if(p=="ABC")cout<<"ARC";
	else cout<<"ABC";
	return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 3648
N = int(input())
A = list(map(int, input().split()))

ans = 1000000000

for i in range(N):
    ctr = 0
    
    while A[i]%2 != 1:
        ctr += 1
        A[i] /= 2
    ans = min(ctr, ans)

print(ans)


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Break Number
            var n = int.Parse(Console.ReadLine());

            Console.WriteLine(GetMaxNumberMultipleOf2(n));
        }

        static int GetMaxNumberMultipleOf2(int n)
        {
            int lastNum = 1;
            int i = 1;

            while (true)
            {
                int newNum = (int)Math.Pow(2, i);

                if (newNum > n)
                {
                    return lastNum;
                }
                else
                {
                    lastNum = newNum;
                    i++;
                }
            }
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  string s;
  cin >> s;
  map<char,int> mp;
  rep(i,s.size()){
    mp[s.at(i)]++;
  }
  for(char c = 'a'; c<='z'; c++){
    if(mp[c]==0){
      cout << c << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}


Measured memory_bytes: 512
N = int(input())
List=list(map(int,input().split()))
List.sort()
a = List[0]
b = List.count(a)
c = List[N//3]
d = List.count(c)
e = List[2*N//3]
f = List.count(e)
if a == c and c == e:
    if a == 0 and b == N:
        print('Yes')
    else:
        print('No')
elif c == e:
    if a == 0  and N % 3 == 0 and b == N // 3 and d == 2 * N // 3:
        print('Yes')
    else:
        print('No')
elif N % 3 == 0 and b == N // 3 and d == N //3 and f == N //3 and a ^ e == c : 
    print('Yes')
else:
    print('No')


Measured memory_bytes: 60784
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll l;
	string s, t;
	cin>>l>>s>>t;
	if(s+t>t+s) swap(s, t);
	int n = s.size(), m = t.size();
	int g = __gcd(n, m);
	int a = n/g, b = m/g, c = l/g;
	string res; 
	rep(i, c+1){
		if((c-(a*i))%b==0){
			int j = (c-(a*i))/b;
			rep(k, i) res+=s;
			rep(k, j) res+=t;
			break;
		}
	}
	for(int i = c/a; i >= 0; i--){
		if((c-(a*i))%b==0){
			int j = (c-(a*i))/b;
			string res2;
			rep(k, i) res2+=s;
			rep(k, j) res2+=t;
			if(res2<res) res = res2;
			break;
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1544
#include <iostream>
using namespace std;
int HW(int H,int W);
int main(void){
int h,w,x;
while(1){
cin>>h>>w;
if(h==0 && w==0){
break;
}
x=HW(h,w);
cout<<endl;
}
return 0;
}

int HW(int H,int W){
int i=1;
for(int a=0;a<H;a++){
int ii=1;
    for(int b=0;b<W;b++){
    if(i%2==1){
        if(ii%2==1){
            cout<<"#";
        }else{
            cout<<".";
        }
    }else{
        if(ii%2==1){
            cout<<".";
        }else{
            cout<<"#";
        }
    }
    ii+=1;
    }
i+=1;
cout<<endl;
}
return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

/**
 * @author yoshizaki
 *
 */
public class Main {
 
    public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        double target = scanner.nextDouble();
    //    long start = System.currentTimeMillis(); 
        long ans = calc(target);
    //    long end = System.currentTimeMillis(); 
    //    long time = end - start;
        System.out.println(ans );
    //    System.out.println(time +"ms");
    }
    
    /**
     * @param target
     * @return
     */
    public static  long calc(double target){
        long targetNum = (long)target;
        long divNum = 0;
        divNum = (long) Math.sqrt(target);
        if (targetNum % divNum != 0 ) 
        {
            for (long i = divNum; i > 0; i--) 
            {
                if (targetNum % i == 0 ) 
                {
                    divNum = i;
                    break;
                }
            }
        }
        return (targetNum / divNum) + divNum -2;
    }
}

Measured memory_bytes: 25172
#include <stdio.h>
int main(void){
    // Here your code !
    int n,a[100001],i,t,s=1;
    int sum = 0;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(i=1;i<=n;i++){
        t=a[s];
        s=t;
        sum += 1;
        if(s==2){
            break;
        }
        else if(i == n){
            sum = -1;
        }
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e17;
ll mod = 1000000007;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

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

  ll a, b;
  cin >> a >> b;

  ll k = (a + b);
  if (k & 1)
    cout << "IMPOSSIBLE" << en;
  else
    cout << k / 2 << en;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int N = scanner.nextInt();
        if (Integer.toString(N).contains("7")) {
            System.out.println("Yes");
            return;
        }

        System.out.println("No");
    }
}


Measured memory_bytes: 35848
n = gets.to_i
s = n.to_s

if s[-1] == "2" || s[-1] == "4" || s[-1] == "5" || s[-1] == "7" || s[-1] == "9"
  puts "hon"
elsif s[-1] == "0" || s[-1] == "1" || s[-1] == "6" || s[-1] == "8"
  puts "pon"
else
  puts "bon"
end

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

const int MOD = (int)1e9+7;

int main(){
  string S;
  cin >> S;

  int r=0;
  int b=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='0')  r++;
    else  b++;
  }
  cout << min(r,b)*2 << endl;

  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        StringBuilder count=new StringBuilder();
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        for (int i=1;i<=n;i++){
            int x=i;
            if (x%3==0){
                count.append(" "+i);
                continue;}
            do{
                if(x%10==3){
                    count.append(" "+i);
                    break;}
                x/=10;
            }while(x!=0);
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 28360
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 
ll N;
ll NN;

int main(){

    cin >> N;
    int B[N];

    rep(i,N-1) cin >> B[i];

    int ans=0;

    ans+=B[0];
    for( int i = 0 ; i <N-1-1 ; i++ ){
        ans+=min(B[i],B[i+1]);
    }
    ans+=B[N-2];
    cout << ans << endl;

}


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

int main() {
  int N, Y;
  scanf("%d %d", &N, &Y);

  Y /= 1000;
  for (int x=0; x<=N; ++x)
    for (int y=0; y<=N; ++y) {
      int z=Y-(10*x+5*y);
      if (z >= 0 && x+y+z == N)
        return !printf("%d %d %d\n", x, y, z);
    }

  printf("-1 -1 -1\n");
}


Measured memory_bytes: 128
import sys
l = []
for line in sys.stdin:
    l.append(line)

for i in range(len(l)):
    numl = l[i].split(' ')
    a = int(numl[0])
    b = int(numl[1])
    sum = a + b
    digitstr = "{0}".format(sum)
    print(len(digitstr))

Measured memory_bytes: 7528
#coding: utf-8
N, T = map(int, input().split())
tans = T
cans = 10 ** 5
for i in range(N):
    c, t = map(int, input().split())
    if c <= cans and t <= T:
        cans, tans = c, t
print(cans if cans < 10**5 else "TLE")

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        int N = 0;
        int K = 0;
        boolean[] a = new boolean[10];
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String[] elems = br.readLine().split(" ");
            N = Integer.parseInt(elems[0]);
            K = Integer.parseInt(elems[1]);
            elems = br.readLine().split(" ");
            for (int i = 0; i < K; i++) {
                a[Integer.parseInt(elems[i])] = true;
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        int ans = N;
        String ansStr;
        while (true) {
            ansStr = Integer.toString(ans);
            boolean flg = true;
            for (int i = 0; i < ansStr.length(); i++) {
                flg &= !a[ansStr.charAt(i) - '0'];
            }
            if (flg)
                break;
            ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 24404
#include<iostream>
#include<vector>
using namespace std;
 
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    vector<long long>b(n+1);
    for(int i=0; i < n; i++){
        cin >> a[i];
        b[a[i]]++;
    }
    long long t=0;
    for(int i=0; i < n+1; i++)t += b[i]*(b[i]-1)/2;
    for(int i=0; i < n; i++){
        cout << t - (b[a[i]]*(b[a[i]]-1)/2) + (b[a[i]]-1)*(b[a[i]]-2)/2 << endl;
    }
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <set>

#define int long long

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)

#define INF (3e15)

using namespace std;

int N, M;
int a[200005];
int b[200005];

signed main()
{
    cin >> N >> M;

    set<int> sa;
    set<int> sb;
    REP(i, M)
    {
        int a, b;
        cin >> a >> b;
        if (a == 1) sb.insert(b);
        if (b == N) sa.insert(a);
    }

    for (int a : sa)
    {
        if (sb.find(a) != sb.end())
        {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;

    return 0;
}


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

int N;
int A[210];

int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> A[i];

  int res = 0;

  while (true) {
    bool exist_odd = false;
    for (int i = 0; i < N; ++i) {
      if (A[i] % 2 != 0) exist_odd = true;
    }

    if (exist_odd) break;

    for (int i = 0; i < N; ++i) {
      A[i] /= 2;
    }
    ++res;
  }

  cout << res << endl;
}

Measured memory_bytes: 256
n, dimen = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]

def isSqrt(n):
    m = 0
    while m * m <= n:
        if m * m == n:
            return True
        m += 1
    return False

ret = 0
for p1 in range(n - 1):
    for p2 in range(p1 + 1, n):
        dist = 0
        for i in range(dimen):
            dist += abs(a[p1][i] - a[p2][i]) ** 2
        if isSqrt(dist):
            ret += 1
print(ret)

Measured memory_bytes: 3064
#include<iostream>
#include <bits/stdc++.h>
#include<vector>
#include<cstdlib>

using namespace std;

int main(){
char c;

  cin>>c;
  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o')cout<<"vowel"<<endl;
  else cout<<"consonant"<<endl;

  return 0;
  }


Measured memory_bytes: 256
n=int(input())
cnt=0
num=list(map(int,input().split()))

for i in range(len(num)):
	min=i
	for j in range(i,len(num)):
		if num[j]<num[min]:
			min=j
	if num[i]>num[min]:
		num[i],num[min]=num[min],num[i]
		cnt+=1
print(' '.join(list(map(str,num))))
print(cnt)
	
				
			
			



Measured memory_bytes: 5604
import Data.List
import Control.Monad

main :: IO ()
main = do
    n <- getLine >>= return . (read :: String -> Int)
    h <- getLine >>= return . map (read :: String -> Int) . words
    putStrLn . show . snd $ foldl' (\(a,b) -> \c -> (c,if a <= c then b + c - a else b)) (0,0) h

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define MOD3 1000000000
#define MOD2 998244353 
float PHI = 1.6180339;
const float  PI_F=3.14159265358979f;
#define MAX 1000 m
#define endl "\n"    
#define manhunt 32 
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define pi 3.1415926535897932384626433
//typedef long long float;
#define int long long
//#define double long double
typedef pair<int, int> pii;
//#define float unsigned long long
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define CHAR_SIZE 26 

int modpow(int x, int n, int m) { if (n == 0) return 1%m; long long u = modpow(x,n/2,m); u = (u*u)%m; if (n%2 == 1) u = (u*x)%m; return u; } 


int add(int x, int y,int m) 
{
	x += y;
	if (x >= m) return x - m;
	return x;
}
int sub(int x, int y) 
{
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
int inv(int a, int m = MOD2)
{
	return modpow(a, m - 2, m);
}
int mul(int a, int b,int m) 
{
	return (long long) a * b % m;
}


int nCrModp(int n, int r, int p) 
{ 
    int C[r+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1; 
    for (int i = 1; i <= n; i++) 
    { 
        for (int j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
} 

bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
    if(a.first==b.first)
    return a.second<b.second;
      return (a.first > b.first); 
       //return (a.first-a.second)>(b.first-b.second);
}

vector<int> z_function(string &s)
{
	int n=s.size();
	vector<int> z(n);
	for(int i=1,l=0,r=0;i<n;i++)
	{
		if(i<=r)
			z[i]=min(r-i+1, z[i-l]);
		while(i+z[i]<n && s[z[i]]==s[i+z[i]])
			z[i]++;
		if(i+z[i]-1>r)
			l=i, r=i+z[i]-1;
	}
	return z;
}

bool isprime(int n) 
{ 
    if (n <= 1)  return false; 
  
    for (int i=2; i*i<=n; i++) 
        if (n%i == 0) 
            return false; 
  
    return true; 
}

void SieveOfEratosthenes(int n, bool isPrime[]) 
{ 
    isPrime[0] = isPrime[1] = false; 
    for (int i=2; i<=n; i++) 
        isPrime[i] = true; 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (isPrime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                isPrime[i] = false; 
        } 
    } 
}


int32_t main()
{
    /* freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout); */
    FAST
    cout << fixed << setprecision(16);
    
    int n;
    cin>>n;
    string s;
    cin>>s;
    int l=0,r=n-1;
    int cnt=0;
    while(l<=r)
    {
        if(s[l]=='W' && s[r]=='R')
        {
            swap(s[l],s[r]);
            ++cnt;
            ++l;
            --r;
        }
        if(s[l]=='R' && s[r]=='W')
        {
            ++l;
            --r;
        }
        else if(s[l]=='W' && s[r]=='W')
        {
            --r;
        }
        else if(s[l]=='R' && s[r]=='R')
        {
            ++l;
        }
    }
    //cout<<s<<endl;
    cout<<cnt<<endl;
    
    return 0;
}





Measured memory_bytes: 3756
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
    int n;
    vector<pair<int, int> > point;
    int cnt = 0;
    while(cin >> n,n){
    cnt++;
    point.resize(n);
    rep(i,n){
        cin >> point[i].first >> point[i].second;
    }
    double ans_s = 0;
    for(int i=0; i<point.size(); i++){
        int idx = (i+1)%point.size();
        ans_s += 0.5*((point[idx].first-point[i].first)
                    *(point[i].second+point[idx].second));
    }
    cout << cnt << " " << fixed << setprecision(1) << ans_s << endl;
    }
    return 0;
}


Measured memory_bytes: 3280
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ggdem=b;i<ggdem;++i)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

vector<ll> g[202];
ll vis[202];
ll c[202];

void bfs(ll v) {
	queue<int>q;
	vis[v]=1;
	q.push(v);
	c[v]=1;
	while(q.size()) {
		int t=q.front(); q.pop();
		//cout<<t+1<<" ";
		for(int i:g[t]) {
			if(!vis[i]) {
				vis[i]=1;
				q.push(i);
				c[i]=c[t]+1;
			}else{
				if((c[i]&1)==(c[t]&1)){
					cout<<-1; exit(0);
				}
			}
		}
	}
}

int main(){FIN;
	ll n; cin>>n;
	//char t[n][n];
	fore(i,0,n){
		fore(j,0,n){
			char es; cin>>es;
			if(es=='1'){
				g[i].pb(j);
			}
		}
	}
	ll res=0;
	bfs(0);
	fore(i,0,n){
		mset(vis,0);
		mset(c,0);
		bfs(i);
		ll maxi=0;
		fore(i,0,n)maxi=max(maxi,c[i]);
		ll br=0;
		fore(j,0,n){
			for(auto jj:g[j]){
				if(abs(c[jj]-c[j])!=1){
					br++; break;
				}
			}
			if(br)break;
		}
		if(!br){
			res=max(res,maxi);
		}
	}
	if(res==0){
		cout<<-1;
	}else cout<<res;
	return 0;
}

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

namespace TYC
{
	typedef long long ll;
	const int N = 25005, M = 405, mod = 1e9 + 7;

	int n, m, K, A[N], C[M], F[2][M];

	inline int read()
	{
		int x = 0, f = 0, ch = getchar();
		while (!isdigit(ch))
			f |= (ch == '-'), ch = getchar();
		while (isdigit(ch))
			x = x * 10 + ch - '0', ch = getchar();
		return f ? -x : x;
	}

	inline bool check1()
	{
		if (m < K)
			return false;
		for (int i = 1; i + K - 1 <= m; i++)
		{
			memset(C, 0, sizeof(C));
			bool flag = false;
			for (int j = 0; j < K; j++)
				flag |= ++C[A[i + j]] > 1;
			if (!flag)
				return true;
		}
		return false;
	}

	inline bool check2()
	{
		if (m > K)
			return false;
		for (int i = 1; i <= m; i++)
			if (++C[A[i]] > 1)
				return false;
		return true;
	}

	inline int qpow(int x, int tim)
	{
		int ans = 1;
		for (; tim; tim >>= 1, x = int((ll)x * x % mod))
			if (tim & 1)
				ans = int((ll)ans * x % mod);
		return ans;
	}

	inline int calc(const int mx)
	{
		static int G[2][M], SF[M], SG[M];
		memset(F, 0, sizeof(F));
		memset(G, 0, sizeof(G));
		memset(SF, 0, sizeof(SF));
		memset(SG, 0, sizeof(SG));
		F[1][1] = K;
		G[1][1] = m == 1 ? K : 0;	
		for (int i = mx - 1; i; i--)
		{
			SF[i] = (SF[i] + F[1][i]) % mod;
			SG[i] = (SG[i] + G[1][i]) % mod;
		}
		for (int i = 2, d = i & 1; i <= n; i++, d ^= 1)
			for (int j = mx - 1; j; j--)
			{
				F[d][j] = int(((ll)F[d ^ 1][j - 1] * (K - j + 1) % mod + SF[j]) % mod);
				G[d][j] = int(((ll)G[d ^ 1][j - 1] * (K - j + 1) % mod + SG[j]) % mod);
				if (j >= m)
					G[d][j] = (G[d][j] + F[d][j]) % mod;
				SF[j] = (F[d][j] + SF[j + 1]) % mod;
				SG[j] = (G[d][j] + SG[j + 1]) % mod;
			}
		return SG[1];
	}

	void solve2()
	{
		int ans = (calc(K + 1) - calc(K) + mod) % mod;
		int t = 1;
		for (int i = K - m + 1; i <= K; i++)
			t = int((ll)t * i % mod);
		printf("%d\n", int((ll)ans * qpow(t, mod - 2) % mod));
	}

	void get_dp(const int x, int *sum)
	{
		static int S[M];
		memset(S, 0, sizeof(S));
		memset(F, 0, sizeof(F));
		F[x & 1][x] = sum[x] = 1;
		fill(S + 1, S + x + 1, 1);
		for (int i = x + 1, d = i & 1; i <= n; i++, d ^= 1)
		{
			for (int j = K - 1; j; j--)
			{
				F[d][j] = int(((ll)F[d ^ 1][j - 1] * (K - j + 1) % mod + S[j]) % mod);
				S[j] = (F[d][j] + S[j + 1]) % mod;
			}
			sum[i] = S[1];
		}
	}
	
	int solve3()
	{
		static int f[N], g[N];
		int pre = 0, suf = 0;
		memset(C, 0, sizeof(int[K + 1]));
		while (pre < m && C[A[pre + 1]] == 0)
			C[A[++pre]]++;
		get_dp(pre, f);
		memset(C, 0, sizeof(int[K + 1]));
		while (suf < m && C[A[m - suf]] == 0)
			C[A[m - suf]]++, suf++;
		get_dp(suf, g);
		int ans = 0;
		for (int i = 0; i + m <= n; i++)
			ans = int((ans + (ll)f[i + pre] * g[n - m - i + suf] % mod) % mod);
		return ans;
	}

	void work()
	{
		n = read(), K = read(), m = read();
		for (int i = 1; i <= m; i++)
			A[i] = read();
		int tot = int((ll)qpow(K, n - m) * (n - m + 1) % mod);
		
		if (check1())
			printf("%d\n", tot);
		else if (check2())
			solve2();
		else
			printf("%d\n", (tot - solve3() + mod) % mod);
	}
}

int main()
{
	TYC::work();
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>
#include <queue>
#include <list>

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define INF 1e9
#define vint vector<int>

using namespace std;
typedef long long  ll;

const long long MOD = 1e9+7;

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i = 1; i<=n; i++){
        if(i%3 != 0 and i%5 != 0){
            ans += i;
        }
    }

    p(ans);
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  ll n,k,i;
  cin >> n >> k;
  if(k==0){
    cout << n*n << endl;
    return 0;
  }
  ll ans=(n-k)*(n-k+1)/2;
  for(i=k+1;i<=n;i++){
    ans+=(n-i+1)/i*(i-k);
    if((n-i+1)%i>=k){
      ll x=(n-i+1)%i;
      ans+=(x-k);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3584
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int INF=1e9;
int ans=INF;
int n;
int a[20][2],p[20],t[20],b[20][2];
void jud(int s){
	for(int i=0;i<n;++i){
		if(s&(1<<i)) p[i]=1;
		else p[i]=0;
		t[i]=a[i][p[i]];
		b[i][0]=a[i][0];
		b[i][1]=a[i][1];
	}
	sort(t,t+n);
	bool flag=0;
	int val=0;
	for(int i=0;i<n;++i){
		int j=i;
		for(;j<n;++j)
			if(b[j][p[j]]==t[i]&&((j-i)&1)==p[j]) break;
		if(j>=n) {
			flag=1;
			break;
		}
		for(;j>i;--j){
			swap(b[j][0],b[j-1][1]);
			swap(b[j][1],b[j-1][0]);
			swap(p[j],p[j-1]);
			p[j]^=1;p[j-1]^=1;
			++val;
		}
	}
	if(flag) return;
	ans=min(ans,val);
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;++i) scanf("%d",&a[i][0]);
	for(int i=0;i<n;++i) scanf("%d",&a[i][1]);
	for(int s=0;s<(1<<n);++s) jud(s);
	printf("%d\n",ans==INF?-1:ans);
	return 0;
} 

Measured memory_bytes: 256
N = int(input())
A = [list(map(int, input().split())) for i in range(2)]
sum_list = [[] for j in range(2)]
goukei_list =[]
goukei = 0

for i in range(2):
  for j in range(N):
    if i == 0:
      goukei += A[i][j]
    else:
      goukei += A[i][N-j-1]
    sum_list[i].append(goukei)
  goukei = 0

for i in range(N):
  goukei_list.append(sum_list[0][i] + sum_list[1][N-i-1])
  
print(max(goukei_list))


Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i, N) for (int i = 0; i < N; ++i)
typedef long long int LL;

LL N, M, p[112345], A[112345], B[112345], C[112345];
LL cou[112345], ans;

int main()
{
	in >> N >> M;
	rep(i, M) { in >> p[i]; }
	rep(i, N - 1) { in >> A[i] >> B[i] >> C[i]; }

	rep(i, M - 1)
	{
		LL from = p[i], to = p[i + 1];
		if (from > to) { std::swap(from, to); }
		++cou[from], --cou[to];
	}
	rep(i, N + 1) { cou[i + 1] += cou[i]; }
	rep(i, N - 1) { ans += std::min(A[i] * cou[i + 1], B[i] * cou[i + 1] + C[i]); }

	out << ans << std::endl;
	return 0;
}

Measured memory_bytes: 7020
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#include <cstring>
#include <cmath>
#include <string>
#include <numeric>

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  string S, T;
  cin >> S >> T;//添え字は0~N-1
  int NS = S.length();
  int NT = T.length();
  
  //main
  vector<vector<int>> memo(NS+10, vector<int>(NT+10, 0)); //Sを左からi(0~N)文字見た&j(0~N)文字見た時の共通部分列。
  
  for(int i=0; i<NS+1; i++){
    for(int j=0; j<NT+1; j++){
      if(i <= NS-1 && j <= NT-1) if(S[i]==T[j]) chmax(memo[i+1][j+1], memo[i][j]+1);
      //memo[i+1][j+1]を埋める→Sのi+1文字目・j文字目まで見る→S[i]
      chmax(memo[i+1][j],memo[i][j]);
      chmax(memo[i][j+1],memo[i][j]);
      //片方の文字列だけを見ても共通部分列は増えない。→memoの縦横の遷移では共通部分列は増えない。
    }
  }
  
  // output
  //output(memo[NS][NT]);
  
  string ans = "";
  int i = NS;
  int j = NT;
  while(i>=1 && j>=1){ //縦横の遷移で値が変化しないため、&&でも|でも良い。
    if(memo[i-1][j] == memo[i][j]){//縦の遷移
      i--;
    }else if(memo[i][j-1] == memo[i][j]){//横の遷移
      j--;
    }else{//斜めの遷移でしか値は変化しないため、斜めの遷移で値が変化した→縦と横の値と異なる。
      ans = S[i-1]+ans;//memoのi文字め→S[i-1]
      i--;
      j--;
    }
  }
  output(ans);
  return 0;
}

Measured memory_bytes: 35712
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

const ll MOD = 1000000007LL;

ll pow_mod(ll num, ll pow) {
    ll prod = 1;
    num %= MOD;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % MOD;
        num = num * num % MOD;
        pow >>= 1;
    }
    return prod;
}

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

    ll n, a;
    cin >> n;

    ll n_pow = 1LL;
    for (ll i = 1; i <= n; i++) (n_pow *= i) %= MOD;

    ll sm[n];
    sm[0] = 0;
    for (ll i = 1; i < n; i++) {
        sm[i] = n_pow * pow_mod(i+1, MOD-2) % MOD;
        (sm[i] += sm[i-1]) %= MOD;
    }

    ll ans = 0LL;
    for (int i = 0; i < n; i++) {
        cin >> a;
        (ans += n_pow * a % MOD) %= MOD;
        (ans += (sm[i] + sm[n-i-1]) % MOD * a % MOD) %= MOD;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
N = int(input())
ans_list = ["a"]  # 生成元の初期状態 (N = 1 の答え)
alphabet = [chr(ord("a") + i) for i in range(N)]  # 使用するアルファベット

for i in range(N - 1):
    ans_list = [ans + x for ans in ans_list for x in alphabet[:len(set(ans)) + 1]]

for ans in ans_list:
    print(ans)

Measured memory_bytes: 12980
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
using ll = long long;
const ll M = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
using namespace std;
using vl = vector<ll>;
using pll =  pair<ll,ll>;

ll power(ll x,ll y){
    if(y==0)
    return 1;
    ll res=power(x,y/2);
    res=(res*res)%M;
    if(y&(ll)1)
    res=(res*x)%M;
    return res;
}
//ll temp[100001];
void solve(){
    int n;cin>>n;
    map<string,int> m;
    string s;int ma=0;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        m[s]++;
        ma=max(ma,m[s]);
    }
    vector<string> v;
    for(auto it=m.begin();it!=m.end();it++)
    {
        if(it->S==ma)
        v.pb(it->F);
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++)
    cout<<v[i]<<endl;
}
 
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // temp[0]=0;
    // for(int i=1;i<100001;i++)
    // {
    //     temp[i]=i/2+i%2;
    //     temp[i]=(temp[i]+temp[i-1])%M;
    // }
    // int t;
    // cin>>t;
    // while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 25840
X, N = [int(i) for i in input().split()]
if N == 0:
    print(X)
else:
    Ps = set([int(i) for i in input().split()])

    # 間違い。なぜ...？？？
    if X not in Ps:
        print(X)
        exit(0)

    # print(f'{X} {sorted(Ps)}')
    diff = 0
    while True:
        a = X - diff
        if a not in Ps:
            print(a)
            break
        a = X + diff
        if a not in Ps:
            print(a)
            break
        diff += 1

Measured memory_bytes: 9088
#include <iostream>
#include<string>
using namespace std;
int main()
{
	int n;
	string x;
	cin>>n;
	cin>>x;
	int counter = 1;
	for (int i = 1; i < n; i++)
	{
		if (x[i] != x[i - 1])
			counter++;
	}
	cout << counter<<endl;
}


Measured memory_bytes: 512
import java.util.*;

class Main{
public static void main(String args[]){
   Scanner sc = new Scanner(System.in);
   String  S = sc.next();
   int N = S.length();
   String  S2 = S.substring(0,(N-1)/2);
   String  S3 = S.substring(((N+3)/2)-1,N); 
   if (isPalindrome(S)&&isPalindrome(S2)&&isPalindrome(S3)){
     System.out.printf("Yes");
   }else{
     System.out.printf("No");
   } 
}
  static boolean isPalindrome (String s) {
	int n = s.length();
	for (int i=0; i<n/2; i++) {
		if (s.charAt(i)!=s.charAt(n-i-1)) {return false;}
	}
	return true;
}
}


Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define pb push_back
#define mp make_pair
#define all(a)  (a).begin(),(a).end()
#define dwn(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	ll a, b, k;
	cin >> a >> b >> k;
	for (int i = 0; i < k; i++) {
		if (i % 2 == 0) {
			if(a % 2 != 0) a--;
			b += a / 2;
			a /= 2;
		}
		else {
			if(b % 2 != 0) b--;
			a += b / 2;
			b /= 2;
		}
	}
	cout << a << " " << b << endl;
}

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

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define vi vector<int>
#define vs vector<string>
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
using namespace std;

int main(){
  long long n,k;
  cin>>n>>k;
  vector<long long> ar(10000000, 0); 
  rep(i, n){
    long long a,b;
    cin>>a>>b;
    ar[--a] += b;
  }

  long long r = 0;
  while(k > 0){
    // cout<<k<<endl;
    k -= ar[r];
    r ++;
  }
  cout<<r<<endl;
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG
 
int main(){
    int h,w,m;
    cin>>h>>w>>m;
    vector<int> retu[h];
    vector<int> gyou[w];
    map<P,bool> mp;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        retu[a].push_back(b);
        gyou[b].push_back(a);
        mp[P{a,b}]=1;
    }

    int retusize=0;
    int gyousize=0;

    rep(i,h){
        int p=retu[i].size();
        retusize=max(p,retusize);
    }
    rep(i,w){
        int p=gyou[i].size();
        gyousize=max(p,gyousize);
    }

    int ans=gyousize+retusize;
    vector<int> maxretu;
    vector<int> maxgyou;
    rep(i,h){
        if(retu[i].size()==retusize) maxretu.push_back(i);
    }
    rep(i,w){
        if(gyou[i].size()==gyousize) maxgyou.push_back(i);
    }
    bool judge=false;
    int mr=maxretu.size();
    int mg=maxgyou.size();
    rep(i,mr){
        rep(j,mg){
            int p=maxretu[i];
            int q=maxgyou[j];
            if(!mp[P{p,q}]) judge=true;
            if(judge) break;
        }
        if(judge) break;
    }
    if(!judge) ans--;
    cout<<ans<<endl;
}

Measured memory_bytes: 59004
#include <bits/stdc++.h>
#define lon long long
using namespace std;
const int maxn=1e5 + 10;

typedef long long ll;

#define mod(x) ((x) % MOD)

#define eps 1e-6

int a[1111][1111];

int main() {
   // ios_base::sync_with_stdio(false);

    ll a,c,b,x,y; cin>>a>>b>>c>>x>>y;
    ll res = 10000000000000LL;
    for (int i = 0; i < 4*(max(x,y)); i++) {
        ll xx = x - i / 2;
        ll yy = y - i / 2;
        if (xx < 0) xx = 0;
        if (yy < 0) yy = 0;
        res = min(res,xx *1ll * a + yy*1ll * b + i *1ll* c);
    }
    cout<<res<<endl;
    return 0;
}











/*


5 3
ADBBC
spiderman
ADBAC
niconico
BDXBC
ekstieks
ACBBC
*/


Measured memory_bytes: 256