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

const ll mod = 1e9 + 7;
ll N;

ll modPow(ll n, ll p, ll mod) {
    n %= mod;
    if (p == 0)
        return 1;
    ll res = modPow(n * n % mod, p / 2, mod);
    if (p % 2 == 1)
        res = res * n % mod;
    return res;
}

struct combination {
    combination(ll Nmax, ll mod) {
        (this->MOD) = mod;
        (this->Nmax) = Nmax;
        factorial.resize(Nmax + 1, 1);
        inverse_factorial.resize(Nmax + 1, 1);
        init_factorial();
    }

    ll calc(ll n, ll r) {
        if (r < 0 || r > n)
            return 0;
        ll ret = (factorial[n] * inverse_factorial[r]) % MOD;
        ret = (ret * inverse_factorial[n - r]) % MOD;
        return ret;
    }

private:
    ll MOD, Nmax;
    vector<ll> factorial;
    vector<ll> inverse_factorial;

    void init_factorial() {
        for (ll i = 1; i <= Nmax; i++) {
            factorial[i] = (factorial[i - 1] * i) % MOD;
        }
        inverse_factorial[Nmax] = modPow(factorial[Nmax], MOD - 2, MOD);
        for (ll i = Nmax - 1; i >= 1; i--) {
            inverse_factorial[i] = (inverse_factorial[i + 1] * (i + 1)) % MOD;
        }
    }
};

void dfs1(int u, int p, vector<vector<int>>& tree, vector<ll>& child, vector<ll>& dp, combination& comb) {
    for (int v : tree[u]) {
        if (v == p)
            continue;
        dfs1(v, u, tree, child, dp, comb);
        child[u] += child[v] + 1;
        dp[u] = (dp[u] * dp[v]) % mod;
        dp[u] = (dp[u] * comb.calc(child[u], child[v] + 1)) % mod;
    }
}

void dfs2(int u, int p, ll pval, vector<ll>& ans, vector<vector<int>>& tree, vector<ll>& child, vector<ll>& dp, combination& comb) {
    ans[u] = dp[u];
    if (p != -1) {
        ans[u] = (((ans[u] * pval) % mod) * comb.calc(N - 1, N - child[u] - 1)) % mod;
    }
    for (int v : tree[u]) {
        if (v == p)
            continue;

        ll uval = (ans[u] * modPow(dp[v], mod - 2, mod)) % mod;
        uval = (uval * modPow(comb.calc(N - 1, child[v] + 1), mod - 2, mod)) % mod;
        dfs2(v, u, uval, ans, tree, child, dp, comb);
    }
}

int main() {
    cin >> N;
    vector<vector<int>> tree(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }

    vector<ll> child(N, 0);
    vector<ll> dp(N, 1);
    combination comb(N, mod);
    dfs1(0, -1, tree, child, dp, comb);

    vector<ll> ans(N, 1);
    dfs2(0, -1, -1, ans, tree, child, dp, comb);
    for (int i = 0; i < N; i++) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 21748
#include<iostream>
#include<cstdio>
using namespace std;
#define MOD 1000000007
#define MAX 3030
void add(int &x,int y){x+=y;if(x>=MOD)x-=MOD;}
int n,m,ans,f[MAX][MAX][2];
int main()
{
	scanf("%d%d",&n,&m);f[0][0][1]=1;
	for(int i=1;i<=n;++i)f[0][i][0]=1;
	for(int i=1;i<=m;++i)
		for(int j=0;j<=n;++j)
			for(int k=0;k<=1;++k)
			{
				if(j)add(f[i][j][k|(j==1)],f[i-1][j][k]),add(f[i][j-1][k|(j==1)],f[i-1][j][k]);
				if(n-j)add(f[i][j+1][k],f[i-1][j][k]),add(f[i][j][k],f[i-1][j][k]);
			}
	for(int i=0;i<=n;++i)add(ans,f[m][i][1]);
	printf("%d\n",ans);return 0;
}

Measured memory_bytes: 71936
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "random"
#include        "chrono"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#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"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          pb push_back
#define          N (int)2e5+5
#define          PI acos(-1.0)
#define          int long long 
#define          vi vector<int>
#define          mod 1000000007
#define          ld long double
#define          eb emplace_back
#define          mii map<int,int>
#define          vpii vector<pii>
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) x.rbegin(),x.rend()
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define          bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > 
OS ;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n,m,k,q;
string s;
vi adj[N];
int vis[N],par[N],a[N];

void go()
{
    cin >> k;
    int cn = 1;

    int now = 7%k;

    for( int i = 0; i <= 5*k; i++)
    {
        if( now == 0 )
        {
            cout << cn << endl;
            return;
        }
        cn += 1;
        // bug( now * 10 + 7);
        now = ( now  * 10 + 7 )%k;
    }

    cout << -1 << endl;
}

int32_t main()
{
    FAST;     
    int t=1; 
    // cin>>t;
    test(t) go();
}

 

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

#define         ull             unsigned long long
#define         ll              long long
#define         inf             INT_MAX
#define         pi              acos(-1.0)
#define         vi              vector<int>
#define         vl              vector<long long>
#define         pii             pair<int,int>
#define         pll             pair<long long,long long>
#define         mp              make_pair
#define         mii             map<int,int>
#define         mll             map<int,int>
#define         mli             multimap<int,int>
#define         mlll            multimap<long long,long long>
#define         msi             multiset<int>
#define         msl             multiset<long long>
#define         si              set<int>
#define         sl              set<long long>
#define         FOR(I,A,B)      for(int I = (A); I < (B); I++)
#define         rev(I,A,B)      for(int I = A ; I >= B ; I--)
#define         mem(a, v)       memset(a, v, sizeof (a))
#define         mod             1000000007
#define         all(a)          a.begin(),a.end()
#define         rall(a)         a.rbegin(),a.rend()
#define         ff              first
#define         ss              second
#define         arsort(ar,n)    sort(ar,ar+n);
#define         vsort(v)        sort(v.begin(),v.end())
#define         vrev(v)         reverse(v.begin(),v.end())
#define         arrev(ar,n)     reverse(ar,ar+n)
#define         pb              push_back
#define         popb            pop_back
#define         booster()       ios_base::sync_with_stdio(0); cin.tie(0);
#define         read(f)         freopen(f, "r", stdin)


#define         min3(a,b,c)     min(a,min(b,c))
#define         max3(a,b,c)     max(a,max(b,c))
#define         min4(a,b,c,d)   min(min(a,b),min(c,d))
#define         max4(a,b,c,d)   max(max(a,b),max(c,d))
#define         max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define         min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))


#define         bitCheck(a,k)     ((bool)(a&(1<<(k))))
#define         bitOff(a,k)       (a&(~(1<<(k))))
#define         bitOn(a,k)        (a|(1<<(k)))
#define         bitFlip(a,k)      (a^(1<<(k)))


int fx[] = {-1,+0,+1,+0,+1,+1,-1,-1,+0};
int fy[] = {+0,-1,+0,+1,+1,-1,+1,-1,+0};
int day[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

using namespace std;

bool comp(int x, int y) { return x > y; }

/*********************** let the play begin() ***********************************/

int main()
{
    booster()
    int n;
    cin>>n;
    int p,cum=0,maxi=-5,save;
    for(int i=1;i<=n;i++)
    {
        p=i;
        while(p%2==0)
        {
            p/=2;
            cum++;
        }
        if(cum>maxi)
        {
            maxi=cum;
            save=i;
        }
        cum=0;

    }
    cout<<save;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;
const int MAX_SIZE = 2e5 + 10;
int s[MAX_SIZE];


int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i = 1; i < n; i++) {
        int t;
        cin >> t;
        s[t]++;
    }
    for (int i = 1; i <= n; i++) {
        cout << s[i] << endl;
   }
    return 0;
}

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

int main(){
  int k,n;
  cin >> k >> n;
  int a[n];
  int p=0;
  int max=0;
  rep(i,n){
    cin >> a[i];
    if(a[i]-p > max)max=a[i]-p;
    p=a[i];
  }
  if(k-max > a[n-1]-a[0])cout << a[n-1]-a[0] << endl;
  else cout << k-max << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int n, a[112345], b[112345], c[112345];

    cin >> n;
    REP(i, n)
    cin >> a[i];
    REP(i, n)
    cin >> b[i];
    REP(i, n)
    cin >> c[i];

    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);

    ll res = 0;

    ll bc[112345];

    REP(i, n)
    {
        bc[i] = (c + n) - upper_bound(c, c + n, b[i]);
    }

    for (int i = n - 1; i >= 0; i--)
    {
        bc[i] += bc[i + 1];
    }

    REP(i, n)
    {
        res += bc[upper_bound(b, b + n, a[i]) - b];
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 2176
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int n;
  double t,a;
  cin>>n>>t>>a;
  
  vector<double> H(n);
  double x;
  rep(i,n){
    cin>>x;
    H[i]=abs(t-x*0.006-a);
  }
  
  double mi=1e9;
  int ans;
  rep(i,n){
    if(mi>H[i]){
      mi=H[i];
      ans=i;
    }
  }

  cout<<ans+1<<endl;
  
  return 0;
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leadinz zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
ll bin_pow(ll a,ll b,ll m)
{
    ll res=1;
    a%=m;
    while(b>0){
        if(b&1)res=res*a%m;
        b>>=1;
        a=a*a%m;
    }
    return res;
}
bool miller_rabin(ll d,ll n)
{
    ll a=2+rand()%(n-4);
    ll x=bin_pow(a,d,n);
    if(x==1 || x==n-1)return true;
    while(d!=n-1){
        x=(x*x)%n;
        d*=2;
        if(x==1)return false;
        if(x==n-1)return true;
    }
    return false;
}
bool prime(ll n,ll k)
{
    if(n==1 || n==4)return false;
    if(n<=3)return true;
    ll d=n-1;
    while(d%2==0)d/=2;
    for(int i=0;i<k;i++){
        if(!miller_rabin(d,n))return false;
    }
    return true;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    string k="";
    int n=s.size()+t.size();
    int id=0;
    for(int i=0;i<n;i++){
        if(i%2==0)k+=s[id++];
        else k+='#';
    }
    id=0;
    for(int i=0;i<n;i++){
        if(k[i]=='#')k[i]=t[id++];
        else continue;
    }
    cout<<k<<endl;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n, a[101010];
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		a[i]--;
	}
	
	int cnt = 0;
	for(int i = 0; i < n; i++){
		if(i == a[a[i]]) cnt++;
	}
	cout << cnt/2 << endl;
}

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


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define ld long double
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rloop(i,a,b) for(ll i=a;i>b;i--)
const ll inf=1e18+7;

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

ll n,sum=0;
cin>>n;
ll a[n];

	loop(i,0,n)cin>>a[i];
	ll dp[n][n];
	

	rloop(L,n-1,-1)
	{
		sum=0;
		loop(R,L,n)
		{
			dp[L][R]=inf;
			sum+=a[R];
		
			if(L==R)
			{
				dp[L][R]=0;
			}
			else 
			{
				
				loop(i,L,R)
				{
					dp[L][R]=min(dp[L][R],dp[L][i]+dp[i+1][R]+sum);
				}
			}
			
		
			
			
		}
		
	
	}
	
	cout<<dp[0][n-1];
}


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

const ll mod=1e9+7;

template<typename T>inline bool chmax(T &a,const T &b){if(a>=b){return false;}a=b;return true;}
template<typename T>inline bool chmin(T &a,const T &b){if(a<=b){return false;}a=b;return true;}

/*-------------------------------------------*/

int q,t,a,b;
ll y;

priority_queue<int>q1;
priority_queue<int,vector<int>,greater<int>>q2;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    cin>>q;
    while(q--){
        cin>>t;
        if(t==1){
            cin>>a>>b;
            y+=b;
            if(q1.size()<=q2.size()){
                q1.push(a);
                y-=a;
            }else{
                q2.push(a);
                y+=a;
            }
        }
        else{
            while(!q2.empty()&&q1.top()>q2.top()){
                y+=q1.top()*2;
                y-=q2.top()*2;
                t=q1.top();
                q1.pop();
                q1.push(q2.top());
                q2.pop();
                q2.push(t);
            }
            cout<<q1.top()<<" "<<((int)q1.size()-(int)q2.size())*q1.top()+y<<endl;
        }
    }
}

Measured memory_bytes: 3452
#include <stdio.h>

int main(void) {
	int a, b, d, r;
	double f;
	//数値を2つ入力
	scanf("%d %d", &a, &b);
	//結果を出力
	printf("%d %d %.5lf\n", a / b, a % b, (double)a / b);
	return 0;
}

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

class Fenwick_Tree{
private:
  vector< int64 > p;
public:
  Fenwick_Tree(int size){
    p.resize(size + 2, 0);
  }
  int64 sum(int x){
    int64 ret = 0;
    for(++x; x > 0; x -= x & -x) ret += p[x];
    return(ret);
  }
  void add( int k, int a){
    for( ++k; k < p.size(); k += k & -k) p[k] += a;
  }
};

int main() {
  int N, M;
  Fenwick_Tree BIT(1000004);

  cin >> N;
  vector< int > a(N);
  for(int i = 0; i < N; i++) {
    cin >> a[i];
    BIT.add(a[i], a[i]);
  } 
  cin >> M;
  vector< int64 > b(M), c(M);
  for(int i = 0; i < M; i++) cin >> b[i];
  for(int i = 0; i < M; i++) cin >> c[i];

  for(int i = 0; i < M; i++) {
    int64 get =  BIT.sum(b[i]);
    if(get >= c[i]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

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

string s;

int main() {
	cin >> s;
	
	int i, cnt = 0;
	for (i = 0; i < s.length(); i++) {
		if (s[i] == '1') cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

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

		int n = Integer.parseInt(br.readLine());

		String id[] = new String[n];
		int ac = 0;

		for (int i = 0; i < n; i++) {
			id[i] = br.readLine();
		}
		int m = Integer.parseInt(br.readLine());

		for (int i = 0; i < m; i++) {
			boolean flag = true;
			String action = br.readLine();
			for (int j = 0; j < n; j++) {
				if (action.equals(id[j])) {
					flag = false;
					if (ac % 2 == 0)
						System.out.println("Opened by " + action);
					else
						System.out.println("Closed by " + action);
					ac++;
				}
			}
			if (flag) {
				System.out.println("Unknown " + action);
			}
		}
	}
}



Measured memory_bytes: 25432
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int inf = 1000000;

ll mod_pow(ll n, ll x) {
  if (x == 0) {
    return 1;
  } else if (x % 2 == 0) {
    return mod_pow(n * n % mod, x /2) % mod;
  } else {
    return (n * (mod_pow(n * n % mod, x /2) % mod)) % mod;
  }
}

int main(int argc, const char * argv[]) {
  int N, A;
  cin >> N;
  
  vector<int> v(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> A;
    v[A]++;
  }
  
  bool ok = true;
  if (N % 2 == 0) {
    if (v[0] != 0) {
      ok = false;
    }
    for (int i = 1; i < N; i++) {
      if (v[i] != 0 && v[i] != 2) {
        ok = false;
      }
    }
    if (ok) {
      cout << mod_pow(2, N / 2) << endl;
      return 0;
    }
  } else {
    if (v[0] != 1) {
      ok = false;
    }
    for (int i = 1; i < N; i++) {
      if (v[i] != 0 && v[i] != 2) {
        ok = false;
      }
    }
    if (ok) {
      cout << mod_pow(2, (N - 1)/ 2) << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}


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

typedef long long ll;
typedef long double ld; 
typedef double db; 
typedef string str; 

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

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound 
#define ub upper_bound 

const int MOD = 998244353;
const ll INF = 1e18;
const int MX = 1000001;

str S;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> S;
    int a[sz(S)], ans[sz(S)];
    F0R(i, sz(S)) {
        a[i] = ans[i] = 0;
    }
    
    FOR(i, 1, sz(S)) {
        if (S[i] == 'L' && S[i - 1] == 'R') a[i] = i;
        else if (S[i] == 'L')a[i] = a[i - 1];
    }
    
    R0F(i, sz(S) - 1) {
        if (S[i] == 'R' && S[i + 1] == 'L') a[i] = i;
        else if (S[i] == 'R') a[i] = a[i + 1];
    }
        
    F0R(i, sz(S)) {
        if (S[i] == 'R') {
            int dist = a[i] - i;
            if (dist % 2) ans[a[i] + 1]++;
            else ans[a[i]]++;
        } else {
            int dist = i - a[i];
            if (dist % 2) ans[a[i] - 1]++;
            else ans[a[i]]++;
        }
    }
    
    trav(i, ans) cout << i << " ";
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 1488
#include<iostream>
#include<vector>
#include<algorithm>
#define REP(i,n) for(int i=0; i<n; i++)
using namespace std;
 
int main(){
    int a;
    vector<int> v;
    REP(i,3){
        cin >> a;
        v.push_back(a);
    }
 
    sort(v.begin(), v.end());
    
    if(v[2] == v[0]+v[1]) cout << "Yes";
    else cout << "No";
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;

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

  ll x1 = 0;
  for (ll i = 0; i < N; i++) {
    if (i % 2 == 0) {
      x1 += A[i];
    } else {
      x1 -= A[i];
    }
  }

  vector<ll> ans(N);
  ans[0] = x1;
  for (ll i = 1; i < N; i++) {
    ans[i] = 2 * A[i - 1] - ans[i - 1];
  }
  for (ll i = 0; i < N; i++) {
    if (i == N - 1) {
      cout << ans[i] << endl;
    } else {
      cout << ans[i] << " ";
    }
  }
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[3002][3002][4];
ll pre[3005][3005];
int r,c,k;
bool safe(int x,int y)
{
    if(x>r || y>c)
    {
        return 0;
    }
    else
    {
        return 1;
    }
}
ll fun(int px,int py,int mov)
{
    if(safe(px,py)==0)
    {
        return -1e18;
    }
    if(px==r && py==c)
    {
        if(mov>0)
        {
            return pre[px][py];
        }
        return 0;
    }
    if(dp[px][py][mov]!=-1)
        return dp[px][py][mov];
    ll res=0;
    if(mov>0)
    {
        res=max(res,pre[px][py]+fun(px+1,py,3));
        res=max(res,pre[px][py]+fun(px,py+1,mov-1));
        res=max(res,fun(px,py+1,mov));
    }
    else
    {
        res=max(res,fun(px+1,py,3));
        res=max(res,fun(px,py+1,mov));
    }
    return dp[px][py][mov]=res;
}
int main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>r>>c>>k;
    for(int i=1;i<=k;i++)
    {
        int x,y;
        ll val;
        cin>>x>>y>>val;
        pre[x][y]=val;
    }
    memset(dp,-1,sizeof dp);
    cout<<fun(1,1,3)<<endl;
    return 0;
}


Measured memory_bytes: 356148
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different 
Yours Faithfully
Shobhit Yadav */

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

ll N,T;
/*ll freq[200005];*/
void solve(){
	 /*memset(freq,0,sizeof(freq));*/
	char c;
	int val;
	cin>>c;
	val = (int)c;

	if(val>=65 && val<=90)
		cout<<'A'<<'\n';

	else if(val>=97)
		cout<<'a'<<'\n';
}



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

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;

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

	string a, b;
	cin >> a >> b;
	if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int A, B, C, K;
	cin >> A >> B >> C >> K;
	int *p = &A;
	if (*p < B) p = &B;
	if (*p < C)p = &C;
	REP(i, K) *p *= 2;
	cout << A + B + C << "\n";


	return 0;
}

Measured memory_bytes: 256
from collections import deque

n = int(input())
a = input().split()
d = deque([])
for i in range(n):
    if i % 2 == 0:
        d.append(a[i])  # 右に足す
    else:
        d.appendleft(a[i])  # 左に足す
if (n % 2) == 1:
    print(' '.join(list(d)[::-1]))
else:
    print(' '.join(list(d)))


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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

	int32 H, W, N;
	cin >> H >> W >> N;
	vector<PII> v(N);
	REP(i, v.size()){
		cin >> v[i].fs >> v[i].sc;
	}
	sort(all(v));
	int32 nowy = 1;
	int32 res = H;
	REP(i, N){
		if(i > 0){
			nowy += v[i].fs-v[i-1].fs-1;
		}else{
			nowy += v[i].fs-2;
		}
		if(nowy >= v[i].sc){
			res = min(res, v[i].fs-1);
		}
		if(nowy != v[i].sc-1) nowy++;
	}
	cout << res << endl;
}


Measured memory_bytes: 3456
counter = 0
S = input()
if S[0] == "A" :
    if S.count("A") == 1 :
        if "C" in S[2:-1] :
            if S.count("C") == 1 :
                t = S.lower()
                s = S.replace("A","a").replace("C","c")
                if s == t :
                    print("AC")
                    counter += 1
if counter == 0 :
    print("WA")
    

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    ll n,k;
    ll ans=n;
    cin >>n>>k;
    n=n%k;
    ans=min(n,abs(k-n));
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long C = sc.nextLong();
    long x[] = new long[N+1];
    long v[] = new long[N+1];
    for (int i=1; i<=N; i++) {
      x[i] = sc.nextLong();
      v[i] = sc.nextLong();
    }
    long vsum[] = new long[N+1];
    long revVsum[] = new long[N+1];
    vsum[0] = 0;
    revVsum[0] = 0;
    for (int i=0; i<N; i++) {
      vsum[i+1] = vsum[i] + v[i+1];
      revVsum[i+1] = revVsum[i] + v[N-i];
    }

    long cal[] = new long[N+1];
    cal[0] = 0;
    long cal2[] = new long[N+1];
    cal2[0] = 0;
    long revcal[] = new long[N+1];
    revcal[0] = 0;
    long revcal2[] = new long[N+1];
    revcal2[0] = 0;
    for (int i=1; i<=N; i++) {
      cal[i] = Math.max(cal[i-1], vsum[i] - x[i]);
      cal2[i] = Math.max(cal2[i-1], vsum[i] - 2*x[i]);
      revcal[i] = Math.max(revcal[i-1], revVsum[i] - (C - x[N-i+1]));
      revcal2[i] = Math.max(revcal2[i-1], revVsum[i] - 2*(C - x[N-i+1]));
    }
    long ans = 0;
    for (int i=0; i<=N; i++) {
      ans = Math.max(ans, cal2[i] + revcal[N-i]);
      ans = Math.max(ans, cal[i] + revcal2[N-i]);
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 93600
//
// Created by  on 28.01.2018.
//



#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cstdlib>
#include <bitset>
#include <cmath>
#include <iomanip>
//defines
#define f first
#define s second
#define ll long long
#define mp make_pair
#define pb push_back
#define ld long double

const int N = int(1e5+1), mod = int(1e9)  + 7;
//functions
using namespace std;


int main(){
//#ifndef ONLINE_JUDGE
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
//#endif
    int a,b,c,x;
    cin>>a>>b>>c>>x;
    int cnt = 0;
    for(int i = 0; i<=a; i++){
        for(int j = 0; j<=b; j++){
            for(int k = 0; k<=c; k++){
                if(i*500 + j*100 + k*50 == x){
                    cnt++;
                }
            }
        }
    }
    cout<<cnt;
    return 0;
}




Measured memory_bytes: 256
#include <algorithm>
#include <stdio.h>
#include <deque>
using namespace std;
using ll = long long;

class Int2 {
public:
	ll color, count;
	Int2(ll color, ll count):color(color),count(count){}
};
int main() {
	char s[200001];
	scanf("%s", s);

	deque<Int2> c;
	c.emplace_back(s[0], 1);
	for (int i = 1; s[i]; i++) {
		if (c.back().color == s[i])
			c.back().count++;
		else
			c.emplace_back(s[i], 1);
	}
	if (c.back().color == 'B')
		c.pop_back();
	if (c.front().color == 'W')
		c.pop_front();

	ll count = 0, carry = 0;
	for (int i = 0; i + 1 < c.size(); i += 2) {
		c[i].count += carry;
		count += c[i].count * c[i + 1].count;
		carry = c[i].count;
	}
	printf("%lld\n", count);
}

Measured memory_bytes: 2048
n = int(input())

count = 0

for _ in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        count += 1
    elif d1 != d2:
        count = 0
    if count == 3:
        break

if count == 3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9172
#include <iostream>

using namespace std;

typedef long long ll;

ll dp_prev[100000];
ll dp_cur[100000];
ll deq[100000];

ll N, M, K;

void copy_dp(){
    for(int i = 0; i < N; i++){
        dp_prev[i] = dp_cur[i];
    }
}

int main(){
    cin >> N >> M >> K;
    ll A[100000];
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        dp_cur[i] = A[i];
    }
    for(ll i = 1; i < K; i++){
        copy_dp();
        for(int j = 0; j < i; j++) dp_cur[j] = 0;
        int s = 0, t = 0;
        for(int j = 0; j < N-1; j++){
            while(s < t && dp_prev[deq[t-1]] <= dp_prev[j]) t--;
            deq[t++] = j;
            if(j+1 >= i) dp_cur[j+1] = (i+1)*A[j+1]+dp_prev[deq[s]];
            if(j-M+1 >= 0 && deq[s] == (j-M+1)) s++;
        }
    }
    ll ans = 0;
    for(int i = 0; i < N; i++) ans = max(ans, dp_cur[i]);
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll h, a;
    cin >> h >> a;
    cout << (h+a-1) / a << endl;
}


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

using pii = pair<int,int> ;
using pll = pair<long,long> ;
using umpii = unordered_map<int,int> ;
using mpii = map<int,int> ;

#define f first
#define s second

int32_t main(){
	int n ;
	cin >> n ;
	int a[n] ;
	for(int i = 0 ; i < n ; i++) cin >> a[i] ;
	sort(a,a+n) ;
	cout << a[n/2] - a[(n-1)/2]  ;
	return 0 ;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    int h, w;
    cin>>h>>w;
    vector<string> grid(h);
    cin>>grid;

    vi ho, ve;
    rep(i, h) {
        bool wh = true;
        rep(j, w) {
            if (grid[i][j] == '#') wh = false;
        }
        if (wh) ho.push_back(i);
    }
    rep(j, w) {
        bool wh = true;
        rep(i, h) {
            if (grid[i][j] == '#') wh = false;
        }
        if (wh) ve.push_back(j);
    }
    rep(i, h) {
        if (find(rng(ho), i) != ho.end()) continue;
        rep(j, w) {
            if (find(rng(ve), j) != ve.end()) continue;
            cout<<grid[i][j];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 256
#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

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(1e9 + 7)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
	
    int n;
    cin >> n;

    vector<int> vec(n);
    rep(i,n)
    	cin >> vec[i];

    vector<int> value(n, 0);
    int cnt = 0;

    repD(i,n,1) {
    	int sum = 0;
    	for(int j = i; j <= n; j += i) {
    		if(value[j - 1])
    			sum++;
    	}

    	if(sum%2 and vec[i - 1]%2 == 0) {
    		value[i - 1] = 1;
    		cnt++;
    		sum++;
    	}

    	if(sum%2 == 0 and vec[i - 1]%2) {
    		sum++;
    		cnt++;
    		value[i - 1] = 1;
    	}

    }

    cout << cnt << '\n';
   	rep(i,n) {
   		if(value[i])
   			cout << i + 1 << ' ';
   	}
   	if(cnt >= 1)
   		cout << '\n';
}

Measured memory_bytes: 3968
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    h,n=map(int, input().split())
    ab=[list(map(int, input().split())) for i in range(n)]
    ans=[0]*(4*10**4)
    for i in range(1,h+1):
        li = [ans[i-j[0]]+j[1] for j in ab]
        ans[i]=min(li)
    print(ans[h])

if __name__=='__main__':
    main()

Measured memory_bytes: 9960
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to;
	ld cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	/*if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;*/
	return ((a.x + 1)*(a.y + 1)) < ((b.x + 1)*(b.y + 1));
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll x, ll k, ll p) {//最大値、個数
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
 //#define int long long
const long long Inf = 4523372036854775807;
const int inf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
struct A {
	string s;
	int x;
	bool y;
	//文字列、年、最初か最後か
};
bool operator<(A a, A b) {
	if (a.x != b.x) return a.x < b.x;
	return !a.y;
}
vector<A>a;
vector<int>b;
signed main() {
	int n, q;
	while (cin >> n >> q, n, q) {
		a.clear();
		b.clear();
		for (int i = 0; i < n; i++) {
			string s;
			int u, r;
			cin >> s >> u >> r;
			a.push_back(A{ s,r - u + 1,0 });
			b.push_back(r - u + 1);
			a.push_back(A{ s,r,1 });
			b.push_back(r);
		}
		sort(a.begin(), a.end());
		sort(b.begin(), b.end());
		for (int i = 0; i < q; i++) {
			int t;
			cin >> t;
			int k = upper_bound(b.begin(), b.end(), t) - b.begin() - 1;
			if (k < 0 || (a[k].y&&a[k].x < t)) {
				cout << "Unknown\n";
			}
			else {
				if (a[k].x == t&&a[k].y) k--;
				cout << a[k].s << " " << t - a[k].x + 1 << endl;
			}
		}
	}
	getchar(); getchar();
}


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

long long sum(string str){
  long long ret = 0;
  int left = 0;
  for (int i = 0; i < str.size(); i++)
  {
    if (str.at(i) == '+')
    {
      //cout << str.substr(left, i - left) << " + " ;
      ret += stoll(str.substr(left, i - left));
      left = ++i;
    }
  }
  //cout << str.substr(left, str.size() - left);
  ret += stoll(str.substr(left, str.size() - left));
  //cout << " = " << ret << endl;
  return ret;
  
}

int main(){
  string s;
  cin >> s;
  long long ans = 0;
  for (int bit = 0; bit < (1 << s.size() - 1); bit++)
  {
    string tmp = s;
    for (int i = s.size() - 1; i >= 0; i--)
    {
      if (bit & (1 << i))
      {
        tmp.insert(i + 1, "+");
      }

    }
    //cout << "get summation of: " << tmp << endl;
    ans += sum(tmp);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
// Problem : C - Peaks
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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


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

    long n, m;
    cin >> n >> m;
    vector<long> h(n + 1, 0);
    for (long i = 1; i <= n; i++) {
        cin >> h[i];
    }
    vector<vector<long>> adj(n+1);
    for (long i = 0; i < m; i++) {
        long x, y;
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    
    long count = 0;
    for (long i = 1; i <= n; i++) {
        bool good = true;
        for (long j = 0; j < adj[i].size(); j++) {
            if (h[adj[i][j]] >= h[i]) good = false;
        }
        if (good) count++;
    }
    cout << count << "\n";
    
    return 0;
}


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

using namespace std;

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

const int MOD = 998244353;

ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << "\n";
    
    return 0;
}


Measured memory_bytes: 3608
using System;

namespace CSharp
{
    class Program
    {
        public static void Main()
        {
            var N = int.Parse(Console.ReadLine());

            var result = 0;
            for (int i = 1; i <= N; i++)
            {
                if (i.ToString().Length % 2 == 1)
                {
                    result++;
                }
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13140
R, C = map(int, input().split())
arr = [list(input()) for _ in range(R)]
dp = [[0 for _ in range(C+1)] for _ in range(R+1)]
dp[1][1] = 1
for i in range(1, R+1):
    for j in range(1, C+1):
        if arr[i-1][j-1] == "#":
            dp[i][j] = 0
        else:
            dp[i][j] = max(dp[i][j], dp[i-1][j]+dp[i][j-1])%1000000007
 
print(dp[-1][-1])

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

int main() {
    string s;
    cin >> s;
    bool coffee = false;
    if (s.at(2) == s.at(3) && s.at(4) == s.at(5)){
        coffee = true;
    }
    
    if (coffee) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[100005], finv[100005], inv[100005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge>>G;

int a, b, k[100005];
int main() {
	string h;
	cin >> a >> b >> h;
	for (int i = 1; i < h.length(); ++i) {
		if (h[i] == 'C'&&h[i - 1] == 'A') { ++k[i]; }
	}
	for (int i = 1; i < a; ++i) { k[i] += k[i - 1]; }
	for (int i = 0; i < b; ++i) {
		int n, m;
		cin >> n >> m;
		--n, --m;
		cout << k[m] - k[n] << endl;
	}
}

Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int mod = 1000000007;
const int tmpMod = 998244353;

int main() {
 
  string N,M;
  cin>>N>>M;
  int ans=0;
  //vector<int64_t> A(N);
  for(int i=0; i<N.size(); i++){
    if(N[i]!=M[i])ans++;
  }
  //vector<vector<int> > A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  cout << ans << endl;
}


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


const int max_n = 100001;
int dat[max_n];


void init() {
	for (int i = 0; i < max_n; i++) {
		dat[i] = 0;
	}
}

void update(int i,int v) {
	while(i < max_n) {
		dat[i] += v;
		i += i & -i;
	}
}

int find(int x) {
	int result = 0;
	while (x > 0) {
		//cout << "xdat[" << x << "] = " << dat[x] << endl;
		result += dat[x];
		x -= x & -x;
		
	}
	 return result;
}

int main() {
	init();

	int n,q;
	cin >> n >> q;

	for (int i = 0; i < q; i++) {
		int com, x, y;
		cin >> com >> x >> y;
		if (com==0) {
			update(x,y);
		} else {
			cout << find(y) - find(x - 1) << endl;
		}

	}
	return 0;
}

Measured memory_bytes: 1552