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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int mod;

inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
	int x = 1 % mod;
	while(b){
		if(b & 1) x = mul(x, a);
		a = mul(a, a);
		b >>= 1;
	}
	return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

const int N = 306;
int C[N][N], f[N][N], g[N][N];

int main(){
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll ans = a - b;
	if(k & 1) ans *= -1;
	cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100050];
int b[100050];
int main()
{
	int A, B, M,x,y,c;
	cin >> A >> B >> M;
	int mina=999999,minb=999999;
	for(int i=1;i<=A;i++)
	{
		cin >> a[i];
		if(mina>a[i]) mina=a[i];
	}
	for(int i=1;i<=B;i++)
	{
		cin >> b[i];
		if(minb>b[i]) minb=b[i];
	}
	int res=mina+minb;
	for(int i=1;i<=M;i++)
	{
		cin >>x>>y>>c;
		int ans=a[x]+b[y]-c;
		if(ans<res) res=ans;
	}
	cout<<res;
	return 0;
} 

Measured memory_bytes: 1024
n, m, x, y = map(int, input().split())
lst1 = list(map(int, input().split()))
lst2 = list(map(int, input().split()))
lst1.sort(reverse = True)
lst2.sort()
m1 = lst1[0] + 1
m2 = lst2[0]
judge = False
for i in range(m1, m2+1):
  if x < i:
    if i <= y:
      judge = True
if judge:
  print("No War")
else:
  print("War")

Measured memory_bytes: 3064
#include<cmath>
#include<cstring>
#include<cstdio>
#include<queue>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = (1 ? 1e9 + 7 : 998244353);
const int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };
ll a, b, c, d, e, f, n, T;




int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> a >> b;
	b *= b;
	f = 0;
	while (a--)
	{
		cin >> c >> d;
		e = c * c + d * d;
		if (e <= b)f++;
	}
	cout << f << endl;
}



Measured memory_bytes: 3648
#include <stdio.h>
#include <limits.h>

int main() {
  int n, m, max = 0, ans = 0;
  scanf("%d", &n);
  int h[n+1];
  h[n] = 0;
  for (size_t i = 0; i < n; i++) {
    scanf("%d", h+i);
    max = (max < h[i]) ? h[i] : max;
  }
  for (size_t j = 0; j < max; j++) {
    m = 0;
    for (size_t i = 0; i < n; i++) {
      if (h[i] != 0 && h[i+1] == 0) {
        m++;
        h[i]--;
      } else if (h[i] != 0 && h[i+1] != 0) {
        h[i]--;
      }
    }
    ans += m;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
c = [list(map(int, input().split())) for _ in range(3)]
x = c[1][0] - c[0][0]
y = c[2][0] - c[0][0]
for i in range(3):
    c[1][i] -= x
    c[2][i] -= y
if c[0] == c[1] == c[2]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
	static void Main(string[] args)
	{
      List<string> youso = new List<string>();
      string line = "";
      while((line=Console.ReadLine()) != null)
      {
        youso.Add(line.ToString());
      }
      /////////////////////////////////////////
      
      string answer;

      string[] indata = youso[0].Split(' ');
      youso.RemoveAt(0);
      int Ninzu = int.Parse(indata[0]);
      int Point = int.Parse(indata[1]);
      int SeikaiCnt = int.Parse(indata[2]);

      List<int> info = new List<int>();
      //初期化
      for (int i = 0; i < Ninzu; i++)
      {
        info.Add(Point - SeikaiCnt);
      }

      foreach (string s in youso)
      {
        int si = int.Parse(s);
        info[si - 1] = info[si - 1] + 1;
      }

      foreach (int i in info)
      {
        if (i <= 0)
        {
          answer = "No";
	      Console.WriteLine(answer);        
        }
        else
        {
          answer = "Yes";
	      Console.WriteLine(answer);        
        }
      }
	}
  
  
  
}


Measured memory_bytes: 25436
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
vector<ll>v(1e7+1,1);
void sieve(){
    for(ll i=2;i<1e7+1;i++){
        v[i]++;
        for(ll j=i*2;j<1e7+1;j+=i){
            v[j]++;
        }
    }
    return;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    sieve();
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=1;i<=n;i++){
        ans+=i*v[i];
    }
    cout<<ans;
    return 0;
}



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

#define MOD 998244353

int D[100005], A[100005];

long long power(long long N, long long expo)
{
    long long ans = 1;

    while(expo)
    {
        if(expo % 2)
            ans = ans * N % MOD;
        
        N = N * N % MOD;
        expo /= 2;
    }

    return ans;
}

int main() {

    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int N;
    cin >> N;

    int maxx = 0;

    for(int i=1; i<=N; i++)
    {
        cin >> D[i];

        A[ D[i] ]++;
        maxx = max(maxx, D[i]);
    }

    int flag = 0;

    for(int i=1; i<=maxx; i++)
        if(A[i] == 0)
            flag = 1;

    if(D[1] != 0 || A[0] != 1 || flag == 1)
    {
        cout << 0 << "\n";
        return 0;
    }

    long long ans = 1;

    for(int i=1; i<=maxx; i++)
        ans = ans * power(A[i-1], A[i]) % MOD;

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

Measured memory_bytes: 1024
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
M = []



for i in range(N):
    TMP = T - (H[i] * 0.006)
    if A >= 0:
        ABS = abs(TMP - A)
    else:
        ABS = abs(A - TMP)
    M.append(ABS)
            
MIN = min(M)
for i in range(len(M)):
    if MIN == M[i]:
        print(i+1)

Measured memory_bytes: 62272
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
	ll ans = 0;
	string s;
	cin >> s;

	for(int i=0;i<(1<<(s.length()-1));i++) {
		ll tmp = 0;
		for(int j=0;j<s.length();j++) {
			tmp *= 10;
			tmp += s[j] - '0';
			if(((i>>j) & 1)) {
				ans += tmp;
				tmp = 0;
			}
		}
		ans += tmp;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
h.append(0)
ans = 0

while True:
    counter = 0
    for i in range(n):
        if h[i] == 0:
            counter += 1
            continue
        elif h[i] != 0 and h[i + 1] == 0:
            h[i] -= 1
            ans += 1
        else:
            h[i] -= 1
    if counter == n:
        break

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>


/* 
*    coder :: ATUL_PANDEY_2608
*        >>> INDIA <<<
*/
using namespace std;
using namespace __gnu_pbds;

// #define  part ..
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end() 
#define mod 1000000007
//#define maxx 200006
#define ll long long 
#define quick    ios_base::sync_with_stdio(NULL),cin.tie(0);
#define listll vector< long long > 
#define listi vector< int> 
#define pii   pair<int , int> 
#define pll pair<long long , long long > 
#define minheap priority_queue<long long , vector< long long >, greater<long long > >
#define rep(i,a,b) for(int i=a;i<b;i++)
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


template < class T > using oset = tree< T , null_type, less  < T  > , rb_tree_tag , tree_order_statistics_node_update > ;


// end of #define 

// define globals ...
const int maxx = 2e5+26;

//write function from here ...







int Main(){

 string s;
 cin>>s;
 
 int cnt =0 ;
  int ans = 0;
  char c ='S'; 
  for(auto ch : s)
  {
	  
	  if( ch == 'R' && ch == c){
		  cnt++;
		  
		  continue;
		  
	  }
	  
	  if(ch == 'R' ){
		  
		  c ='R';
		  ans = max(ans,cnt);
		  cnt=1;
		  continue;
		  
		  
	  }
	  
	  ans  = max(ans,cnt);
	  cnt =0 ;
	  c= 'S';
	  
	  
  }
  
  cout<<max(cnt,ans)<<endl;



return 0;

}

















int main(){
 quick;
int t =1; 
//cin>>t;
while(t-- )
 Main();

 return 0;


}


Measured memory_bytes: 3652
import java.io.*;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader =
            new BufferedReader(new InputStreamReader(System.in));

        String[] line = reader.readLine().split(" ");
        int inputA = Integer.parseInt(line[0]);
        int inputB = Integer.parseInt(line[1]);
        int inputC = Integer.parseInt(line[2]);

        if ((inputA >= inputB) || (inputB >= inputC)) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 24404
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) { lhs = rhs; return true; }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) { lhs = rhs; return true; }
  return false;
}

struct range {
  struct itr {
    int64_t i;
    constexpr itr(int64_t i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int64_t operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int64_t l_, int64_t r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

struct revrange {
  struct itr {
    int64_t i;
    constexpr itr(int64_t i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int64_t operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int64_t l_, int64_t r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

constexpr i32 inf32 = (i32(1) << 30) - 1;
constexpr i64 inf64 = (i64(1) << 62) - 1;

int main() {
  u64 a;
  std::cin >> a;
  std::string s;
  std::cin >> s;
  u32 b = 0;
  for (auto c: s) {
    if (c == '.') {
      continue;
    }
    b = b * 10 + (c - '0');
  }
  std::cout << a * b / 100 << '\n';
  return 0;
}


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

using namespace std;

const int INF = 1 << 29;
typedef pair<int, int> P;

int n;
int dp[10][10][10] = {0};
int balls[10];

int dfs(int left, int right, int num)
{
	if(num == 10) return 1;
	if(dp[left][right][num]) return dp[left][right][num];
	int ret1 = 0, ret2 = 0;
	if(left <= balls[num]) ret1 = dfs(balls[num], right, num+1);
	if(right <= balls[num] && ret1 != 1) ret2 = dfs(left, balls[num], num+1);
	return dp[left][right][num] = (ret1 == 1 || ret2 == 1 ? 1 : -1);
}

int main(void)
{
	while(cin >> n && n)
	{
		for (int i = 0; i < n; i++)
		{
			memset(dp, 0, sizeof(dp));
			for (int j = 0; j < 10; j++)
			{
				int x; cin >> x; x--;
				balls[j] = x;
			}
			cout << (dfs(0,0,0) == 1?"YES":"NO")<< endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1156
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size))scanf("%d",&(name)[i])
#define MOD 1000000007

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=n;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    GI(N);
    string S=get_str();
    vector<int> black(N);
    vector<int> white(N);
    ll ans=N;
    int lb=0,lw=0;
    FOR(i,N){
        if(S[i]=='#')lb++;
        if(S[i]=='.')lw++;
        black[i]=lb;
        white[i]=lw;
    }
    FOR(i,N){
        ll ans2=black[i]+lw-white[i];//debug(i,ans2,black[i],white[i]);
        if(ans>ans2)ans=ans2;
    }
    if(ans>white[N-1])ans=white[N-1];
    print(ans);
    return 0;
}

Measured memory_bytes: 2180
//be naame khodaa

#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <cstdio>
#include <algorithm>
#include <set>
#include <cassert>
#include <iomanip>
#include <cstring>
#include <sstream>
#define fi first
#define se second
#define rep(i, x, n) for (int i = x; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> VI;

const int maxn = 100 * 1000 + 5;

int a[3][maxn];
ll dp[3][maxn], acc[3][maxn];

int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 0; i < 3; i++){
		for (int j = 0; j < n; j++)
			cin >> a[i][j];
		sort (a[i], a[i] + n);
	}
	for (int j = n-1; j >= 0; j--){
		dp[2][j] = 1;
		acc[2][j] = acc[2][j+1] + dp[2][j];
	}
	for (int i = 1; i >= 0; i--){
		int p = n;
		for (int j = n-1; j >= 0; j--){
			while (p && a[i+1][p-1] > a[i][j])
				p--;
			dp[i][j] = acc[i+1][p];
			acc[i][j] = acc[i][j+1] + dp[i][j];
		}
	}
	cout << acc[0][0] << endl;
	return 0;
}

Measured memory_bytes: 6144
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
    private static final StringBuilder builder = new StringBuilder();
    public static void main(String[] args) {
        int n = readInt(), x = readInt(), t = readInt();
        int m = (n / x) * t;
        if (n % x != 0) m += t;
        System.out.print(m);
    }

    private static void read() {
        builder.setLength(0);
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) {
                    break;
                } else {
                    builder.appendCodePoint(b);
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static int readInt() {
        read();
        return Integer.parseInt(builder.toString());
    }

    private static int readInt(int radix) {
        read();
        return Integer.parseInt(builder.toString(), radix);
    }

    private static long readLong() {
        read();
        return Long.parseLong(builder.toString());
    }

    private static long readLong(int radix) {
        read();
        return Long.parseLong(builder.toString(), radix);
    }

    private static BigInteger readBigInteger() {
        read();
        return new BigInteger(builder.toString());
    }

    private static BigInteger readBigInteger(int radix) {
        read();
        return new BigInteger(builder.toString(), radix);
    }

    private static double readDouble() {
        read();
        return Double.parseDouble(builder.toString());
    }

    private static BigDecimal readBigDecimal() {
        read();
        return new BigDecimal(builder.toString());
    }

    private static float readFloat() {
        read();
        return Float.parseFloat(builder.toString());
    }

    private static void skipLine() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == '\n' || b == -1) {
                    break;
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static void skip() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) break;
            } catch (IOException e) {
                break;
            }
        }
    }

}


Measured memory_bytes: 32252
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin >>s;
  bool flag =false;
  for (int i  = 0 ; i < s.length() -1 ;i++)
    if (s[i] == s[i+1])
      flag =true;
  if (flag)
    cout<<"Bad"<<endl;
  else
    cout<<"Good"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lim 100000
#define mod 1000000007
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define sd(n) scanf("%lld",&n)
 ll c[1000],s[1000],f[1000];
 ll n;
 ll getans(ll i,ll t)
 {   if(i==n-1)
  return t;
 // cout<<t<<" l l "<<endl;
  if(t<=s[i])
  {
    t=s[i]+c[i];
    return getans(i+1,t);
  }
  t-=s[i];
  ll x=ceil(t*1.0/f[i]);
  t=s[i]+x*f[i]+c[i];
  return getans(i+1,t);

 }
int main()
{

 cin>>n;

 for(ll i=0;i<n;i++)
  cin>>c[i]>>s[i]>>f[i];
vector<ll>ans;
  for(int i=n-2;i>=0;i--)
    ans.push_back(getans(i,0));
  reverse(ans.begin(),ans.end());
  ans.push_back(0);
  for(int i=0;i<ans.size();i++)
    cout<<ans[i]<<endl;
}

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

using namespace std;

#ifdef WIN32
	#define I64 "%I64d"
#else
	#define I64 "%lld"
#endif

typedef long long ll;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(s) s.begin(), s.end()
#define sz(s) (int(s.size()))
#define fname "a"
#define MAXN 200002

int n, m;
int d[MAXN];

int main()
{
	#ifdef LOCAL
	freopen(fname".in", "r", stdin);
	freopen(fname".out", "w", stdout);
	#endif

	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++i) {
		int v1, v2;
		scanf("%d%d", &v1, &v2);
		--v1, --v2;
		++d[v1];
		++d[v2];
	}

	for (int i = 0; i < n; ++i)
		if (d[i] & 1) {
			puts("NO");
			return 0;
		}
	puts("YES");

	return 0;
}


Measured memory_bytes: 640
n=input()

if n[-1] == '2' or n[-1] == '4' or n[-1] == '5' or n[-1] == '7' or n[-1] == '9':
  print('hon')
elif n[-1] == '0' or n[-1] == '1' or n[-1] == '6' or n[-1] == '8':
  print('pon')
else:
  print('bon')

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

int main(){
    ll n;
    cin>>n;
    ll time=0;
    pair<ll,ll> num[n];
    for (int i = 0; i < n; ++i) {
        ll a,b;
        cin>>a>>b;
        num[i].first=b;
        num[i].second=a;
    }
    sort(num,num+n);
    for (int j = 0; j < n; ++j) {
        time+=num[j].second;
        if(time>num[j].first){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string.h>
using namespace std;
char s[400005];
int main()
{
	cin >> s;
	if (strlen(s) % 2 == 1)
	{
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < strlen(s); i++)
	{
		if (i % 2 == 0)
		{
			if (s[i] == 'h')
			{
				continue;
			}
			else
			{
				cout << "No" << endl;
				return 0;
			}
		}
		else
		{
			if (s[i] == 'i')
			{
				continue;
			}
			else
			{
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

int minPower[10];
int c[10][10];

int minTemp;

int H;
int W;

int *A;

void rec(const vector<int> used, int now, int before, int firstNumber)
{
    if (before == 1)
    {
        minTemp = (minTemp < now) ? minTemp : now;
    }
    else
    {
        if (firstNumber > before)
        {
            rec(used, now + minPower[before], 1, firstNumber);
        }
        else
        {
            for (int i = 0; i < used.size(); i++)
            {

                vector<int> cop = used;
                int temp = cop[i];
                cop.erase(cop.begin() + i);
                rec(cop, now + c[before][temp], temp, firstNumber);
            }
        }
    }
}

int main()
{
    cin >> H;
    cin >> W;

    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            cin >> c[i][j];
        }
    }

    A = new int[H * W];

    for (int i = 0; i < H * W; i++)
    {
        cin >> A[i];
        if (A[i] == -1)
        {
            A[i] = 1;
        }
    }

    for (int i = 0; i < 10; i++)
    {
        vector<int> dataset = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
        minTemp = 100000000;
        rec(dataset, 0, i, i);
        minPower[i] = minTemp;
    }

    int result = 0;

    for (int i = 0; i < H * W; i++)
    {
        result += minPower[A[i]];
    }

    cout << result;
    return 0;
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
string X; cin >> X;
 REP(i,X.size()) {
   if(X[i] == '?') {
     X[i] = 'D';
   }
 }
  cout << X;
}

Measured memory_bytes: 3772
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <sstream>

using namespace std;
const double PI = acos(-1.0);
const double EPS = 1e-11;
typedef long long ll;
const ll MOD = 1000000007;
const int N = 100000 + 7;
typedef unsigned long long ull;

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
void fast() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
}

/*                What if i lose? only losers think like that. But the answer is you will lose rate.                */

int n, m, kk, cnt, ans;
vector<vector<char>> grid;
vector<int> row, col, reRows;


int main() {
#ifndef ONLINE_JUDGE
    freopen("Input.txt", "r", stdin);
    freopen("Output.txt", "w", stdout);
#endif
    fast();

    cin >> n >> m >> kk;

    grid.resize(n, vector<char>(m));
    row.resize(n);
    col.resize(m);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> grid[i][j];
            row[i] += grid[i][j] == '#';
            col[j] += grid[i][j] == '#';
            cnt += (grid[i][j] == '#');
        }
    }

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

        int removedRow = 0;
        int k = 0;
        reRows.clear();
        while ((1 << k) <= i) {
            if ((1 << k) & i) {
                removedRow += row[k];
                reRows.push_back(k);
            }
            k++;
        }

        for (int j = 0; j < (1 << m); j++) {
            int all = removedRow;


            k = 0;

            while ((1 << k) <= j) {
                if ((1 << k) & j) {
                    all += col[k];
                    for (int z = 0; z < reRows.size(); z++) {
                        if (grid[reRows[z]][k] == '#')
                            all--;
                    }
                }
                k++;
            }


            if (cnt - all == kk) {
                ans++;
            }
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 3616
L,R=map(int, input().split())
 
if R-L+1>=2019:
  print(0)
else:
  L %= 2019
  R %= 2019
  if L<R: 
    m = 2019
    for i in range(L,R+1):
      for j in range(i+1,R+1):
        m = min(m, (i*j)%2019)
    print(m)
  else:
    print(0)

Measured memory_bytes: 3060
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
   
//#include <x86intrin.h>
#include <bits/stdc++.h>   
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)1e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int k, d[N], ans = mod;
queue <int> q;

inline int mult (int a, int b) {
   return 1ll * a * b % k;
}

inline int add (int a, int b) {
   a += b;
   if (a >= k) a -= k;
   return a;
}

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> k;
   for (int i = 1; i < k; i ++) d[i] = mod;
   q.push (0);
   while (sz (q)) {
      int v = q.front ();
      q.pop (); 
      int new_v1 = mult (v, 10);
      int new_v2 = add (v, 1);
      if (new_v1 == 0 && d[v] > 0) ans = min (ans, d[v]);
      if (new_v2 == 0 && d[v] + 1 > 0) ans = min (ans, d[v] + 1);
      if (d[new_v1] > d[v]) {
         d[new_v1] = d[v];
         q.push (new_v1);
      }
      if (d[new_v2] > d[v] + 1) {
         d[new_v2] = d[v] + 1;
         q.push (new_v2);
      }
   }
   cout << ans;
}

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
                          

Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<cmath>
#include<bitset>
int main(){
    int t;
    while(std::cin>>t){
    std::bitset<11> value(t);
    std::string s=value.to_string();
    for(int i=0;i<s.size();i++){if(s[0]=='0') s.erase(s.begin()); else break;}
    int num=std::stoi(s);
        for(int i=0;i<s.size();i++){if(num%10){std::cout<<pow(2,(double)(i)); if(pow(2,i)*2<t)std::cout<<" ";}num/=10;}
    std::cout<<std::endl;
    }
}

Measured memory_bytes: 3392
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int W = scan.nextInt();
        int H = scan.nextInt();
        int N = scan.nextInt();
        int[][] map = new int[H+1][W+1];
        int min_x = 0;
        int max_x = W;
        int min_y = 0;
        int max_y = H;
        for (int i = 0; i < N; i++) {
            int x = scan.nextInt();
            int y = scan.nextInt();
            int a = scan.nextInt();
            if (a == 1) {
                min_x = Math.max(min_x, x);
            }
            if (a == 2) {
                max_x = Math.min(max_x, x);
            }
            if (a == 3) {
                min_y = Math.max(min_y, y);
            }
            if (a == 4) {
                max_y = Math.min(max_y, y);
            }
        }
        if (max_x <= min_x || max_y <= min_y) {
            System.out.println(0);
        } else {
            System.out.println((max_x - min_x) * (max_y - min_y));
        }
    }
}


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

int main() {
  int n;
  vector<int> v;
  vector<int> c;
  int tmp;
  cin >> n;
  for (int i=0; i<n; i++) {
    cin >> tmp;
    v.push_back(tmp);
  }
  for (int i=0; i<n; i++) {
    cin >> tmp;
    c.push_back(tmp);
  }
  
  int ans = 0;
  for (int i=0; i<n; i++) {
    if(v[i]>c[i]) ans += v[i]-c[i];
  }
  
  cout << ans <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  ll n = 0;
  cin >> n;
  if(n == 0){
    cout << 2 << endl;
    return 0;
  }else if(n == 1){
    cout << 1 << endl;
    return 0;
  }
  ll l0 = 2;
  ll l1 = 1;
  ll l = 0;
  for(ll i = 2; i <= n; i ++){
    l = l0 + l1;
    l0 = l1;
    l1 = l;
  }
  cout << l << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
  char S[100000];
  scanf("%s", S);

  int N = strlen(S);
  int K;
  scanf("%d", &K);

  for (int i = 0; i < N; i++) {
    if('z'-S[i]+1 <= K && S[i]  != 'a'){
      K -= 'z'-S[i]+1;
      S[i] = 'a';
    }
  }
  K %= 26;
  S[N-1] += K;

  printf("%s\n", S);

  return 0;
}

Measured memory_bytes: 384
n = int(input())
a = [input() for i in range(n)]
z = [0]*4
for i in range(n):
  if a[i] == 'AC':
    z[0] += 1
  elif a[i] == 'WA':
    z[1] += 1
  elif a[i] == 'TLE':
    z[2] += 1
  elif a[i] == 'RE':
    z[3] += 1
    
print('AC','x', str(z[0]))
print('WA','x', str(z[1]))
print('TLE','x', str(z[2]))
print('RE','x', str(z[3]))

Measured memory_bytes: 16224
#include <cstdio>
#include <vector>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < int(n); ++(i))
#define repeat_reverse(i, n) for (int i = (n)-1; (i) >= 0; --(i))
#define repeat_from_reverse(i, m, n) for (int i = (n)-1; (i) >= int(m); --(i))
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define unittest_name_helper(counter) unittest_ ## counter
#define unittest_name(counter) unittest_name_helper(counter)
#define unittest __attribute__((constructor)) void unittest_name(__COUNTER__) ()
using ll = long long;
using namespace std;
template <class T> inline void setmax(T & a, T const & b) { a = max(a, b); }
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

int main() {
    int n, m; scanf("%d%d", &n, &m);
    vector<set<int> > g(n);
    repeat (i, m) {
        int a, b; scanf("%d%d", &a, &b); -- a; -- b;
        g[a].insert(b);
        g[b].insert(a);
    }
    bool result = false;
    for (int k : g[0]) {
        if (g[k].count(n - 1)) {
            result = true;
            break;
        }
    }
    printf("%s\n", result ? "POSSIBLE" : "IMPOSSIBLE");
    return 0;
}


Measured memory_bytes: 28416
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] weather = {"Sunny", "Cloudy", "Rainy"};
        String choose = scanner.next();
        Black(weather, choose);

    }
    public static void Black(String[] arr, String weather){
        int size = arr.length;
        for(int i = 0; i < size; i++){

            if(weather.equals(arr[i])){
                if(i == size - 1)
                    System.out.println(arr[0]);
                else System.out.println(arr[i + 1]);
            }

        }
    }
}

Measured memory_bytes: 21076
import math 
X, N = map(int,input().split())
d = int(999)
d1 = int()
ans = int(999)
if 0 < N:
    P = list(map(int,input().split()))
    for i in range(999):
        if P.count(i) == 0:
            d1 = abs(X-i)
            if d1 < d and 0 <= d1:
                d = d1
                ans = i
    print(ans)
else:
    print(X)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define CHMAX(a,b) a = max(a,b)
#define CHMIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define newline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;
const VI dx = {1, 0, -1, 0};
const VI dy = {0, 1, 0, -1};

int main()
{
    int n, ans;
    REP(i,5) {
        cin>>n;
        if (n == 0) ans = i+1;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
constexpr ll INF = LLONG_MAX;
constexpr double PI = M_PI;
 
int main(){
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
 
  long long r;
  cin >> r;
  cout << r*r << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
int MAX = 7368791;
int main(){
    int n,m;
    bool f[MAX+1];
    while(1){
        cin>>m>>n;
        if(m+n==0)break;
        REP(i,MAX+1)f[i]=false;
        for(int i=m;;i++){
            if(!f[i]){
                if(n==0){
                    cout<<i<<endl;
                    break;
                }else{
                    n--;
                    for(int j=i;j<=MAX;j+=i){
                        f[j]=true;
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 10216
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdlib>
using namespace std;
int arr[100000]={0};
int main() {
    unsigned long long x,y=0, a=0,d=0;
    cin>>x;

    for(int i=1;i<=130;i++){
        for(int w=1;w<=130;w++){
            for(int y=1;y<=130;y++){
                if(((i*i)+(w*w)+(y*y)+(i*w)+(i*y)+(y*w))<=x){
                    arr[((i*i)+(w*w)+(y*y)+(i*w)+(i*y)+(y*w))]++;

                }

            }

        }
    }
    for(int i=1;i<=x;i++){
        cout<<arr[i]<<"\n";
    }
return 0 ;
}

Measured memory_bytes: 3468
#include <bits/stdc++.h>
#include <boost/format.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/optional.hpp>

#ifdef DEBUG
#include "libs/debug.cpp"
#define DEBUG 1
#else
#define DEBUG 0
#endif

#define rep(i, n) repr((i), 0, (n))
#define repr(i, a, t) reps((i), (a), (t), 1)
#define reps(i, a, t, s) for (long long (i) = (a); (i) < (long long)(t); (i) += (s))
#define rrep(i, n) rrepr((i), (n) - 1, 0)
#define rrepr(i, a, t) rreps((i), (a), (t), 1)
#define rreps(i, a, t, s) for (long long (i) = (a); (i) >= (long long)(t); (i) -= (s))
#define each(v, c) for (auto &&(v) : (c))
#define all(c) (c).begin(), (c).end()

using namespace std;
namespace mp = boost::multiprecision;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ml = mp::cpp_int;
template<typename T>
using optional = boost::optional<T>;
const auto none = boost::none;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;

int main() {
  cout << fixed << setprecision(10);
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ifstream ifs;
  if (DEBUG) {
    ifs.open("src/_in.txt");
    cin.rdbuf(ifs.rdbuf());
  }

  ll N;
  cin >> N;
  string S;
  cin >> S;

  unordered_map<char, ll> counts(0);
  rep (i, 26) {
    counts['a' + i] = 1;
  }
  rep (i, N) {
    counts[S[i]]++;
  }

  ll ans = 1;
  each (cnt, counts) {
    ans *= cnt.second;
    ans %= MOD;
  }
  ans += MOD - 1;
  ans %= MOD;
  cout << ans << "\n";
}

Measured memory_bytes: 512
pchk=0
gchk=0
win=0
lose=0
for i in `fold -1`
do
	if [ $pchk -lt $gchk ]
	then
		if [ "$i" = "g" ]
		then
			pchk=$((pchk + 1))
			win=$((win + 1))
		else
			pchk=$((pchk + 1))
		fi
	else
		if [ "$i" = "p" ]
		then
			gchk=$((gchk + 1))
			lose=$((lose + 1))
		else
			gchk=$((gchk + 1))
		fi
	fi
done
echo $((win - lose))


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    int l = 0, r = N;
    while (r-l > 1) {
        int c = (l+r)/2;
        map<int, int> mp;
        for (int i = 1; i < N; i++) {
            if (A[i-1] >= A[i]) {
                if (c == 1) {
                    mp[0] = 1;
                    break;
                }
                int t = A[i];
                mp[t]++;
                auto it = mp.upper_bound(t);
                mp.erase(it, mp.end());
                while (t > 0 && mp[t] == c) {
                    mp[t] = 0;
                    mp[t-1]++;
                    t--;
                }
            }
            if (mp[0] > 0) break;
        }
        if (mp[0] == 0) r = c;
        else l = c;
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;

int main()
{
	double x1, x2, x3, x4, y1, y2, y3, y4, n;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		if (fabs((y2 - y1) * (x4 - x3) - (y4 - y3) * (x2 - x1)) < 0.0000000001) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}


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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> v(N);
    REP(i, N) {
        cin >> v[i];
    }
    sort(ALL(v), greater<int>());
    int res = 0;
    REP(i, K) {
        res += v[i];
    }
    cout << res << endl;
    return 0;
}



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

using ll = long long;
using P = pair<int, int>;

const int MAX = 1e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int N, M;
int p[MAX], y[MAX];
vector<P> vv;
int cnt[MAX];
map<P, int> mp;

string f(ll n) {
  string s = to_string(n);
  while (s.size() < 6) {
    s = '0' + s;
  }
  return s;
}

int binary_search(vector<int> v, int key) {
    int left = 0, right = (int)v.size() - 1; // 配列 a の左端と右端
    while (right >= left) {
        int mid = left + (right - left) / 2; // 区間の真ん中
        if (v[mid] == key) return mid;
        else if (v[mid] > key) right = mid - 1;
        else if (v[mid] < key) left = mid + 1;
    }
    return -1;
}

int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) scanf("%d %d", p + i, y + i);

  for (int i = 0; i < M; i++) {
    vv.push_back(P(y[i], p[i]));
  }
  sort(vv.begin(), vv.end());

  for (int i = 0; i < M; i++) {
    P tmp = P(vv[i].second, vv[i].first);
    mp[tmp] = cnt[vv[i].second] + 1;
    cnt[vv[i].second]++;
  }

  for (int i = 0; i < M; i++) {
    P tmp = P(p[i], y[i]);
    cout << f(p[i]) << f(mp[tmp]) << endl;
  }

  return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}


int main(){
  int N; cin >> N;
  int ans = 0;
  for (int i = 0; i < N; i++){
    int A; cin >> A;
    while (A % 2 == 0){
      ans++; A /= 2;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3640
N = int(input())
A = [[0] * (1+N) for _ in xrange(1+N)]
def solve(l, r, id):
    if l == r:  return
    mid = (l+r) / 2
    for i in xrange(l, mid+1):
        for j in xrange(mid+1, r+1):
            A[i][j] = str(id)
    solve(l, mid, id+1)
    solve(mid+1, r, id+1)
solve(1, N, 1)
for i in xrange(1, N):
    print(' '.join(A[i][i+1: N+1]))

Measured memory_bytes: 4868
/*input
1900
*/
#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 2;

int mm(int x) {
  x %= 1000;
  if (x < 0) x += 1000;
  return x;
}

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

  int n; cin >> n; cout << mm(1000 - n) << endl;

  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <vector>
#include <cmath>

int main(void){
    std::string a,b,c;
    std::cin >> a >> b >> c;
    std::cout << a[0] << b[1] << c[2];
    return 0;
}


Measured memory_bytes: 256
n,k = gets.chomp.split(" ").map { |e| e.to_i }
a = gets.chomp.split(" ").map { |e| e.to_i }

head_sum = 0
body_sum = a[0,k].inject { |mem, var| mem+var }
tail_sum = a[k,n-k].select { |e| e>0 } .inject { |mem, var| mem+var }
tail_sum ||=0
ret = head_sum+[body_sum,0].max+tail_sum
(0..n-k-1).each { |i|
    leave = a[i]
    gett = a[i+k]
    head_sum += (leave > 0) ? leave : 0
    body_sum = body_sum - leave + gett
    tail_sum -= (gett > 0) ? gett : 0
    val = head_sum+[body_sum,0].max+tail_sum
    ret = val if val>ret
}
p ret

Measured memory_bytes: 13068
def conv_list(n):
    adj_matrix = []
    for _ in range(n):
        adj_list = input().split()
        adj_list = list(map(int, adj_list))
        adj_row = [0] * n
        if adj_list[1] > 0:
            for i in adj_list[2:]:
                adj_row[i - 1] = 1
        adj_matrix.append(adj_row)
    return adj_matrix


def main():
    n = int(input())
    adj_matrix = conv_list(n)
    for row in adj_matrix:
        print(" ".join(map(str, row)))


if __name__ == "__main__":
    main()



Measured memory_bytes: 5668
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i, j, n) for(int i=(j); 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; }

map<int, int> mp;
void prime_factorize(long long N) {
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        mp[a] += ex;
    }
    if (N != 1) mp[N]++;
}

int main() { 
   int n; cin >> n;
   fo(i, 1, n+1)prime_factorize(i);

   ll _74 = 0, _24 = 0, _14 = 0,_4 = 0, _2 = 0;
   for(auto m: mp){
       int num = m.second;
       if(num >=74) _74++;
       if(num >=24) _24++;
       if(num >=14) _14++;
       if(num >=4) _4++;
       if(num >=2) _2++;
   }
   ll res = 0;
   res += _74;
   res += _24 * (_2-1);
   res += _14 * (_4-1);
   res += (_4*(_4-1)/2)*(_2-2);

   cout << res << ln;
}






Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String x = br.readLine();
		String[] cut = x.split(" ");

		int a = Integer.parseInt(cut[0]);
		int b = Integer.parseInt(cut[1]);
		int c = Integer.parseInt(cut[2]);
		int d = Integer.parseInt(cut[3]);

		String ans = "=";

		if ((a + b) > (c + d)) {
			ans = "Left";
		} else if ((a + b) < (c + d)) {
			ans = "Right" + "";
		} else {
			ans = "Balanced";
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21076
n = int(input())
name = input()
length = len(name)
def check(ss):
  ind = 0
  end = len(ss)
  while ind < end:
    while ind < end and ss[ind] != name[0]:
      ind += 1
    
    for i in range(100):
      j1 = ind
      j2 = 0
      while j1 < end and j2 < length and ss[j1] == name[j2]:
        j1 += i
        j2 += 1
      if j2 == length:
        return True
    ind += 1
  return False

print(sum([check(input()) for _ in range(n)]))


Measured memory_bytes: 5616
n, q = gets.chomp.split(' ').map {|v| v.to_i}
s = gets.chomp

sum = Array.new(1 + s.length, 0)
for i in 1..s.length do
  v = sum[i - 1]
  if s[i - 1] == 'A' and s[i] == 'C'
    v += 1
  end
  sum[i] = v
end

q.times do |j|
  l, r = gets.chomp.split(' ').map {|v| v.to_i}
  v = sum[r - 1] - sum[l - 1]
  puts v
end


Measured memory_bytes: 3324