akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int length = Integer.parseInt(br.readLine());
		for(int i = 0;i<length;i++){
			String[] num = br.readLine().split(" ");
			int a = Integer.parseInt(num[0]);
			int b = Integer.parseInt(num[1]);
			int c = Integer.parseInt(num[2]);
			
			int rightc = a*a+b*b;
			int rightb = a*a+c*c;
			int righta = b*b+c*c;
			if(c*c==rightc ||b*b==rightb || a*a==righta){
				System.out.println("YES");
			} else{
				System.out.println("NO");
			}
		}
	}
}
			

Measured memory_bytes: 25968
#include<iostream>
int rounds;
int Ascore, Bscore;
int Acard,Bcard;
int main(){
	while (true){
		std::cin >> rounds;
		if (rounds == 0)break;
		for (int i = 0; i < rounds; i++){
			std::cin >> Acard>> Bcard;
			if (Acard > Bcard){
				Ascore += (Acard + Bcard);
			}
			else if (Acard < Bcard){
				Bscore += (Acard + Bcard);
			}
			else{
				Ascore += Acard;
				Bscore += Bcard;
			}
		}
		std::cout << Ascore << " " << Bscore << "\n";
		Ascore = 0, Bscore = 0;
	}
	return 0;
}

Measured memory_bytes: 3096
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std ;

char s[200] ;
int n , m ;

int main ()
{
    int i ;
    scanf(" %d %s ",&n,s+1);
    for ( i=1 ; i<=n ; i++ ) m+=(s[i]=='R');
    if ( m>n-m ) puts("Yes");
    else puts("No");
    return 0 ;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
typedef pair<int,int> pii;
int MOD = 998244353;

ll pow(ll x,ll n){
    ll ans = 1;
    while(n > 0){
        if(n%2 == 1) ans = ans * x;
        x = x * x;
        n = n >> 1;
    }
    return ans;
}

signed main(){
    int m,k;
    cin >> m >> k;

    int n = pow(2,m);

    if(k >= n){
        cout << -1 << endl;
        return 0;
    }
    if(m == 1){
        if(k == 0)cout << "0 0 1 1" << endl;
        if(k == 1)cout << "-1" << endl;
        return 0;
    }

    rep(i,n){
        if(i != k)cout << i << " ";
    }
    cout << k << " ";
    rep(i,n){
        if(n-1-i != k)cout << n-1-i << " ";
    }
    cout << k << endl;


     
    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc126.contest.atcoder.jp/tasks/abc126_f


Measured memory_bytes: 1792
S = input()
T = []
kai = len(S)
for A in range(2):
  if A == 1:
    AA = ["1"]
  else:
    AA = ["0"]
  for AAA in range(1,len(S)):
    if AA[AAA - 1] == "1":
      AA += "0"
    else:
      AA += "1"
  T += [AA]

for B in range(2):
  KK = 0
  BS = T[B]
  for BBS in range(len(BS)):
    C = BS[BBS]
    if S[BBS] != C:
      KK += 1
  if kai > KK:
    kai = KK
print(kai)

Measured memory_bytes: 4852
#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (a, b) = input!(u64, u64);

    if (a + b) % 2 == 0 {
        println!("{}", (a + b) / 2);
    } else {
        println!("IMPOSSIBLE");
    }
}

fn main() {
    solve();
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>

int Partition(int A[], int p, int r)
{
  int x;
  int i, j;
  int tmp;

  x = A[r];
  i = p - 1;
  for(j = p; j < r; j++)
    {
      if(A[j] <= x)
	{
	  i = i + 1;
	  tmp = A[i];
	  A[i] = A[j];
	  A[j] = tmp;
	}
    }
  tmp = A[i + 1];
  A[i + 1] = A[r];
  A[r] = tmp;
  
  return i + 1;
}

int main()
{
  int i;
  int *A;
  int n, q;

  scanf("%d", &n);

  A = (int *)malloc(n * sizeof(int));

  for(i = 0; i < n; i++)
    {
      scanf("%d", &A[i]);
    }

  q = Partition(A, 0, n - 1);

  for(i = 0; i < q; i++)
    {
      printf("%d ", A[i]);
    }
  printf("[%d] ", A[q]);
  for(i = q + 1; i < n - 1; i++)
    {
      printf("%d ", A[i]);
    }
  printf("%d\n", A[n - 1]);

  return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;
int sum, t, mx;
int main() {
    for (int i = 0; i < 3; ++i) {
        cin >> t;
        sum += t;
        mx = max(mx, t);
    }
    cout << sum - mx << endl;
    
    return 0;
}


Measured memory_bytes: 3536
#include<stdio.h>
#define int long long
#define mod 1000000007
inline int ksm(int a,int b)
{
	register int ans=1;
	for(;b;a*=a,a%=mod,b>>=1)if(b&1)ans*=a,ans%=mod;
	return ans;
}
main()
{
	register int n;
	scanf("%lld",&n);
	if(n==1)puts("0");
	else printf("%lld",((ksm(10,n)-ksm(9,n)-ksm(9,n)+ksm(8,n))%mod+mod)%mod);
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
  std::cin.tie(nullptr);
  ios::sync_with_stdio(0);
  string s;
  cin >> s;
  cout << ((s[0] == '7' || s[1] == '7' || s[2] == '7') ? "Yes" : "No") << endl;

  return 0;
}


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

int main(){
  while(1){
    int H, W;
    cin>>H>>W;
    if(H == 0 && W == 0) break;

    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
        if(i == 0 || i == H - 1 || j == 0 || j == W - 1) cout<<"#";
        else cout<<".";
      }
      cout<<endl;
    }
 
    cout<<endl;
  }
  
    return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

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

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////


int main() {
  int N;
  cin >> N;
  vector<LL> A(N, 0);
  for(int i=0; i<N; i++) cin >> A[i];
  vector<int> change(31, 0);
  for(int elem : A) {
    int cnt = 0;
    cnt++;
    while(elem % 2 == 0) {
      cnt++;
      elem /=2;
    }
    change[cnt]++;
  }
  LL result = 0;
  for(int i=0; i<N; i++) {
    result ^= A[i];
  }

  vector<int> ketas;
  int ans = 0;
  bool ok = true;
  bool flip = false;
  for(int i=30; i>=0; i--) {
    bool cur =  ((1<<i) & result ? true : false)  ;

    if(cur ^ flip) {
      ketas.push_back(i+1);
      ans++;
      if(change[i+1] == 0) ok = false;
      flip ^= 1;
    }
  }
  if(!ok) ans = -1;
  cout << ans << endl;
  

  return 0;
}


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

#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1e9)
ll A,B,ans;
ll X[2][50]={};//X[0][13] = A-1まで X[1][13] == Bまで
int main(){
  cin >> A >> B;
  if(A==B){
    cout << A << endl;
    return 0;
  }
  if(A!=0){
    rep(i,50){
      ll bek = pow(2,i);
      X[0][i] = (A/((ll)2*bek))*bek+max((ll)0,A%((ll)2*bek)-bek);
    }
  }
  rep(i,50){
    ll bek = pow(2,i);
    X[1][i] = ((B+1)/((ll)2*bek))*bek+max((ll)0,(B+1)%((ll)2*bek)-bek);
  }
  for(int i=0; i<50; i++){
    if((X[1][i]-X[0][i])%2==1){
      ans += (ll)pow(2,i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <algorithm>
#include <typeinfo>
#define _USE_MATH_DEFINES
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int n, q;
vector<int> A(2000);

bool solve(int i, int v){
    if(v==0){
        return true;
    }
    if(i==n){
        return false;
    }
    bool res;
    if(A[i]<=v){
        res = solve(i+1, v) || solve(i+1, v-A[i]);
    }else{
        res = solve(i+1, v);
    }
    return res;
}

int main(){

    cin >> n;

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

    cin >> q;
    for(int i=0; i<q; i++){
        int M;
        cin >> M;
        if(solve(0, M)){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }

    return 0;
}



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

using namespace std;

const int MAX_N = 105;

int ans [MAX_N][MAX_N];

int main () {
  int n, m;
  cin >> n >> m;

  int k;
  cin >> k;
  vector<int> arr;
  for (int i = 1; i <= k; i++) {
    int x;
    cin >> x;

    for (int j = 0; j < x; j++) {
      arr.push_back(i);
    }
  }

  int cur = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      for (int j = 0; j < m; j++) {
        ans[i][j] = arr[cur];
        cur++;
      }
    } else {
      for (int j = m - 1; j >= 0; j--) {
        ans[i][j] = arr[cur];
        cur++;
      }
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << ans[i][j] << " ";
    }
    cout << '\n';
  }
}


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

int main(){
  int H,W;

  while(1){
    cin >> H >> W;
    
    if(H==0 && W==0){
      break;
    }

    for(int j=0; j<H; j++){
      for(int i=0; i<W; i++){
        cout << "#";
      }
      cout << endl;
    }
    

    cout << endl;
  }
  
  return(0);
}

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

using namespace std;
using ll = long long;

ll sum(int x) {
	return x <= 0 ? 0 : 1LL * x * (x + 1) / 2;
}

ll sum(int a, int b) {
	return sum(b) - sum(a - 1);
}

int n, x, d;

int main() {

	scanf("%d %d %d", &n, &x, &d);

	if(d == 0) {
		printf("%d\n", x == 0 ? 1 : n + 1);
		return 0;
	}

	map<int, vector<tuple<ll, int>>> events;
	for(int k = 0; k <= n; k++) { 
		ll a = sum(0, k-1) * d + 1LL * k * x;
		ll b = sum(n - k, n-1) * d + 1LL * k * x;
		if(a > b) swap(a, b);
		int id = int(1LL * k * x % d);
		if(id < 0) id += abs(d);
		// printf("%d(%d): [%lld %lld] | %lld %lld\n", k, id, a, b, sum(0, k-1), sum(n-k, n-1));
		events[id].emplace_back(a, 0);
		events[id].emplace_back(b+abs(d), 1);
	}

	ll ans = 0;

	for(auto vec : events) {
		sort(vec.second.begin(), vec.second.end());
		ll last = -1e18;
		int cnt = 0;
		for(auto e : vec.second) {
			ll pos; int st;
			tie(pos, st) = e;
			if(cnt) {
				ans += (pos - last) / abs(d);
			}
			cnt += st == 0 ? 1 : -1;
			assert(cnt >= 0);
			last = pos;
		}
		assert(cnt == 0);
	}

	printf("%lld\n", ans);
}


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

int main(){
  
  int N; cin >> N;
  string S; cin >> S;
  
  if(N%2 == 1){
    cout << "No" << endl;
    return 0;
  }
  
  for(int i=0; i<N/2; i++){
    
    if(S.at(i) != S.at(i+N/2)){
      cout << "No" << endl;
      return 0;    
    }
  
  }
  cout << "Yes" << endl;
}

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

int N;
vector<vector<int> > adj;
vector<int> X;
vector<int> dp;
vector<int> tmp;

void dfs(int u) {
    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        dfs(v);
    }

    tmp = vector<int>(5010, 0);
    tmp[0] = 1;

    int sum = 0;
    int tot = 0;
    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];

        sum += min(X[v], dp[v]);
        tot += X[v] + dp[v];
        for(int j = 5010; j--;) {
            if(j - max(X[v], dp[v]) + min(X[v], dp[v]) < 0) continue;
            tmp[j] |= tmp[ j - max(X[v], dp[v]) + min(X[v], dp[v]) ];
        }
    }

    if(X[u] < sum) {
        printf("IMPOSSIBLE");
        exit(0);
    }

    for(int j = 0; j <= X[u] - sum; j++) {
        if(tmp[j]) dp[u] = tot - sum - j;
    }
}

int main() {
    scanf("%d", &N);
    adj.resize(N);
    for(int i = 1; i < N; i++) {
        int p; scanf("%d", &p);
        p--;
        adj[p].push_back(i);
    }

    X.resize(N);
    for(int i = 0; i < N; i++) {
        scanf("%d", &X[i]);
    }

    dp.resize(N);
    dfs(0);

    printf("POSSIBLE");
}


Measured memory_bytes: 384
n=int(input())
s1=input()
s2=input()
x=[]
f=0
for i in range(n):
    if f==1:
        f=0
    else:
        if s1[i]==s2[i]:
            x.append(0)
        else:
            x.append(1)
            f=1
l=len(x)
#print(x)
if l==1:
    if x[0]==0:
        print(3)
    else:
        print(6)
else:
    if x[0]==0:
        c=3
    else:
        c=6
    for i in range(1,l):
        #print(c)
        if x[i-1]==0:
            c*=2
        else:
            if x[i]==1:
                c*=3
        c%=1000000007

    print(c%1000000007)


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

using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int k=sizeof(a)/sizeof(a[0]);
	sort(a,a+k);
	int alice=0,bob=0;
	int m=0,l=0;
	for(int j=n-1;j>=0;j--)
	{
		if(j==(n-m)-1)
		{
			alice+=a[j];
			//cout<<alice;
			m+=2;
		}
		else
		{
			bob+=a[j];
			//cout<<bob;
		}
	}
	int answer=alice-bob;
	cout<<answer;
	return 0;
}

Measured memory_bytes: 256
def get_order_of_arrival(ar: list) -> list:
    lst = [None for _ in range(len(ar))]
    for i, s in enumerate(ar):
        lst[s - 1] = i + 1
    return lst


if __name__ == '__main__':
    N = int(input())
    array = list(map(int, input().split()))
    result = get_order_of_arrival(array)
    print(" ".join(list(map(str, result))))


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

typedef vector<int>  vi;
typedef set<char> setchar;
typedef set<int> sett;
typedef deque <int> dq;
typedef long long ll;

#define vec(a)  a.begin(),a.end()
#define pb     push_back
#define pf     push_front
#define mem(a,b) memset(a,b,sizeof(a));
#define inI(a)  scanf("%d",&a);
#define inL(a)  scanf("%lld",&a);
#define uff ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
//int fx[]={+0,-1,-1,-1,+0,+1,+1,+1};
//int fy[]={-1,-1,+0,+1,+1,+1,+0,-1};
int fx[]= {0,-1,0,+1};
int fy[]= {-1,0,+1,0};
int dp[3][100005];
int main()
{
    uff
    //freopen("input.txt","r",stdin);
    int n;
    cin>>n;
    vector<int> a(n,0),b(n,0),c(n,0);
    for(int i=0;i<n;i++)
    cin>>a[i]>>b[i]>>c[i];
    dp[0][0]=a[0];
    dp[1][0]=b[0];
    dp[2][0]=c[0];

    for(int i=1;i<n;i++)
    {
        dp[0][i]=a[i]+max(dp[1][i-1],dp[2][i-1]);
        dp[1][i]=b[i]+max(dp[0][i-1],dp[2][i-1]);
        dp[2][i]=c[i]+max(dp[1][i-1],dp[0][i-1]);
    }
    cout<<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]))<<endl;







    return 0;

}







Measured memory_bytes: 2560
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

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

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

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

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(i, a)  for (auto i : a)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define PI acos(-1)

template<class T>
bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }

template<class T>
bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

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

const int MOD = 998244353;
const ll oo = 1e18;
const int MX = 1e5 + 5, N = 2e5 + 5;

int l, r, d;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> l >> r >> d;
    int ans = 0;
    FOR(i, l, r + 1) {
        if (i % d == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
	int n,m;
	while(cin>>n>>m,n||m){
		vector<pair<string,pii> > v(n);
		rep(i,n){
			cin>>v[i].F>>v[i].S.F>>v[i].S.S;
		}
		rep(i,m){
			int t;
			cin>>t;
			bool f=true;
			rep(j,n){
				if(v[j].S.S>=t&&v[j].S.S-v[j].S.F+1<=t){
					cout<<v[j].F<<" "<<v[j].S.F-(v[j].S.S-t)<<endl;
					f=false;
					break;
				}
			}
			if(f) cout<<"Unknown\n";
		}
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

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

ll mod = 1000000007;

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

ll inv(ll x){
  ll res = 1;
  ll k = mod - 2;
  ll y = x;
  while(k){
    if(k&1)res = (res*y)%mod;
    y = (y*y) % mod;
    k /= 2;
  }
  return res;
}

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

  int n;
  cin >> n;

  vi ab(1000001);
  for(int i = 1;i <= 1000000;i++){
    for(int j = i;j <= 1000000;j++){
      if((ll)i*j > 1000000)break;
      if(i == j)ab[i*j]++;
      else ab[i*j] += 2;
    }
  }

  int ret = 0;
  for(int i = 1;i <= n-1;i++){  
    ret += ab[i];
  }

  cout << ret << endl;
}

Measured memory_bytes: 7152
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) {rep(i,x.size()) cout << x[i] << " "; cout << endl;}
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9+7;
const ll inf_l = 1e18;
const int MAX = 1e7+10;

int main() {
    int n; cin >> n;
    set<int> od, ev;
    vint a(n);
    rep(i,n) {
        int x; cin >> x;
        if (i&1) od.insert(x);
        else ev.insert(x);
        a[i] = x;
    }
    sort(all(a));
    int ans = 0;
    rep(i,n) {
        if (i&1 && !od.count(a[i])) ans++;
        if (!(i&1) && !ev.count(a[i])) ans++;
    }
    cout << ans/2 << endl;
}

Measured memory_bytes: 8292
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Integer res = Stream.generate(()->sc.nextInt()).limit(N)
                .reduce(0, (a, b)->{
                    if(b == a+1){
                        return a+1;
                    }else{
                        return a;
                    }
                });
        if(res == 0){
            System.out.println(-1);
        }else {
            System.out.println(N - res);
        }
    }
}


Measured memory_bytes: 66348
while True:
    (H, W) = [int(i) for i in input().split()]
    if H == W == 0:
        break
    for a in range(H):
        for b in range(W):
            if (a + b) % 2 == 0:
                print('#', end='')
            else:
                print('.', end='')
        print('')
    print('')

Measured memory_bytes: 9176
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,a,c,d;
    cin>>n;
    if(n<1000)
        cout<<1000-n<<endl;
    else {
        k=((n/1000)+1)*1000;
        k=k-n;
        if(k%1000 == 0)
            cout<<"0"<<endl;
        else
            cout<<k<<endl;
    }
    return 0;
}


Measured memory_bytes: 3604
a,b,c,d = map(int,input().split())

import fractions

def calc(x,y,z):
    div_y = x//y
    div_z = x//z
    div_yz = x//( y*z//fractions.gcd(y,z) )
    return( x - div_y - div_z + div_yz  )

ans = calc(b,c,d) - calc(a-1,c,d)
print(ans)

Measured memory_bytes: 63980
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef long double ld;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll exp(ll x,ll y){if(y==0) return 1;if(y%2 == 1) return x*exp(x,y/2)*exp(x,y/2);return exp(x,y/2) * exp(x,y/2);}
ll exp(ll x,ll y,ll modd) {if(y==0) return 1;ll t=exp(x,y/2,modd);t = t%modd;t=t*t;t=t%modd;if(y % 2 == 1) return (x*t)%modd ;return t%modd;}
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC target ("sse4")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define emp empty()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0ll, so x)
#define all(x) (x).be , (x).en
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define revn(i,a,b) for(ll i=a;i>=b;--i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vs vector<string>
#define vsi vector<pair<string,int>>
#define vll vector<pair<ll,ll> >
#define vlll vector<pair<ll,pair<ll,ll>>>
#define vlvl vector<pair<pair<ll,ll>,ll>>>
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

int main()
{
    ios;
    int n, w;
	cin>>n>>w;
	 
	vector<ll> val(n), wt(n);
	
	for(int i=0;i<n;i++)
		cin>>wt[i]>>val[i];
	
	vector<vector<ll>> dp(n, vector<ll>(w+1, 0));
	
	for(int i=0;i<=w;i++)
		if(wt[0]<=i)
			dp[0][i]=val[0];
	
	
	for(int i=1;i<n;i++)
		for(int j=1;j<=w;j++)
		{
			ll p1 = 0;
			
			if(j>=wt[i])
				p1 = dp[i-1][j-wt[i]] + val[i];
			
			dp[i][j] = max(dp[i-1][j], p1);
		}
	cout<<dp[n-1][w];
	return 0;
}

Measured memory_bytes: 79488
using static System.Console;
using static System.Math;

class Program {
	static void Main() {
		var O = ReadLine();
		var E = ReadLine();

		for (var i = 0; i < Max(O.Length, E.Length); i++) {
			if (i < O.Length) {
				Write(O[i]);
			}
			if (i < E.Length) {
				Write(E[i]);
			}
		}
		WriteLine();
	}
}


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

int main(){
  int N;
  cin >> N;
  
  int ok = 20000, ng = 0;
  while(ok - ng > 1){
    int mid = (ok + ng) / 2;
    if(mid * (mid + 1) / 2 >= N){
      ok = mid;
    }else{
      ng = mid;
    }
  }

  for(int i = ok; i >= 1; i--){
    if(N >= i){
      cout << i << endl;
      N -= i;
    }
  }
}


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

#define ll long long
#define an "\n"
#define pb push_back
#define pob pop_back

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for(int i=0;i<100;i++) {
		if(i*1000>=n) {
			cout << i*1000-n;
			return 0;
		}
	}
}


Measured memory_bytes: 3620
function main(){
  var debt = 100000;
  var wk = input.trim() - 0;
  for(;wk > 0; wk--){
    debt = Math.ceil((debt * 1.05)/1000) * 1000;
  }

  console.log(debt);
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  main();
});

Measured memory_bytes: 7644
/*Bismillahir Rahmanir Rahim
->>Code by Ashraful Islam Paran
->>CUET,CSE
*/
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef unsigned long long ull;
typedef vector<int> vi;
const int MX=2e5+5;
#define f(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define endl "\n"
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

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

    int n,k,s{0};
    cin>>n>>k;
    int p[n];
    f(i,0,n)
    {
        cin>>p[i];
    }
    sort(p,p+n);
    f(i,0,k)
    {
        s+=p[i];
    }
    cout<<s<<endl;

    return 0;
}



Measured memory_bytes: 3664
#include<stdio.h>
#include<queue>
#include<assert.h>
#include<tuple>
#include<string>
#include<algorithm>
#include<iostream>
#include<map>
#include<string.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<ctype.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef tuple<int,int,int> t3;

const int MX = 2005;
const int MM = 1000000007;

int main()
{
	int N, a = 0, b;
	scanf("%d", &N);
	for(int i = 1; i <= N; i++){
		scanf("%d", &b);
		a += b&1;
	}
	printf("%s\n", a&1? "NO":"YES");
}


Measured memory_bytes: 256
a, b, c = gets.split.map(&:to_i).sort!
a, b = c - a, c - b

diva, a = a.divmod(2)
divb, b = b.divmod(2)
ans = diva + divb

case a + b
when 2
  puts ans + 1
when 1
  puts ans + 2
when 0
  puts ans
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
#define INF 1000000007
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main() {
   int n;
   cin >> n;
   int p[n];
   int c = 0;
   rep(i, n) {
     cin >> p[i];
     if(p[i] != i + 1) c++;
   }
   if(c == 2 || c == 0) cout << "YES" << endl;
   else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<string> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    int i;
    for(i = 1; i < n; i++){
        int j;
        for(j = 0; j < i; j++){
            if(v[i] == v[j]) break;
        }
        if(i != j) break;
        if(v[i][0] != v[i-1][v[i-1].size()-1]) break;
    }
    if(i == n) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(){
  string N;
  cin >> N;
  int D = N.size();
  int sum = 0;
  for (int i = 0; i < D; i++){
    sum += N[i] - '0';
  }
  if (sum % 9 == 0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3716
s=gets.chomp
t=gets.chomp
z=s.size
a=0
n=-1
m=0
t.each_char do |tt|
  if s.index(tt,n+1)
    m=s.index(tt,n+1)
    a+=m-n
    n=m
  elsif s.index(tt)
    m=s.index(tt)
    a+=m-n+z
    n=m
  else
    puts "-1"
    exit
  end
end
puts a


Measured memory_bytes: 4220
<?php
declare(strict_types=1);

$inputs = str_split(file_get_contents("php://stdin"));
echo array_reduce($inputs, function(string $prev, string $cur): string {
  if ($cur === "B") {
    return strlen($prev) == 0 ? $prev : substr($prev, 0, -1);
  } else {
    return $prev.$cur;
  }
}, "");

Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using ll = unsigned long long int;
using namespace std;

bool isdigit(char ch) {
    return '0' <= ch && ch <= '9';
}

int main() {
    fastIO;

    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;

    if ((int)s.size() != (a + b + 1)) {
        cout << "No";
        return 0;
    }

    for (int i = 0; i < a; i++) {
        if (!isdigit(s.at(i))) {
            cout << "No";
            return 0;
        }
    }

    if (s.at(a) != '-') {
        cout << "No";
        return 0;
    }

    for (int i = a + 1; i < a + b; i++) {
        if (!isdigit(s.at(i))) {
            cout << "No";
            return 0;
        }
    }

    cout << "Yes";
}

Measured memory_bytes: 3660
import sys
from collections import defaultdict

def solve():
    input = sys.stdin.readline
    A, B, T = map(int, input().split())
    time = A
    count = 0
    while time < T + 0.5:
        count += B
        time += A
    print(count)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3316
#include <stdio.h>

#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define STRS(i,str) for(int i=0;(str)[i];i++)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX3(a,b,c) ((a)>(b)?(a)>(c)?(a):(c):(b)>(c)?(b):(c))
#define MIN3(a,b,c) ((a)<(b)?(a)<(c)?(a):(c):(b)<(c)?(b):(c))
#define MED(a,b,c) ((a)<(b)?(a)>(c)?(a):(b)<(c)?(b):(c):(a)>(c)?(b)<(c)?(c):(b):(a))
#define RNG(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define RNG3(a,b,c) ((a)>(b)?(b)>(c)?(a)-(c):(c)>(a)?(c)-(b):(a)-(b):(b)>(c)?(c)>(a)?(b)-(a):(b)-(c):(c)-(a))
#define MAXS(a,b) {if((a)<(b))(a)=(b);}
#define MINS(a,b) {if((a)>(b))(a)=(b);}
#define BEGINFOR(a,b,c,d,e,f,g,h,i) a;goto i##_6;i##_2:c;goto i##_6;i##_3:h;goto i##_7;i##_4:d;goto i##_8;i##_5:f;goto i##_8;i##_6:if(b)goto i##_4;else goto i##_9;i##_7:if(g)goto i##_5;else goto i##_1;i##_8:if(e)goto i##_2;else goto i##_3;i##_9:
#define CONTINUE(i) goto i##_3
#define BREAK(i) goto i##_1
#define ENDFOR(i) goto i##_3;i##_1:

#define INT int

class Int{
public:
	int v;
	Int(){scanf("%d", &v);}
	operator int(){return v;}
};

#define ARC(i,a,b) for(INT i=(a);i<(b);++i)
#define ARCH(i,a,b) for(INT i=(a)-1;i>=(b);--i)
#define RC(i,n) ARC(i,0,n)
#define RCH(i,n) ARCH(i,n,0)
#define SRC(i,s) for(INT i=0;(s)[i];++i)
#define ATH(a,b) ((a)>(b)?(a):(b))
#define OTH(a,b) ((a)<(b)?(a):(b))
#define ANTH(a,b) {if((a)<(b))(a)=(b);}
#define ONTH(a,b) {if((a)>(b))(a)=(b);}
#define ANT printf
#define ENT scanf
#define AT putchar
#define ET getchar
#define _ AT('\n');

int main(){
	Int a, b, c, d;
	ANT(a + b > c + d ? "Left" : a + b == c + d ? "Balanced" : "Right");_
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio>
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RREP(i,x) for(int i=(x);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)

int n, x, t;
string s;
main(){
	while(cin >> n >> x){
		vector<int> d1, d2;
		REP(i, x){
			cin >> s >> t;
			if(s == "D") d1.push_back(t);
		}
		cin >> x;
		REP(i, x){
			cin >> s >> t;
			if(s == "DD") d2.push_back(t);
		}
		int ans = 0;
		sort(d1.rbegin(), d1.rend());
		sort(d2.rbegin(), d2.rend());
		int sum = 0;
		for(int i=0;i*2<=n&&i<=d2.size();i++){
			int sum2 = sum;
			for(int j=0;i*2+j<n&&j<d1.size();j++) sum2 += d1[j];
			ans = max(ans, sum2);
			if(i<d2.size()) sum += d2[i];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
#define lint long long
//#define P pair<int, int>

int main(){
    int N, M;
    cin >> N >> M;
    
    vector<vector<int>> G(51);
    int a[M], b[M];
    
    for(int i = 0; i < M; ++i){
        cin >> a[i] >> b[i];
        
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    
    int ans = 0;
    
    for(int i = 0; i < M; ++i){
//        cerr << i << " : ";
        bool tf[N + 1];
        memset(tf, false, sizeof tf);
        queue<int> que;
        que.push(1);
        
        while(!que.empty()){
            int p = que.front(); que.pop();
            for(int j = 0; j < G[p].size(); ++j){
                int e = G[p][j];
                if(tf[e]){
                    continue;
                } else {
                    if((p == a[i] && e == b[i]) || (p == b[i] && e == a[i])){
                        continue;
                    }
                    tf[e] = true;
                    que.push(e);
//                    cerr << e << " ";
                }
            }
        }
//        cerr << endl;
        
        for(int i = 1; i <= N; ++i){
            if(!tf[i]){
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
bool check(const int x, const int y) {
	return (x >= 0 && x <= 9 && y >= 0 && y <= 9);
}

int ax[] = { -2,-2,-2,-1,0,1,2,2,2,1,0,-1 };
int ay[] = { -1,0,1,2,2,2,1,0,-1,-2,-2,-2 };

int main() {
	while (1) {
		int sx, sy; cin >> sx >> sy;
		if (!sx)break;
		sx--; sy--;
		if (!sx)break;
		int N; cin >> N;
		vector<vector<int>>oks(10, vector<int>(10, false));
		oks[sy][sx] = true;
		for (int i = 0; i < N; ++i) {
			int x, y; cin >> x >> y; x--; y--;

			vector<vector<int>>nextoks(10, vector<int>(10, false));
			vector<vector<int>>nextoks2(10, vector<int>(10, false));
			for (int dx = -1; dx <= 1; ++dx) {
				for (int dy = -1; dy <= 1; ++dy) {
					if (check(x + dx, y + dy)) {
						nextoks[y + dy][x + dx] = true;
					}
				}
			}
			for (int y = 0; y < 10; ++y) {
				for (int x = 0; x < 10; ++x) {
					if (oks[y][x]) {
						for (int t = 0; t < 12; ++t) {
							int nexty = y + ay[t];
							int nextx = x + ax[t];
							if (check(nextx, nexty)) {
								nextoks2[nexty][nextx] = true;
							}
						}
					}
				}
			}
			for (int y = 0; y < 10; ++y) {
				for (int x = 0; x < 10; ++x) {
					if (nextoks[y][x] && nextoks2[y][x])oks[y][x] = true;
					else oks[y][x] = false;
				}
			}
		}
		bool ok = false;
		for (int y = 0; y < 10; ++y) {
			for (int x = 0; x < 10; ++x) {
				if (oks[y][x])ok = true;
			}
		}
		if (ok) {
			cout << "OK" << endl;
		}
		else {
			cout << "NA" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3052
#include<cstdio>
using namespace std;
#define MAXN 100005
#define LL long long
LL n,X;
LL x[MAXN];
LL ans;
LL gcd(LL a,LL b)
{
	if(b==0) return a;
	return gcd(b,a%b);
}
LL Abs(LL p)
{
	if(p>=0) return p;
	return -p;
}
int main()
{
	scanf("%lld %lld",&n,&X);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&x[i]);
		x[i]=Abs(x[i]-X);
		if(i==1) ans=gcd(x[1],x[2]);
		else ans=gcd(ans,x[i]);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N, T; cin >> N >> T;
  vector<int> cost;
  rep(i, N){
    int c, t; cin >> c >> t;
    if (t <= T) cost.push_back(c);
  }
  if (cost.empty()){
    cout << "TLE" << endl;
    return 0;
  }
  sort(cost.begin(), cost.end());
  cout << cost[0] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto eps = 1e-6;
constexpr auto mod = 998244353;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

int tree[MAXSIZE];
int lazy[MAXSIZE];
int a[MAXSIZE];
int pre[MAXSIZE];

void build(int node, int left, int right){
	if(left==right){
		tree[node] = a[left];
		return ;
	}
	int mid = (left+right)/2;
	build(2*node, left,mid);
	build(2*node+1,mid+1,right);
	tree[node] = (tree[2*node] + tree[2*node+1]);
	if(tree[node] >= mod) tree[node] -= mod;
}

void propogate(int node, int left, int right){
	if(lazy[node]!=0){
		int s = (pre[left] - pre[right + 1]);
		if(s <= 0) s += mod;
		int k = lazy[node] * (s);
		k %= mod;
		//cout << left << " " << right << " " << node << " " << k << " " << tree[node] << "\n";
		tree[node] = (k);
		if(tree[node] >= mod) tree[node] -= mod; 
		if(left!=right){
			lazy[2*node]=lazy[node];
			lazy[2*node+1]=lazy[node];
		}
		lazy[node] = 0;	
	}
	
}

void update(int node, int left, int right, int l, int r, int val){
	propogate(node,left,right);
	if(left>r || right<l || right<left) return ;
	if(left>=l and right<=r){
		lazy[node]=val;
		propogate(node,left,right);
		return ;
	}
	int mid = (left+right)/2;
	update(2*node,left,mid,l,r,val);
	update(2*node+1,mid+1,right,l,r,val);
	tree[node] = (tree[2*node] + tree[2*node+1]);
	if(tree[node] >= mod) tree[node] -= mod;
}

int query(int node, int left, int right, int l, int r){
	propogate(node,left,right);
	if(left>r || right<l || right<left) return 0;
	if(left>=l and right<=r) return tree[node];
	int mid = (left+right)/2;
	int p = query(2*node,left,mid,l,r);
	int q = query(2*node+1,mid+1,right,l,r);
	int s =  (p + q);
	if(s  >= mod) s -= mod;
	return s;
}

int32_t main(){
	fastio();
	int n,q;
	cin >> n >> q;
	a[n] = 1;
	for(int i = n - 1; i >= 1; i--){
		a[i] = a[i + 1] * 10;
		a[i] %= mod;
	}
	for(int i = n; i >= 1; i--){
		pre[i] += pre[i + 1] + a[i];
		pre[i] %= mod;
	}
	build(1,1,n);

	while(q--){
		int l,r,x;
		cin >> l >> r >> x;
		update(1,1,n,l,r,x);
		cout << tree[1] << "\n";
	}
}

Measured memory_bytes: 14940
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <cctype>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
/*
	ll n;
	vector<ll> a(5);
	cin >> n;
	int cnt = 0;
	int m[5] = { 0 }; int people[5] = { 0 };
	people[0] = n;
	while (1) {
		for (int i = 0; i < 5; i++) {

		}
		if (m[4] == n)break;
	}
*/
int main(void) {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	//注文してから届くまでの時間
	vector<int> time = { a,b,c,d,e };
	//注文してから次に注文できるまでの時間
	vector<int> next_time(5);
	REP(i, 5) {
		if (time[i] % 10 == 0) next_time[i] = time[i];
		else next_time[i] = time[i] - time[i] % 10 + 10;
	}
	int best_time = 9999999999;
	//最後に注文するものを全通り計算
	REP(i, 5) {
		int sum_time = 0;
		REP(j, 5) {
			if (i == j) {
				//最後の処理
				sum_time += time[j];
			}
			else {
				sum_time += next_time[j];
			}
		}
		best_time = min(best_time, sum_time);
	}
	cout << best_time << endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int l = s.length();

        System.out.println(s.substring(0,1) + (l-2) + s.substring(l-1,l));
    }

}


Measured memory_bytes: 21844
#include<stdio.h>

long long calc(long long a, long long b){
	if (!b)return a;
	return calc(b, a%b);
}
int main(){
	long long n, x;
	scanf("%lld%lld", &n, &x);
	printf("%lld\n", 3 * (n - calc(n, x)));
	return 0;
}

Measured memory_bytes: 128
//https://arc076.contest.atcoder.jp/tasks/arc076_c

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

struct data{
    int num, x, y;
};

int r, c, n;
int x[2][N], y[2][N], cnt[N];
vector <data> mv[4];
stack <int> ms;

int main(){
    cin >> r >> c >> n;
    for (int i = 1; i <= n; i++) cin >> x[0][i] >> y[0][i] >> x[1][i] >> y[1][i];
    for (int i = 1; i <= n; i++){
        if (y[0][i] == 0) mv[0].push_back({i, x[0][i], y[0][i]});
        else if (x[0][i] == r) mv[1].push_back({i, x[0][i], y[0][i]});
        else if (y[0][i] == c) mv[2].push_back({i, x[0][i], y[0][i]});
        else if (x[0][i] == 0) mv[3].push_back({i, x[0][i], y[0][i]});
        else cnt[i]--;

        if (y[1][i] == 0) mv[0].push_back({i, x[1][i], y[1][i]});
        else if (x[1][i] == r) mv[1].push_back({i, x[1][i], y[1][i]});
        else if (y[1][i] == c) mv[2].push_back({i, x[1][i], y[1][i]});
        else if (x[1][i] == 0) mv[3].push_back({i, x[1][i], y[1][i]});
        else cnt[i]--;
    }
    sort(mv[0].begin(), mv[0].end(), [](data x, data y){return x.x < y.x;});
    sort(mv[1].begin(), mv[1].end(), [](data x, data y){return x.y < y.y;});
    sort(mv[2].begin(), mv[2].end(), [](data x, data y){return x.x > y.x;});
    sort(mv[3].begin(), mv[3].end(), [](data x, data y){return x.y > y.y;});
    for (auto x : mv[0]){
        if (cnt[x.num]) continue;
        if (ms.size() && ms.top() == x.num) ms.pop();
        else ms.push(x.num);
    }
    for (auto x : mv[1]){
        if (cnt[x.num]) continue;
        if (ms.size() && ms.top() == x.num) ms.pop();
        else ms.push(x.num);
    }
    for (auto x : mv[2]){
        if (cnt[x.num]) continue;
        if (ms.size() && ms.top() == x.num) ms.pop();
        else ms.push(x.num);
    }
    for (auto x : mv[3]){
        if (cnt[x.num]) continue;
        if (ms.size() && ms.top() == x.num) ms.pop();
        else ms.push(x.num);
    }
    cout << (ms.size() ? "NO" : "YES");
}


Measured memory_bytes: 5612
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()
a = inpl()
for i in range(n):
    a[i] = (a[i]+1)/2
cnt = sum(a[:k])
res = cnt
for i in range(n-k):
    cnt -= a[i]
    cnt += a[k+i]
    res = max(res,cnt)
print(res)    

Measured memory_bytes: 98636