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

public class Main {
    public static void main(String[] args) throws FileNotFoundException {

//    	File file = new File("src/in.txt");

        //コード
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);

    	int N = sc.nextInt();

    	long sum = 0;

    	for(int i=1;i<=N;i++) {
    		if((i%3!=0)&&(i%5!=0)) {
    			sum += i;
    		}
    	}
    	System.out.println(sum);


    }
}


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

int main() {
  int s;
  cin >> s;
  int count = 0;
  
  while(true){
    count++;
    if(s == 1 || s == 2 || s == 4){
      cout << count + 3 << endl;
      break;
    }
    else {
      if (s%2 == 0){
        s = s/2;
      }
      else {
        s = 3*s + 1;
      }
    }
  }
}


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

using namespace std;

string f(int n, int k, string s) {

    s[k - 1] = (char)((int)s[k - 1] + 32);

    return s;
}

int main() {

    int n, k;
    cin >> n >> k;

    string s;
    cin >> s;

    string result = f(n, k, s);
    cout << result << endl;

    return 0;
}


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

int f(int x) {
    printf("%d\n", x); fflush(stdout);
    char buf[255];
    scanf("%s", buf);
    if (buf[0] == 'V') exit(0);
    return buf[0] == 'M';
}
int main() {
    int N; scanf("%d", &N);
    int L = 0, Lt = f(L);
    int R = N - 1, Rt = f(R);
    while (1) {
        int M = (L + R) / 2;
        int v = f(M);
        if (abs(L - M) % 2 != abs(Lt - v) % 2) {
            R = M;
            Rt = v;
        }
        else {
            L = M;
            Lt = v;
        }
    }
}

Measured memory_bytes: 3864
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		boolean result = false;
		for (int i = 1; i <= 9; i++) {
			for (int j = 1; j <= 9; j++) {
				if (i * j == n) {
					result = true;
				}
			}
		}
		System.out.println(result ? "Yes" : "No");
	}
}


Measured memory_bytes: 23764
/* ****TCIITB**** */

#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

#define N  100005

int main()
{
	
	io
	
	ll n,m,k;
	cin>>n>>m>>k;
	ll arr[n][m];
	rep(i,0,n)
	{
		string x;
		cin>>x;
		rep(j,0,m)
		{			
			arr[i][j]=(x[j]-'0');			
		}
	}
	ll res=1e18;
	rep(i,0,(1<<(n))+1)
	{
		// ll i=3;
		std::vector<ll> idx;
		ll cnt=0;		
		rep(j,0,n-1)
		{
			if((1<<j) & (i))
			{
				idx.pb(j);
				cnt++;
			}
		}
		std::vector<pii> fr;
		ll curr=0;		
		rep(j,0,idx.size())
		{
			if(j==0)
			{
				fr.pb({0,idx[0]});
				curr=idx[j]+1;
				// continue;
			}
			if(j!=0)
			{
				fr.pb({curr,idx[j]});
				curr=idx[j]+1;
			}
			if(j==(idx.size()-1))
			{
				fr.pb({curr,n-1});
				continue;
			}
			
		}
		ll cj=0;
		ll fl=0;
		if(fr.size()==0)
		{
			fr.pb({0,n-1});
		}
		// cout<<i<<endl;
		// for(auto ii:fr)
		// {
		// 	cout<<ii.F<<" "<<ii.S<<endl;
		// }
		// cout<<endl;
		while(1)
		{
			ll mn=1e18;
			cnt++;
			for(auto j:fr)
			{
				ll c1=-1;
				ll ss=0;
				rep(kk,cj,m)
				{
					rep(ii,j.F,j.S+1)
					{
						ss+=arr[ii][kk];
					}
					if(ss<=k)
						c1=kk;
					else
						break;
				}
				if(c1==-1)
				{
					fl=1;
					break;
				}
				mn=min(mn,c1);
			}
			if(fl)
				break;

			cj=mn+1;
			// cout<<i<<" "<<cj<<endl;
			if(cj>=m)
				break;
		}
		if(!fl)
		{
			res=min(res,cnt);
		}
		// cout<<endl;



	}
	cout<<max(0ll,res-1);







}

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

int main(){
	int i,j;
	char map[10][11];

	memset(map,'0',sizeof(map));

	while(scanf("%c%c%c%c%c%c%c%c",&map[0][1],&map[0][2],&map[0][3],&map[0][4],&map[0][5],&map[0][6],&map[0][7],&map[0][8]) != EOF){
		getchar();
		for(i = 1;i < 8;i++){
			for(j = 1;j <= 8;j++){
				scanf("%c",&map[i][j]);
			}
			getchar();
		}
		getchar();

		for(i = 0;i < 8;i++){
			for(j = 1;j <= 8;j++){
				if(map[i][j] == '1'){
					if(map[i+2][j] == '1'){
						printf("B\n");
					}else if(map[i][j+2] == '1'){
						printf("C\n");
					}else if(map[i+1][j-1] == '1'){
						if(map[i+2][j-1] == '1'){
							printf("D\n");
						}else{
							printf("G\n");
						}
					}else if(map[i+1][j+2] == '1'){
						printf("E\n");
					}else if(map[i+2][j+1] == '1'){
						printf("F\n");
					}else{
						printf("A\n");
					}
					i = 8;
					break;
				}
			}
		}
	}

	return 0;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};

int main(){
  ll N; cin >> N;
  Vi a(N);
  REP(i, N) cin >> a[i];
  for(ll i = N - 1; i >= 0; i = i - 2){
    cout << a[i] << ' ';
  }
  for(ll i = N % 2; i < N; i = i + 2){
    cout << a[i] << ((i == N - 2) ? "\n" : " ") ;
  }
}


Measured memory_bytes: 3712
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long N = scan.nextLong();
        Set<Long> divisors = new HashSet<>();
        for (long i = 1; i * i <= N-1; i++) {
            if ((N - 1) % i != 0) {
                continue;
            }
            if (i != 1) {
                divisors.add(i);
            }
            if (1 < (N - 1) / i) {
                divisors.add((N - 1) / i);
            }
        }
        List<Long> list = new ArrayList<>();
        for (long i = 1; i * i <= N; i++) {
            if (N % i != 0) {
                continue;
            }
            if (i != 1) {
                list.add(i);
            }
            if (1 < N / i) {
                list.add(N / i);
            }
        }
        for (long i : list) {
            long target = N;
            while (target % i == 0) {
                target /= i;
            }
            target -= ((target - i) / i) * i;
            while (i <= target) {
                target -= i;
            }
            if (target == 1) {
                divisors.add(i);
            }
        }
        divisors.remove(1);
        System.out.println(divisors.size());
    }
}


Measured memory_bytes: 38412
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

using T = tuple<int, int, int>;

signed main() {
	int i, o, t, j, l, s, z; cin >> i >> o >> t >> j >> l >> s >> z;

	int a = o + (i / 2 + j / 2 + l / 2) * 2;
	int b = 0;
	if (i && j && l) {
		i--; j--; l--;
		b = o + (i / 2 + j / 2 + l / 2) * 2 + 3;
	}

	cout << max(a, b) << endl;

	system("pause");
}

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

#define PI 3.141592653589793238462;

int main(){
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double ak = (h+m/60)*30;
    double bk = 6*m;
    double k = abs(ak-bk)>180?360-abs(ak-bk):abs(ak-bk);
    k= k/180*PI;
    double ans = a*a + b*b - 2*a*b*cos(k);
    ans = abs(ans);
    ans = pow(ans,0.50);
    cout << fixed << setprecision(20) << ans << endl;
    return 0;
}

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

using namespace std;

bool vis[100002];
int dp[100003];

map<int,vector<int>> mapy;

void dfs(int i)
{
    vis[i]=true;
    for(auto node : mapy[i])
    {
        if(!vis[node])
        dfs(node);
        dp[i]=max(dp[i],dp[node]+1);
    }

}
int main()
{
    for(int i=0;i<=100000;i++)
    vis[i]=false;
    for(int i=0;i<=100000;i++)
    dp[i]=0;
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        mapy[a].push_back(b);
    }
    for(int i=1;i<=n;i++)
    {
        if(vis[i]==false)
        dfs(i);
    }
    int miny=0;
    for(int i=1;i<=n;i++)
    {
        miny=max(miny,dp[i]);
    }
    cout<<miny<<endl;
}


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

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

  int N;
  cin >> N;
  vector<int64_t> A(N);
  rep(i, N){
    cin >> A[i];
  }
  int64_t ans = A[0];
  for(int i=1;i<N;i++){
    ans = max(ans, A[i]) / __gcd(ans, A[i]) * min(ans, A[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	int X, Y, Z; cin >> X >> Y >> Z;
	cout << (X - 2 * Z - Y) / (Y + Z) + 1 << endl;
	return 0;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int a , b;
string s , t , u;

int main()
{
    _FastIO;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        cout << 'x';
    }
    cout << endl;
    return 0;
}


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

uint64_t get_size(uint64_t n) {
  return n % 6 % 5 == 0 ? (n - 1) / 3 : (n / 6) * 2;
}

std::vector<int> generate_primes(uint64_t upperbound) {
  uint64_t sieve_size = get_size(upperbound);
  std::vector<bool> sieve(sieve_size, true);
  uint64_t limit = get_size(sqrt(upperbound));

  for(uint64_t i = 0; i != limit; ++i) {
    int p = i * 3 - (i & 1) + 5;
    uint64_t j;
    for(j = p * 2; j < sieve_size - i; j += p * 2) {
      sieve.at(j + i) = false;
      sieve.at(j - i - 3) = false;
    }

    if(j < sieve_size + i + 3) {
      sieve.at(j - i - 3) = false;
    }
  }

  std::vector<int> ret;
  ret.push_back(2);
  ret.push_back(3);

  for(uint64_t i = 0; i < sieve_size; ++i) {
    if(sieve.at(i))
      ret.push_back(i * 3 - (i & 1) + 5);
  }

  return ret;
}

int main(void) {
  int n;
  std::cin >> n;

  int x;
  std::vector<int> xs;
  for(int i = 0; i < n; ++i) {
    std::cin >> x;
    xs.push_back(x);
  }

  std::sort(xs.begin(), xs.end());
  auto primes = generate_primes(xs.back());

  int count =
    std::count_if(xs.begin(), xs.end(), [&](auto x) { return std::binary_search(primes.begin(), primes.end(), x); });

  std::cout << count << std::endl;

  return 0;
}

Measured memory_bytes: 40056
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;

int divisor(int n){
    int cnt=0;
    for(int i=1; i<=n; i++){
        if (n % i == 0)cnt++;
    }
    return cnt;
}

int main(){
    int n;
    cin >> n;
    int ans=0;
    for(int i=1; i<=n; i+=2){
        if(divisor(i) == 8) ans++;
        
    }
    out(ans);

}

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

int X[100010], W[100010], ans[100010], irek[100010];
vector<int> cw, aw;

int main() {
	ll N, L, T;
	cin >> N >> L >> T;
	for(int i=0; i<N; ++i){
		cin >> X[i] >> W[i];
		if(W[i]==1) cw.emplace_back(i);
		else aw.emplace_back(i);
	}
	if(aw.empty()){
		for(int i=0; i<N; ++i){
			cout << (X[i]+T%L)%L << endl;
		}
	}else if(cw.empty()){
		for(int i=0; i<N; ++i){
			cout << (X[i]+L-T%L)%L << endl;
		}
	}else{
		ll q=((T/L)*2)%N, r=T%L;
		if(r*2>=L){
			q=(q+1)%N;
			r -= (L+1)/2;
		}
		for(int i=0; i<N; ++i){
			if(W[i]==1){
				ans[i]=(X[i]+T%L)%L;
				int t=distance(aw.begin(), upper_bound(aw.begin(), aw.end(), i));
				int ok=-1, ng=aw.size();
				while(ok+1<ng){
					int mid=(ok+ng)/2, dis;
					dis=X[aw[(t+mid)%aw.size()]]-X[i];
					if(dis<0) dis += L;
					if(dis<=r*2) ok=mid;
					else ng=mid;
				}
				irek[(q*aw.size()+ng+i)%N]=i;
			}else{
				ans[i]=(X[i]+L-T%L)%L;
				int t=distance(cw.begin(), upper_bound(cw.begin(), cw.end(), i));
				(t += cw.size()-1) %= cw.size();
				int ok=-1, ng=cw.size();
				while(ok+1<ng){
					int mid=(ok+ng)/2, dis;
					dis=X[i]-X[cw[(t+cw.size()-mid)%cw.size()]];
					if(dis<0) dis += L;
					if(dis<=r*2) ok=mid;
					else ng=mid;
				}
				irek[(i+N-(q*cw.size()+ng)%N)%N]=i;
			}
		}
		for(int i=0; i<N; ++i){
			cout << ans[irek[i]] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
 
// vector<int> vec(3); = vector<int> vec={0,0,0}
// vec.at()
// sort(num.begin(),num.end(), greater<int>());
// reverse(num.begin(),num.end());

// 切り上げ　a/b+1
 
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  int flag =0;
  
  if(A == 5 && B == 7 && C == 5){
    flag = 1;
  }else if(A == 7 && B == 5 && C ==5){
  	flag = 1;
  }else if(A == 5 && B == 5 && C == 7){
  	flag = 1;
  }else{
  	flag = 0;
  }
  if(flag){
  	cout << "YES" << endl;
  }else{
  	cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);

		int[] ab = new int[2001];
		
		for (int i = 0; i < 1001; i++) {
			for (int j = 0; j < 1001; j++) {
				ab[i + j]++;
			}
		}
		
		while (sc.hasNextLine() == true) {
			int sum = Integer.parseInt(sc.nextLine());
			
			int ans = 0;
			
			for (int i = 0; i < (sum + 1); i++) {
				if ((sum - i) > 2000) continue;
				if (i > 2000) break;
				
				ans = ans + ab[i] * ab[sum - i];
			}
			
			System.out.println(ans);
		}
	}
}

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

int main(){
    const ll mod=998244353;
    int n;
    cin>>n;
    vector<int>d(n);
    map<int,int>mp;
    rep(i,n){
        cin>>d[i];
        mp[d[i]]++;
    }
    bool ok=true;
    if(d[0]!=0)ok=false;
    if(mp[0]!=1)ok=false;
    if(ok==false){cout<<0<<endl; return 0;}
    ll ans=1;
    for(int i=1; i<n; ++i){
        ans*=mp[d[i]-1];
        ans%=mod;
    }
    cout<<ans<<endl;
}


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

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)
// int fact[3001];
// int binExp(int x,int n)
// {
//     int res=1;
//     while(n)
//     {
//         if(n&1) res=(res*x)%mod;
//         x=(x*x)%mod;
//         n>>=1;
//     }
//     return res;
// }
// int modInv(int i) {return binExp(i,mod-2);}
// int ncr(int n,int r) {return (fact[n]*modInv(fact[r]))%mod*modInv(fact[n-r])%mod;}

signed main()
{
    fast

    #ifndef ONLINE_JUDGE
        freopen("inputf.in","r",stdin);
        freopen("outputf.in","w",stdout);
    #endif

    
    int n;
    cin>>n;

    int a[n],b[n];
    f0(i,0,n) cin>>a[i];
    f0(i,0,n) cin>>b[i];

    vi cnta(n+1,0);
    vi cntb(n+1,0);

    f0(i,0,n)
    {
        cnta[a[i]]++;
        cntb[b[i]]++;
    }

    f1(i,1,n)
    {
        if(cnta[i] + cntb[i] > n)
        {
            cout<<"No";
            return 0;
        }
    }

    f1(i,1,n)
    {
        cnta[i] += cnta[i-1];
        cntb[i] += cntb[i-1];
    }

    int shift = 0;
    f1(i,1,n)
    {
        shift = max(shift, (ll)cnta[i] - cntb[i-1]);
    }

    cout<<"Yes\n";
    f0(i,0,n) cout<<b[(i - shift + n)%n]<<' ';
}

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

int d[1006][1006];
int meter(char *a,int k,char *b,int l){

  int i,j;

  i=0;
  while(i<k+1){
    d[i][0]=0;
    i++;
  }
  j=0;
  while(j<l+1){
    d[0][j]=0;
    j++;
  }

  for(i=1;i<k+1;i++){
    for(j=1;j<l+1;j++){
      if(a[i-1]==b[j-1]){
	d[i][j]=d[i-1][j-1]+1;
      }
      else if(d[i-1][j]>=d[i][j-1]){
	d[i][j]=d[i-1][j];
      }
      else{
	d[i][j]=d[i][j-1];
      }
    }
  }
  return d[k][l];
}

char a[1006],b[1006];

int main(){
  char *p;
  int r,f,g;

  fgets(a,10,stdin);
  r=atoi(a);
  while(r--){
    fgets(p=a,1006,stdin);
    while(*p>' ')
      p++;
    *p=0;
    f=p-a;

    fgets(p=b,1006,stdin);
    while(*p>' ')
      p++;
    *p=0;
    g=p-b;

    printf("%d\n",meter(a,f,b,g));
  }
  return 0;
}



Measured memory_bytes: 5600
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a,b;
	while(cin>>a>>b){
	int t=8500;
	for(int i=t;i;i--){
		for(int j=i;j;j--){
			if(i+j==2)a+=b;
		}
	}
	int cnt=0;
	while(a)a/=10,cnt++;
	cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
long long int modpow(long long N, long long P, long long M) {//Nのp乗modM;
    long long count_prs = 0;
    ++count_prs;
    if (P == 0) return 1;
    if (P % 2 == 0) {
        long long t = modpow(N, P / 2, M);
        return t * t % M;
    }
    return N * modpow(N, P - 1, M);
}
int main() {
	//Nが奇数の場合，0が１名と2,4,…(N-1)/2がそれぞれ2名。
	//偶数の場合，1,3,5,…N/2がそれぞれ２名。
	int N,M;
    cin >> N;
    vector<int>A(N+1);
    for (size_t i = 0; i < N; i++)
    {
        cin >> M;
        A.at(M)++;
    }
    if (N % 2) {
        if (A.at(0) != 1) {
            cout << 0;
            return 0;
        }
    }
        for (size_t i = 1; i <= N/2; i++) {
            if (A.at(i) != 2 * ((i + N%2) % 2)) {
                cout << 0;
                return 0;
            }
        }
        cout << modpow(2, N / 2, mod);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 2000000010;
constexpr ll INF= 2000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;
typedef pair<int,P> PP;

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;
}

ll mod(ll val, ll M) {
    ll res = val % M;
    if(res < 0) {
        res += M;
    }
    return res;
}

template<typename T>
T RS(T N, T P, T M){
    if(P == 0) {
        return 1;
    }
    if(P < 0) {
        return 0;
    }
    if(P % 2 == 0){
        ll t = RS(N, P/2, M);
        if(M == -1) return t * t;
        return t * t % M;
    }
    if(M == -1) {
        return N * RS(N,P - 1,M);
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    int M;
    cin >> M;
    ll Digit = 0;
    ll Sum = 0;
    for(int i = 0;i < M;i++) {
        ll A,B;
        cin >> A >> B;
        Digit += B;
        Sum += A * B;
    }
    cout << (Digit - 1ll) + (Sum - 1ll) / 9ll << endl;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(Math.abs(a - b) <= W){
			System.out.println("0");
		}else{
			System.out.println(Math.abs(a - b) - W);
		}
		

	}

}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vi A(n);
    rep(i,n-1){
        int a; cin>>a; a--;
        A[a]++;
    }
    rep(i,n) cout<<A[i]<<"\n";
    return 0;
}


Measured memory_bytes: 3936
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll f(ll x)
{ return x*x*x*x*x;
}
int main()
{   ll x,flag=0;
    cin>>x;
    for(ll i=-1000;i<=1000;i++)
    {  for(ll j=-1000;j<=1000;j++)
         { if(f(i)-f(j)==x)
           { printf("%lld %lld",i,j);
             flag=1;
             break;
           }
         }
        if(flag)break;
    }
    return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    string x;
    cin>>x;
    string a;
    int count=0;
    for(int i=0;i<x.length();i++){
        if (x[i]=='B'){
            if (count>0)
                count--;
        }
        else{
            a[count]=x[i];
            count++;
        }
    }
    //printf("%d\n",count);
   // printf("%c\n",a[0]);
    for(int i=0;i<count;i++){
       printf("%c",a[i]);
    }
}

Measured memory_bytes: 3588
/*
 * Copyright (c) 2006 Kamo Hiroyasu
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

/*
 *  An answer to ACM/ICPC Domestic Contest 2006 Problem B
 *	Organaize Your Train part II
 *
 *  Author: Kamo Hiroyasu <wd@ics.nara-wu.ac.jp>
 */

#include <iostream>
#include <string>
#include <set>

using namespace std;

int
count_configuration(const string &s)
{
	set<string>	ss;
	ss.insert(s);
	string		r(s.rbegin(), s.rend());
	ss.insert(r);
	for (string::size_type i = 1, l = s.length(); i < l; ++ i) {
		string	s0(s, 0, i);
		string	s1(s, i);
		string	r0(s0.rbegin(), s0.rend());
		string	r1(s1.rbegin(), s1.rend());
		ss.insert(s0 + r1);
		ss.insert(r0 + s1);
		ss.insert(r0 + r1);
		ss.insert(s1 + s0);
		ss.insert(s1 + r0);
		ss.insert(r1 + s0);
	}
	return ss.size();
}

int
main()
{
	int	n;
	string	str;
	for (cin >> n; n > 0 && cin >> str; n --) {
		cout << count_configuration(str) << endl;
	}
	return 0;
}



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

int main(){
    int N,T;
    cin >> N >> T;
    vector<int> t(N);
    for(int i = 0; i < N; i++){
        cin >> t.at(i);
    }
    int64_t ans = 0;
    for(int i = 0; i < (N - 1); i++){
        if ((t.at(i + 1) - t.at(i)) >= T){
            ans += T;
        }
        else {
            ans += (t.at(i + 1) - t.at(i));
        }
    }
    cout << ans + T << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 3e5+10;
const ll mod =   1e9+7;
ll pre[N],arr[N],k,n;
int main()
{  fast
cin>>n>>k;
for(int i=1;i<=n;i++)
cin>>arr[i];
while(k--){
	bool ans=true;
for(int i=1;i<=n;i++)
if(arr[i]!=n)
ans=false;
if(ans)
break;
for(ll i=1;i<=n;i++){
	ll x=max(1ll,i-arr[i]);ll y=min(n,arr[i]+i);
	pre[x]+=1;pre[y+1]-=1;
}
for(ll i=1;i<=n;i++)
pre[i]+=pre[i-1];
for(int i=1;i<=n;i++){
	arr[i]=pre[i];pre[i]=0;
}
}
for(ll i=1;i<=n;i++)
cout<<arr[i]<<" ";
}

Measured memory_bytes: 6700
#include <iostream>
int main()
{
    int k;
    std::cin >> k;

    int a,b,c,d,e,f,ans=0;

    for(int n=0;k-n!=0;n++)
    {
        for(int m=0;k-m!=0;m++)
        {
            for(int i=0;k-i!=0;i++)
            {
                a=k-i,b=k-m,c=k-n;
                if(a<b) e=a,a=b,b=e;
                d=a%b;
                while(d!=0){
                    a=b;
                    b=d;
                    d=a%b;
                }
    
                if(b<c) e=b,b=c,c=e;
                f=b%c;
                while(f!=0){
                    b=c;
                    c=f;
                    f=b%c;
                }
                ans += c;

            }
        }
    }

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

Measured memory_bytes: 3636
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long L[] = new long[N+1];
    L[0] = 2;
    L[1] = 1;
    for(int i=2;i<=N;i++){
      L[i] = L[i-1] + L[i-2];
    }
    System.out.println(L[N]);
  }
}


Measured memory_bytes: 21844
/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
int main()
{
    int a;
	cin>>a;
	if(a%10==2||a%10==4||a%10==5||a%10==7||a%10==9) cout<<"hon"<<endl;
	else if(a%10==0||a%10==1||a%10==6||a%10==8) cout<<"pon"<<endl;
	else cout<<"bon"<<endl;
	return 0;
}


Measured memory_bytes: 3592
def examA():
    N = 26
    D = I()
    C = LI()
    S = [LI()for _ in range(N)]
    ans = [0]*D

    for v in ans:
        print(v)
    return

def examB():
    N = 26
    D = I()
    C = LI()
    S = [LI()for _ in range(D)]
    T = [I()for _ in range(D)]
    ans = [0]*D
    used = [0]*N
    for i,t in enumerate(T):
        ans[i] += ans[i-1]
        t -= 1
        ans[i] += S[i][t]
        used[t] = i+1
        for j in range(N):
            ans[i] -= C[j]*(i+1-used[j])
    for v in ans:
        print(v)
    return

def examC():
    ans = 0
    print(ans)
    return


from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examB()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

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

using namespace std;

int main(){
  int n; cin >> n;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  //i番目に到達するために必要なコストの最小値をdp[i]とする。
  int dp[n];
  //dpテーブルの初期化
  dp[0]=0;
  dp[1]=0;
  dp[2]=abs(h[1]-h[0]);
  for(int i=2;i<n;i++){
    dp[i+1]=min(dp[i]+abs(h[i]-h[i-1]),dp[i-1]+abs(h[i]-h[i-2]));
  }
  cout << dp[n] << endl;
}


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

void Main()
{
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


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

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pr pair<int,int>
#define SZ(S) int(S.size())
#define REP(i,a,b) for(int i=a;i<b;++i)
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define FORD(i,b,a) for(int i=b;i>=a;--i)
#define CLR(A,x) memset(A,x,sizeof(A))
#define ALL(S) S.begin(),S.end()

#define OUT(a,l,r) cout<<#a": ";FOR(i,l,r)cout<<a[i]<<" ";cout<<endl
#define PRT(a) cout<<"--> "#a" "<<a<<endl

using namespace std;
typedef long long ll;

const int N=100005,INF=0x3f3f3f3f;
const ll P=1e9+7;

template<typename T>
inline void read(T& x,int f=1,char s=getchar()) {
	for(x=0;s>'9'||s<'0';s=getchar()) if(s=='-') f=-1; 
	while(s<='9'&&s>='0') x=x*10+s-'0',s=getchar();x*=f;
}

int main() {
	int n,m,k;
	cin>>n>>m>>k;
	FOR(a,0,n) {
		FOR(b,0,m) {
//			cout<<a<<" "<<b<<" "<<a*m+b*n-2*a*b<<endl;
			if(a*m+b*n-2*a*b==k) {
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]
a=sorted(a,reverse=True)
turn=True
b,c=0,0
for i in range(n):
  if turn:
    b+=a[i]
    turn=False
  else:
    c+=a[i]
    turn=True
print(abs(b-c))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define len(x) (int) (x.size())
using namespace std;
typedef long long ll;

int main(){
    int n, k;
    string s;
    cin >> n >> k >> s;

    s[k-1] = s[k-1]+32;
    cout << s << '\n'; 
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n, k; cin >> n >> k;
    vector<pair<LL, LL>> xy(n);
    rep(i, n) {
        LL x, y; cin >> x >> y;
        xy[i] = {x, y};
    }
    set<int> xx, yy;
    for (auto e: xy) {
        xx.insert(e.first); yy.insert(e.second);
    }

    LL ans = -1;
    for (int sx: xx)
        for (int sy: yy)
            for (int tx: xx)
                for (int ty: yy)  if (sx <= tx and sy <= ty) {
                        LL sm = 1LL * (tx - sx) * (ty - sy);

                        int cnt = 0;
                        rep(i, n) if (sx <= xy[i].first
                                      and xy[i].first <= tx
                                      and sy <= xy[i].second
                                      and xy[i].second <= ty) cnt++;

                        if (k <= cnt) {
                            if (ans < 0) ans = sm;
                            ans = min(ans, sm);
                        }
                }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(a) a.begin(),a.end()
typedef complex<double> Point;
typedef vector<Point> VP;
#define X real()
#define Y imag()

double dot(Point a, Point b) {
  return a.X*b.X + a.Y*b.Y;
}

Point proj(Point a1, Point a2, Point p) {
  return a1 + dot(a2-a1, p-a1)/norm(a2-a1) * (a2-a1);
}

VP crosspointLC(Point a1, Point a2, Point c, double r) {
  VP ps;
  Point ft = proj(a1, a2, c);
  assert(r*r >= norm(ft-c));
  Point dir = sqrt(max(r*r - norm(ft-c), 0.0)) / abs(a2-a1) * (a2-a1);
  ps.push_back(ft + dir);
  ps.push_back(ft - dir);
  return ps;
}

namespace std {
  bool operator<(const Point a, const Point b) {
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
}

int main(void){
    double cx,cy,r;
    int q;
    cin>>cx>>cy>>r>>q;
    rep(i,q){
        double x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        VP ps = crosspointLC(Point(x1,y1),Point(x2,y2),Point(cx,cy),r);
        sort(all(ps));
        printf("%.9f %.9f " ,ps[0].X,ps[0].Y);
        printf("%.9f %.9f\n",ps[1].X,ps[1].Y);
    }
    return 0;
}

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

int main()
{
  string s;
  int count_o = 0, count_x = 0;

  cin >> s;
  for (int i = 0; i < s.size(); i++)
  {
    if(s[i] == 'x')
      count_x++;
  }

  if(count_x < 8)
    cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]
A_min = min(A)
A_max = max(A)
ans = N * (A_max - A_min) ** 2
for p in range(A_min, A_max + 1):
    cost = 0
    for a in A:
        cost += (a - p) ** 2
    if cost < ans:
        ans = cost
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
   string a,b,c;
    cin >> a >> b >> c;
    transform(a.begin(),a.end(),a.begin(),::toupper);
    transform(b.begin(),b.end(),b.begin(),::toupper);
    transform(c.begin(),c.end(),c.begin(),::toupper);
    cout << a[0] << b[0] << c[0] << endl;
    return 0;
}



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

using namespace std;

using llong = long long int;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000007;
const static int INF = 1<<30;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

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

    int n;
    cin >> n;
    map<pair<llong, llong>, llong> M;
    llong ans = 0;
    rep(i, n) {
        long double a;
        cin >> a;
        llong x = llround(a*1e9);
        int two = 0, five = 0;
        while (x % 2 == 0) {
            ++two;
            x /= 2;
        }
        while (x % 5 == 0) {
            ++five;
            x /= 5;
        }

        stl_rep(itr, M) if (itr->first.first + two >= 18 && itr->first.second + five >= 18) ans += itr->second;

        ++M[make_pair(two, five)];
    }

    /* llong ans = 0;
    for (auto itr1 = M.begin(); itr1 != M.end(); ++itr1) {
        for (auto itr2 = M.begin(); itr2 != M.end(); ++itr2) {
            cout << itr1->first.first*itr2->first.first << ' ' << itr1->first.second + itr2->first.second << endl;
            if (itr1->first.first*itr2->first.first >= 18 && itr1->first.second + itr2->first.second >= 18) {
                if (itr1 == itr2) ans += itr1->second*(itr2->second - 1)/2LL;
                else ans += itr1->second*itr2->second;
            }
        }
    } */

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3760
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
int MOD = 1000000007;

void piyo(int& a, int& b, int& c, int& d) {
	int tmp = a;
	a = b;
	b = c;
	c = d;
	d = tmp;
}

void hoge(vector<int>& a, char c) {
	switch (c) {
	case 'W': piyo(a[0], a[2], a[5], a[3]); break;
	case 'S': piyo(a[0], a[4], a[5], a[1]); break;
	case 'N': piyo(a[0], a[1], a[5], a[4]); break;
	case 'E': piyo(a[0], a[3], a[5], a[2]); break;
	}
}

int main() {
	int n; cin >> n;
	vector< vector<int> > a(n, vector<int>(6, INT_MAX));
	for (int i = 0; i < n; i++) {
		vector<int> b(6);
		for (int j = 0; j < 6; j++) cin >> b[j];
		for (int k = 0; k < 10000; k++) {
			a[i] = min(a[i], b);
			if (rand() % 2) hoge(b, 'N');
			else hoge(b, 'E');
		}
	}
	for (int i = 0; i < n; i++)
		for (int _i = i + 1; _i < n; _i++)
			if (a[i] == a[_i]) {
				cout << "No" << endl;
				return 0;
			}
	cout << "Yes" << endl;
}

Measured memory_bytes: 1220
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long n, k;
    scanf("%ld%ld", &n, &k);

    vector<pair<long,long> > zz;
    long i;
    for(i=0; i<n; i++) {
        long a,b;
        scanf("%ld%ld", &a, &b);
        zz.push_back( make_pair(a, b));
    }
    sort(zz.begin(), zz.end());

    ll count=0;
    for(i=0; i<n; i++) {
        count += zz[i].second;
        if(k<=count) {
            printf("%ld\n", zz[i].first);
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 2420
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class199
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            Dictionary<string, int> dic = new Dictionary<string, int>();
            for (int i = 0; i < N; i++)
            {
                string s = Console.ReadLine();
                if (dic.ContainsKey(s)) dic[s]++;
                else dic[s] = 1;
            }
            int M = int.Parse(Console.ReadLine());
            for (int i = 0; i < M; i++)
            {
                string t = Console.ReadLine();
                if (dic.ContainsKey(t)) dic[t]--;

            }
            int ans = 0;
            foreach (int i in dic.Values)
                ans = Math.Max(ans, i);
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int x = s.nextInt();
        byte[] a = new byte[3];
        while(s.hasNext()){
            for(int i=0;i<3;i++)
                a[i] = s.nextByte();                
            Arrays.sort(a);
            if(a[2]*a[2] == a[0]*a[0] + a[1]*a[1])
                System.out.println("YES");
            else
                System.out.println("NO");
        }
        
    }
}

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

#define nl                 "\n"
#define ll                 long long
#define pb                 push_back
#define pf                 push_front
#define np                 next_permutation
#define pp                 prev_permutation
#define sqr(x)             ((x)*(x))
#define pi                 acos(-1)
#define setprecision(x)    fixed<<setprecision((int)(x))
#define mem1(x)            memset(x,0,sizeof(x))
#define mem2(x)            memset(x,-1,sizeof(x))
#define all(x)             (x).begin(),(x).end()
#define sort1(x)           sort(all(x))
#define csort(x,c)         sort(all(x),c)
#define rsort(x)           sort(x.rbegin(),x.rend())

using namespace std;
void solve()
{
    int n;
    cin>>n;
    int a=ceil(n/1000.0);
    cout<<a*1000-n<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //int t; cin>>t; while(t--){solve();}
    solve();
    return 0;
}


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc =new Scanner(System.in);
		
		int a=sc.nextInt();
		int b=sc.nextInt();
		if((a+b)%2==1) {
			System.out.println("IMPOSSIBLE");
		}
		else {
			System.out.println((a+b)/2);
		}

}
	
	
	
}





Measured memory_bytes: 23252
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N = I()
A = III()

xor = 0
for i in range(N):
    xor ^= A[i]

for i in range(N):
    A[i] &= ~xor

max_digit = len(format(max(A), 'b'))
rank = 0
for col in range(max_digit)[::-1]:
    pivot = -1
    for row in range(rank,N):
        if A[row]>>col & 1:
            pivot = row
            break
    if pivot == -1: 
        continue
    A[pivot],A[rank] = A[rank],A[pivot]
    for row in range(rank+1,N):
        if A[row]>>col & 1:
            A[row] ^= A[rank]
    rank += 1

val = 0
for i in range(N):
    val = max(val,val^A[i])

print(2*val + xor)

Measured memory_bytes: 76016
#include<stdio.h>
int main(){
 int c=0;
char a[4];
scanf ("%s",a);
  for (int i=0;i<4;i++){
  if (a[i]=='+'){
  c=c+1;
  }
  else if (a[i]=='-'){
  c=c-1;
  }
  }
  printf ("%d",c);

return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include <cstdio>
#include <algorithm>
#include <stack>

using namespace std;

#define maxa 1400+10

struct Rectangle {
	int height;
	int pos;
};

int we(int size, int buffer[]) {
	int i;
	stack<Rectangle> S;
	int maxv=0;
	buffer[size]=0;

	for(i=0; i<=size; i++) {
		Rectangle rect;
		rect.height=buffer[i];
		rect.pos=i;
		if(S.empty()) {
			S.push(rect);
		} else {
			if(S.top().height < rect.height) {
				S.push(rect);
			} else if(S.top().height > rect.height) {
				int target = i;
				while(!S.empty() && S.top().height > rect.height) {
					Rectangle pre = S.top();
					S.pop();
					int area = pre.height * (i - pre.pos);
					maxv=max(maxv, area);
					target = pre.pos;
				}
				rect.pos=target;
				S.push(rect);
			}
		}
	}
	return maxv;
}

int H,W;
int buffer[maxa][maxa];
int T[maxa][maxa];

int solve() {
	int i,j;

	for(j=0; j<W; j++)
		for(i=0; i<H; i++) {
			if(buffer[i][j]==1) T[i][j]=0;
			else {
				T[i][j]=(i>0) ? T[i-1][j]+1 : 1;
			}
		}

	int maxv=0;

	for(i=0; i<H; i++) {
		maxv=max(maxv,we(W,T[i]));
	}

	return maxv;
}

int main() {
	int i,j;

	scanf("%d %d",&H,&W);

	for(i=0; i<H; i++) {
		for(j=0; j<W; j++) {
			scanf("%d",&buffer[i][j]);
		}
	}

	printf("%d\n",solve());

	return 0;
}


Measured memory_bytes: 18648
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n;
		String s;
		n = sc.nextInt();
		s = sc.next();

		int ans = 0;
		for (int i = 1; i < s.length(); i++) {
			int tmp = check(s.substring(0, i), s.substring(i));
			ans = Math.max(ans, tmp);
		}
		System.out.print(ans);
	}

	static int check(String s, String t) {
		int[] a = new int[26];
		int[] b = new int[26];
		int cnt = 0;
		for (int i = 0; i < s.length(); i++) {
			int num = s.charAt(i) - 'a';
			a[num] = 1;
		}
		for (int i = 0; i < t.length(); i++) {
			int num = t.charAt(i) - 'a';
			b[num] = 1;
		}
		for (int i = 0; i < 26; i++) {
			if(a[i] == 1 && b[i] == 1) cnt++;
		}

		return cnt;
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int n;
    cin >> n;
    
    int ans = (1000 - (n % 1000)) % 1000;
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3620
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

ll expo(ll a, ll b){
    ll ex = 1;
    rep(i, b){
        ex *= a;
    }
    return ex;
}

ll fact(ll a){
    ll fc = 1;
    REP(i, 1, a+1){
        fc *= i;
    }
    return fc;
}

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if(abs(a-c)<=d) {
        cout << "Yes" << endl;
    }
    else if(abs(a-b)<=d && abs(b-c)<=d) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
using ll = long long;
 
int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  sort(l.begin(),l.end());
  //int x=n-1;
  int count=0;
  //if(n<3) cout << 0 << endl;
  //else{
  for(int i=0; i<n-2; i++){
    for(int j=i+1; j<n-1; j++){
      for(int k=j+1; k<n; k++){
        if(l[i]!=l[j] && l[i]!=l[k] && l[j]!=l[k]){
          if(l[i]+l[j]>l[k]) count++;
        }
      }
    }
  }
  //}
  cout << count << endl;
}

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

class Program
{
    static void Main(string[] args) {
        string[] str = Console.ReadLine().Split().ToArray();
        Stack<int> s = new Stack<int>();
        for (int i = 0; i < str.Length; i ++) {
            if (str[i]=="+") s.Push(s.Pop() + s.Pop());
            else if (str[i]=="-") s.Push((s.Pop() - s.Pop()) * -1);
            else if (str[i]=="*") s.Push(s.Pop() * s.Pop());
            else s.Push(int.Parse(str[i]));
        }
        Console.WriteLine(s.Pop());
    }
}


Measured memory_bytes: 18764