akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

func main() {
	group := []int{0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1}
	var x, y int
	fmt.Scanf("%d %d", &x, &y)
	if group[x] == group[y] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

int main () {
    int a, b;
    cin >> a >> b;
    vector<string> vec(a);
    for (int t = 0; t < a; t++) {
        cin >> vec.at(t);
    }
    for (int t = 0; t < b+2; t++) {
        cout << '#';
    } cout << endl;
    
    for (int t = 0; t < a; t++) {
        cout << '#' << vec.at(t) << '#' << endl;
    }
    
    for (int t = 0; t < b+2; t++) {
        cout << '#';
    } cout << endl;
}


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

left = 1
right = n
cnt = []
while n % 2 == 0:
    n //= 2
    cnt.append(2)

f = 3
while f * f <= n:
    if n % f == 0:
        n //= f
        cnt.append(f)
    else:
        f += 2

cnt.append(n)

for i in range(len(cnt)):
    left *= cnt[i]
    right //= cnt[i]
    if left < 10 and right < 10:
        print('Yes')
        exit()
print('No')

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

int main(){
  long long L,R;
  cin >> L >> R;
  if(R-L+1>=2020) R = L+2018;
  
  long long ans = 2020;
  for(long long i=L;i<=R;i++){
    for(long long j=i+1;j<=R;j++){
      ans = min(ans,(i*j)%2019);
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int A, B, C, tmp;
  scanf("%d %d %d", &A, &B, &C);
  if(B > A){
    tmp = A; A = B; B = tmp;
  }
  if(C > B){
    tmp = C; C = B; B = tmp;
  }
  if(B > A){
    tmp = A; A = B; B = tmp;
  }
  printf("%d\n", 10*A + B + C);
  return 0;
}


Measured memory_bytes: 128
//Dictionary

#include<stdio.h>
#include<string.h>
#define N 1000000
#define M 14

char arr[N][M];

int a2c(char word)
{
  if(word == 'A') return 1;
  else if(word == 'C') return 2;
  else if(word == 'G') return 3;
  else if(word == 'T') return 4;
  else return 0;
}

int makeK(char word[])
{
  int sum = 0,i,x = 1;

  for(i = 0; i < strlen(word); i++)
    {
      sum += x*(a2c(word[i]));
      x *= 5;
    }
  return sum;
}

int h1(int key)
{
  return key % N;
}

int h2(int key)
{
  return 1 + (key % (N - 1));
}

int insert(char word[])
{
  int key,i,h;
  key = makeK(word);

  for(i = 0; ; i++)
    {
      h = (h1(key) + i * h2(key)) % N;
      if(strcmp(arr[h],word) == 0) return 1;
      else if(strlen(arr[h]) == 0)
	{
	  strcpy(arr[h],word);
	  return 0;
	}
    }
  return 0;
}

int find(char word[])
{
  int key,i,h;
  key = makeK(word);

  for(i = 0; ; i++)
    {
      h = (h1(key) + i * h2(key)) % N;
      if(strcmp(arr[h],word) == 0) return 1;
      else if(strlen(arr[h]) == 0) return 0;
    }
  return 0;
}

int main()
{
  int i,n;
  char order[M],word[10];
  
  //initialize array
  for(i = 0; i < N; i++) arr[i][0] = '\0';

  //input data
  scanf("%d",&n);
  for(i = 0; i < n; i++)
    {
      scanf("%s %s",order,word);

      //work
      if(order[0] == 'i')
	{
	  insert(word);
	}else{
	if(find(word))
	  {
	    printf("yes\n");
	  }
	else printf("no\n");
      }
    }

  return 0;
}



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

int main () {
    int N, M, X, Y;
    int max_x = -200;
    int min_y = 200;
    cin >> N >> M >> X >> Y;
    for (int i = 0; i < N; i++) {
        int x = 0; cin >> x;
        max_x = max(max_x, x);
    }
    for (int i = 0; i < M; i++) {
        int y = 0; cin >> y;
        min_y = min(min_y, y);
    }
    if ( min_y - max_x > 0) {
        int z = max_x + 1;
        if (X < z && Y >= z) {
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int n;

    cin >> n;

    int h[n+1][4], i, j;

    for(i = 1 ; i <= n ; i++)
    {
        for(j = 1 ; j <= 3 ; j++)
        {
            cin >> h[i][j];
        }
    }

    int dp[n+1][4];
    dp[1][1] = h[1][1];
    dp[1][2] = h[1][2];
    dp[1][3] = h[1][3];

    for(i = 2 ; i <= n ; i++)
    {
        dp[i][1] = max(dp[i-1][2], dp[i-1][3]) + h[i][1];
        dp[i][2] = max(dp[i-1][1], dp[i-1][3]) + h[i][2];
        dp[i][3] = max(dp[i-1][2], dp[i-1][1]) + h[i][3];
    }

    cout << max(dp[n][1], max(dp[n][2], dp[n][3]));
    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll mod = 1e9+7;
const ll INF = ll(1e18)+1;
const ll MAXN = 1e6;

int main()
{
    ll a,b;
    cin>>a>>b;
    if(a>b)swap(a,b);
    ll ans=abs(a-b);

    if(ans%2==0)
    {
        cout<<abs(ans/2+a);
    }
    else
    {
        cout<<"IMPOSSIBLE";
    }
    
}

Measured memory_bytes: 256
def main14():
    buf = input("");
    bufs = buf.split();
    hai = [];
    for i in range(len(bufs)):
        hai.append(int(bufs[i]));
    if hai[1] - hai[0] == hai[2] - hai[1]:
        print("YES");
    else:
        print("NO");

if __name__ == '__main__':
    main14()

Measured memory_bytes: 3060
/*
g++ -std=c++11 -o2 -Wall ABC099D.cpp -o ./out/ABC099D.out
./out/ABC099D.out
*/

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

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define tr(c, i) for (iter(c) != (c).begin(); i != (c).end(); ++i)
#define pb push_back
#define mp make_pair

typedef long long ll;

int n,C;
int d[30][30];
int c[500][500];
long a[3][30];

int main(){
//    freopen("./input/input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin>>n>>C;
    for(int i=0;i<C;i++)for(int j=0;j<C;j++)cin>>d[i][j];
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)cin>>c[i][j];
    for(int i=0;i<3;i++)
    {
      for(int j=0;j<C;j++)
      {
        for(int k=0;k<n;k++)for(int l=0;l<n;l++)if((k+l)%3==i)a[i][j]+=d[c[k][l]-1][j];
      }
    }
    long ans=1e15;
    for(int i=0;i<C;i++)for(int j=0;j<C;j++)for(int k=0;k<C;k++)
    {
      if(i==j||i==k||j==k)continue;
      ans=min(ans,a[0][i]+a[1][j]+a[2][k]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1280
from collections import Counter

def main():
    N = int(input())
    numList = list(map(int, input().split()))

    counter = Counter(numList)
    
    ans = 0
    for k, v in counter.items():
        if(k == v):
            continue
        elif(k < v):
            ans += v-k
        elif(k > v):
            ans += v

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 18676
program main
implicit None
	integer::s,p,n
	
	read*,s
	
	p = 1
	do
		if(s == 4 .or. s == 1 .or. s ==2)then
			print "(i0)",p+3
			stop
		endif
		if(mod(s,2) == 0)then
			s = s/2
			else
			s = s*3+1
		endif
		p = p+1
	enddo
end program main

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int K;
	cin >> K;
	string ans;
	REP(i, K) ans += "ACL";
	cout << ans << endl;
	return 0;
}


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

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

    if (a == b)
    {
        cout << "Draw" << endl;
    }
    else if (a == 1 or (a > b and b != 1))
    {
        cout << "Alice" << endl;
    }
    else
    {
        cout << "Bob" << endl;
    }
}

Measured memory_bytes: 256
//この講義の第６回講義資料の4, 5, 6ページ、教科書の158, 159, 160, 163ページを参照しながらプログラムを作成しました。
//また、Visual Studio Codeを用いて、作成したプログラムがどのように実行されるかを確かめたりもしました。
//この問題が解けないと第６回の他の課題も解けないと考えたので、教科書228ページの模範解答を参照しました。
#include <cstdio>
#include <cctype>

int main(){
    char a;
    while(a != '\n'){
        scanf("%c", &a);
        if (isupper(a)){
            printf("%c", tolower(a));
        } else if (islower(a)){
            printf("%c", toupper(a));
        } else {
            printf("%c", a);
        }
    }
}


Measured memory_bytes: 2572
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include<cmath>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100000000;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
const int MOD = 1000000007;



int par[100001];

void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
	}
}
//木の根を求める
int root(int x) {
	if (par[x] == x)
		return x;
	else {
		return par[x] = root(par[x]);
	}
}
//find
bool same(int x, int y) {
	return root(x) == root(y);

}
//union
void unite(int x, int y) {
	x = root(x);
	y = root(y);
	if (x == y) return;
	if (x < y) {
		par[y] = x;
	}
	else {
		par[x] = y;
	}
}


int main() {
	ll i, j, k, l, m, n, sum, flag, cc, M, X, N, Y, Z, K,x,y,z;
	sum = 0;
	flag = cc = 0;
	cin >> N>>K;
	char S[51];
	cin >> S;
	S[K - 1] = S[K - 1] - 'A' + 'a';
	output(S);
}








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

int main() {
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int ans = 0;
    int x = 0;
    for (int i = 0; i < n - 1; i++) {
        ans += a[i + 1] - a[i];
        x = max(x, a[i + 1] - a[i]);
    }
    ans += k - a[n - 1] + a[0];
    x = max(x, k - a[n - 1] + a[0]);
    cout << ans - x << endl;
}


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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

void trace(int a[], int n) {
  int i;
  rep(i, n) {
    if (i > 0) cout << " ";
    cout << a[i];
  }
  cout << endl;
}

void insertionSort(int a[], int n) {
  int i, j, v;
  FOR(i, 1, n) {
    v = a[i];
    j = i - 1;
    while (j >= 0 && a[j] > v) {
      a[j + 1] = a[j];
      j--;
    }
    a[j + 1] = v;
    trace(a, n);
  }
}

signed main() {
	int n, i, j;
  int a[100];

  cin >> n;
  rep(i, n) cin >> a[i];

  trace(a, n);
  insertionSort(a, n);

  return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    string s; cin >> s;
    int ans = 7;
    rep(i,3) if(s[i] == 'o') ans++;

    cout << ans*100 << endl;
}

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

#include <map>
#include <set>
#include <queue>
#include <stack>

#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdbl vector<double>
#define vstr vector<string>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int a,b,c;
	cin >> a >> b >> c;

	if(a <= c && c <= b) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
typedef long long ll;

using namespace std;

int n, m, fact[500001], invfact[500001], ans;

int add(int a, int b)
{
    return (a+b)%MOD;
}

int mul(int a, int b)
{
    return (ll(a)*ll(b))%MOD;
}

int exp(int a, int b = MOD-2)
{
    int ret = 1;
    while(b!=0)
    {
        if(b%2==1)
            ret = mul(ret,a);
        b/=2, a = mul(a,a);
    }
    return ret;
}

int ncr(int a, int b)
{
    return mul(mul(fact[a],invfact[b]),invfact[a-b]);
}

int main()
{
    cin >> n >> m;
    fact[0] = invfact[0] = 1;
    for(int i = 1; i<=m; i++)
        fact[i] = mul(fact[i-1],i), invfact[i] = exp(fact[i]);
    for(int i = 0; i<=n; i++)
    {
        int temp = mul(mul(mul(ncr(n,i),invfact[m-n]),invfact[m-n]),fact[m-i]);
        ans = add(ans,mul(1-2*(i%2),temp));
    }
    ans = mul(ans,fact[m]);
    cout << add(ans,MOD) << endl;
}


Measured memory_bytes: 7436
// Problem : A - Calc
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vstr vector<string>
#define vdb vector<double>
#define vbool vector<bool>
#define vvi vector<vector<int> >
#define mii map<int,int>
#define pb push_back
#define pii pair<int,int>
#define vpair vector<pii > 
#define mkp make_pair
#define scan(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) {cout<<a[i]<<' ';}cout<<'\n'
#define mem(a,v) memset(a,v,sizeof(a))
#define loop(i,a,b) for (int i = a; i < b; i++)
#define loope(i,a,b) for (int i = a; i <= b; i++)
#define bloop(i,a,b) for(int i = a;i>=b;i--)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::fixed );std::cout.precision(9)
#define PI 3.14159265
#define S second
#define F first
#define CHECK cout<<"CHEDEDWB"<<endl
#define CHECK1(a) cout<<a<<endl
#define CHECK2(a,b) cout<<a<<' '<<b<<endl;
#define br '\n'
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
using namespace std;
int mod = 1e9+7;
int inf = 1e18;
int m_inf = INT_MIN;
// int extendedgcd(int a,int b,int &x,int &y){
	// if(a == 0){
		// x = 0; y = 1;
		// return b;
	// }
	// int x1,y1;
	// int d = extendedgcd(b%a,a,x1,y1);
	// x = y1 - (b/a)*x1;y = x1;
	// return d;
// }
// int expmod(int a,int b) {
// 	if(b == 1) return a;
// 	if(b == 0) return 1;
// 	int m1 = expmod(a,b/2)%mod;
// 	if(b%2) return ((m1*m1)%mod*a%mod)%mod;
// 	return (m1*m1)%mod;
// }
// int power(int a,int b) {
// 	if(b == 1) return a;
// 	if(b == 0) return 1;
// 	int m1 = power(a,b/2);
// 	if(b%2) return m1*m1*a;
// 	return m1*m1;
// }
// int logn(int n, int r) 
// { 
//     return (n > r - 1) ? 1 + logn(n / r, r) : 0; 
// } 

// int nCr(int n,int r)
// {
	// r = min(r,n-r);
	// if(r<0)
		// return 0;
	// if(r == 0)
		// return 1;
	// int ans = 1;
	// for(int i = 1;i<=r;i++)
	// {
		// ans = ans*(n-i+1)/i;
	// }
	// return ans;
// 		
// }
// vi factmod(int n)
// {
	// vi ans(n+1);
	// ans[0] = 1;
	// loop(i,1,n+1)
	// {
		// ans[i] = (ans[i-1]*i)%mod;
	// }
	// return ans;
// }
// int nCrmod(int n,int r,vi &fact)
// {
	// int x1,y1;
	// extendedgcd(fact[r],mod,x1,y1);
	// int x2,y2;
	// extendedgcd(fact[n-r],mod,x2,y2);
	// int ans = (fact[n]*((x1+mod)%mod))%mod;
	// ans = (ans*((x2+mod)%mod))%mod;
	// return ans;
// }

// void dfs(vector<vector<int> > &adj,int root,vbool &vis)
// {
// 	vis[root] = true;
// 	for(int i = 0;i<adj[root].size();i++){
// 		int v = adj[root][i];
// 		if(!vis[v])		
// 			dfs(adj,v,vis);
// 	}
// }

int32_t main() 
{
	FastIO; PRECISION;
	int t = 1;
	// cin>>t;
	while(t--)
	{
		int a;
		cin>>a;
		cout<<(a+(a*a)+(a*a*a))<<'\n';
	}
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
int main()
{
	int i,j,k,ans=1,n=0;
	cin  >>  n;
	cin  >>  k;
	for(i = 0;i < n; i++)
	{
		if(ans * 2 < ans + k)
			ans*=2;
		else
			ans+=k;
	}
	cout<<ans;
	return 0;
}
	


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

int __counter__ = 0;

namespace std {

	void trace(vector<int> v) {
		for (int i = 0; i < v.size(); ++i) {
			if (i != v.size() - 1)
				cout << v[i] << " ";
			else
				cout << v[i] << endl;
		}
	}

	void merge(vector<int> &v, vector<int> &L, vector<int> &R) {
		vector<int>::iterator i = L.begin();
		vector<int>::iterator j = R.begin();	
		for (vector<int>::iterator x = v.begin(); x != v.end(); ++x){
			if (j == R.end() || i != L.end() && *i <= *j) {
				*x = *i;
				++i;
			}
			else{
				*x = *j;
				++j;
			}
			__counter__++;
		}
	}

	void merge_sort(vector<int> &v) {
		if (v.size() == 1)
			return;
		vector<int> L;
		vector<int> R;
		L.assign(v.begin(), v.begin() + (v.size() / 2));
		R.assign(v.begin() + (v.size() / 2), v.end());
		merge_sort(L);
		merge_sort(R);
		merge(v, L, R);
	}

}//std

int main() {
	{
		using namespace std;
		int n;
		cin >> n;
		vector<int> v;
		v.resize(n);
		for (int i = 0; i < n; i++)
			cin >> v[i];

		merge_sort(v);
		trace(v);
		cout << __counter__ << std::endl;

	}
}

Measured memory_bytes: 8800
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

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

    int ans = 0;
    for (auto i = 1; i <= n; i += 2) {
        int count = 0;
        for (auto j = 1; j <= i; j += 2) {
            if(i % j == 0) count++;
        }
        if(count == 8) ans++;
    }

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

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


def qSort(array):
    left = []
    right = []

    if len(array) <= 1:
        return array

    ref = array[0]
    array = array[1:]
    for a in array:
        if a < ref:
            left.append(a)
        else:
            right.append(a)

    return qSort(left) + [ref] + qSort(right)


if qSort(N) == [1, 4, 7, 9]:
    print("YES")
else:
    print("NO")


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

ll s;

ll gcd(ll x, ll y) {
    if (x < y) swap(x, y);
    x %= y;
    swap(x, y);
    s++;
    return y ? gcd(x, y) : x;
}

int main() {
    ll a, b;
    while (cin >> a >> b && !(a == 0 || b == 0)) {
        s = 0;
        ll g = gcd(a, b);
        cout << g << ' ' << s << endl;
    }
}


Measured memory_bytes: 2992
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int n,a,b;
  vector< pair<int,int> > vec;
  
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    vec.push_back(make_pair(a,b));
  }
  sort(vec.begin(),vec.end());
  
  for(int i=0;i<n;i++){
    cout << vec[i].first << " " << vec[i].second << endl;
  }

  return(0);
}



Measured memory_bytes: 3872
sx, sy, tx, ty = map(int, input().split())

dx = tx - sx
dy = ty - sy

r = ''
for i in range(dy):
  r += 'U'

for i in range(dx):
  r += 'R'
  
for i in range(dy):
  r += 'D'

for i in range(dx):
  r += 'L'

r += 'L'
for i in range(dy + 1):
  r += 'U'
for i in range(dx + 1):
  r += 'R'
r += 'D'
r += 'R'
for i in range(dy + 1):
  r += 'D'
for i in range(dx + 1):
  r += 'L'
r += 'U'

print(r)

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

int main(){
  int a,b;
  cin >> a >> b;
  int c;
  if(b < 10) c = a * 10 + b;
  else if(b < 100) c = a * 100 + b;
  else c = a * 1000 + b;
  for(int i = 1; i < c; i++){
    if(c == i * i){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3596
N = int(input())
P = [None] + list(map(int, input().split()))

p_to_index = [None] * (N + 1)
for index, x in enumerate(P[1:], 1):
    p_to_index[x] = index

#大きい数から挿入
#左隣にあるインデックスを取得できるようにする
#[1, i]内で書き込んだ数の個数を獲得できるBITを構築する

def BIT_add(i):
    while i <= N:
        tree[i] += 1
        i += i & (-i)

def BIT_sum(i):
    s = 0
    while i:
        s += tree[i]
        i -= i & (-i)
    return s

def BIT_search(x):
    i = 0
    s = 0
    step = 1 << (N.bit_length() - 1)
    while step:
        if i + step <= N and s + tree[i + step] < x:
            i += step
            s += tree[i]
        step >>= 1
    return i + 1

tree = [0] * (N + 1)
ans = 0
for x in range(N, 0, -1):
    c = p_to_index[x]
    L = BIT_sum(c) #左側にある既に書き込んだ数の個数
    BIT_add(c)
    R = N - x - L #右側にある既に書き込んだ数の個数
    a = BIT_search(L - 1) if L >= 2 else 0
    b = BIT_search(L) if L >= 1 else 0
    d = BIT_search(L + 2) if R >= 1 else N + 1
    e = BIT_search(L + 3) if R >= 2 else N + 1
    tmp = 0
    if b != 0:
        tmp += (b - a) * (d - c)
    if d != 0:
        tmp += (e - d) * (c - b)
    ans += tmp * x

print (ans)


Measured memory_bytes: 61128
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>
 
using namespace std;
typedef long long ll;


ll ans,mx,mn,sum;
int main(){
	int a,b,h;
	cin>>a>>b>>h;
	cout<<((a+b)*h)/2;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define N 100
#define I 1
#define O 0
#define T 2
#define TI 21

int Min(int,int);

int main(){
  int n,i,j,m,l;
  int P[N+I],M[N+I][N+I];

  scanf("%d",&n);
  for(i=I;i<=n;i++){
    scanf("%d%d", &P[i-I], &P[i]);
  }
  for(i=O;i<=n;i++){
    M[i][i]=O;
  }
  for(l=T;l<=n;l++){
    for(i=I;i<=n-l+I;i++){
      j=i+l-I;
      M[i][j]=I<<TI;
      for(m=i;m<=j-I;m++){
        M[i][j]=Min(M[i][j],M[i][m]+M[m+I][j]+P[i-I]*P[m]*P[j]);
      }
    }
  }

  printf("%d\n",M[I][n]);
  return 0;
}

int Min(int x,int y)
{
  if(x<y){
    return (x);
  }
  else{
    return (y);
  }
}



Measured memory_bytes: 2112
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

vector<int>pos[3];
set<int>t[3];

int main(void){
    int n;
    string s;
    cin>>n>>s;
    map<char,int>m;
    map<int,char>mi;
    m['R']=0;
    m['G']=1;
    m['B']=2;
    mi[0]='R';
    mi[1]='G';
    mi[2]='B';
    ll ans = 0;
    for(int i=0;i<n;i++){
        pos[m[s[i]]].push_back(i);
        t[m[s[i]]].insert(i);
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(i==j)continue;
            if(s[i]==s[j])continue;
            int index=0;
            for(int k=0;k<3;k++){
                if(s[i]==mi[k])continue;
                if(s[j]==mi[k])continue;
                index=k;
                break;
            }
            auto itr = upper_bound(pos[index].begin(),pos[index].end(),j);
            if(itr==pos[index].end())continue;
            int d=j-i;
            int siz = pos[index].size();
            int index2=itr-pos[index].begin();
            //cout<<i<<" "<<j<<" "<<index2<<endl;
            ans+=(siz-index2);
            if(t[index].count(j+d)==1)ans--;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<char>> a(n,vector<char> (n,'.'));
    vector<vector<char>> b(m,vector<char> (m,'.'));
    rep(i,n){
        rep(j,n){
            cin>>a[i][j];
        }
    }
    rep(i,m){
        rep(j,m){
            cin>>b[i][j];
        }
    }
    bool ans = false;

    for(int i=0;i<=n-m;i++){
        for(int j=0;j<=n-m;j++){//bを横にj、縦にi動かした状態でaとの合致を見る
            bool match=true;
            for(int k=0;k<m;k++){
                for(int l=0;l<m;l++){
                    if(b[k][l]!=a[i+k][j+l]){
                        match = false;
                    }
                }
            }
            if(match){
                ans = true;
            }
        }
    }
    if(ans){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<math.h>
#include<cstring>
#include<iostream>
#include<stack>
#include<queue>
#include<functional>
#include<set>
#include<vector>
#include<stdlib.h>
using namespace std;
int n,m,i,j,k,vis[1000][1000]={0},s=0,countl=0,biaojix,biaojiy;long long minn=1e10+7,flag=0,bushu[1000][1000]={0};
char map[1000][1000];
const int dx[]={-1,0,1,0,-1,-1,1,1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
struct dot{
	int x,y;
	dot(int x1,int y1){
		x=x1;
		y=y1;
		
	}
};
queue<dot>q;
void bfs(){
	int x,y;
	while(!q.empty()){
		dot now=q.front();
		q.pop();
		for(i=0;i<4;i++){
			x=now.x+dx[i];
			y=now.y+dy[i];
		    
			if(vis[x][y]||map[x][y]=='#'||x<0 || y<0 || x>=n || y>=m )continue;
			
			else if(map[x][y]=='.'){
			q.push(dot(x,y));
			countl++;
			vis[x][y]=1;
			bushu[x][y]=bushu[now.x][now.y]+1;
			}
		}
	}
}


int main(){
	int sum1;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++){getchar();
		for(j=0;j<m;j++){
			scanf("%c",&map[i][j]);
			if(map[i][j]=='#'){
				s++;
				
			}
		}
	}
	vis[0][0]=1;
	q.push(dot(0,0));
	bfs();
	sum1=n*m-bushu[n-1][m-1]-1-s;
	if(vis[n-1][m-1]!=1){
		printf("-1\n");
	}
	else printf("%d\n",sum1);
	 
	
} 

Measured memory_bytes: 2560
#include<cstdio>
#include<utility>

using namespace std;

// a^n mod を計算する
long int modpow(long int a, long int n, long int mod) {
    long int res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
        // printf("%d\n", res);
    }

    return res;
}

int modcomb(int a, int b, int mod){
    // puts("22");
    // printf("%d %d\n", a, b);
    long int res = 1;
    for(int i = a; i > a - b; i--){
        res *= i % mod;
        res %= mod;
        // puts("23");
    }
    res %= mod;
    // printf("res = %d\n", res);
    // puts("33");
    for(int i = 1; i <= b; i++){
        // printf("res1 = %d\n", res);
        int i_inv = modpow(i, mod - 2, mod);
        // printf(" i_inv= %d\n", i_inv);
        res *= i_inv % mod;
        // printf("res = %d\n", res);
        res %= mod;
    }
    // puts("4");
    res %= mod;
    return res;
}


int main(){
    long int n, m;
    scanf("%ld %ld", &n, &m);
    long int mod = 1000000007;
    pair<long int, long int> p[100000];
    long int num = m;
    int n_fact = 0;
    for(int i = 2; i * i <= m; i++){
        if (num % i == 0) {
            p[n_fact].first = i;
            while(num % i == 0){
                num /= i;
                p[n_fact].second++;
            }
            n_fact++;
        }
    }
    if (num > 1) {
        p[n_fact].first = num;
        p[n_fact].second++;
        n_fact++;
    }
    // for(int i = 0; i < n_fact; i++){
    //     printf("%ld %ld\n", p[i].first, p[i].second);
    // }
    
    // puts("1");
    // printf("%d\n", n_fact);
    long int ans = 1;
    for(int i = 0; i < n_fact; i++){
        ans *= modcomb(p[i].second + n - 1, p[i].second, mod);
        // printf("ans = %d\n", ans);
        ans %= mod;
        
    }
    
    // printf("%ld\n", modpow(2, mod - 2, mod));
    printf("%ld\n", ans);
}

Measured memory_bytes: 1664
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N;
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < N; i++) {
		cout << s[i] << t[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int W, H, N;
int a[100][100];
int main()
{
    cin >> W >> H >> N;
    for(int i=0; i<N; ++i)
    {
        int x, y, at; cin>>x>>y>>at;
        for(int i=0; i<W; ++i)
            for(int j=0; j<H; ++j)
            {
                switch(at)
                {
                    case 1:
                        if(i<x) a[i][j]=1;
                        break;
                    case 2:
                        if(i>=x) a[i][j] = 1;
                        break;
                    case 3:
                        if(j<y) a[i][j] = 1;
                        break;
                    case 4:
                        if(j>=y) a[i][j] = 1;
                        break;
                      
                }
            }
    }
    int ans = 0;
    for(int i=0; i<W; ++i)
        for(int j=0; j<H; ++j)
            ans += a[i][j];
    cout <<W*H-ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Game {
	private int a = 0;
	private int b = 0;
	
	void play(int _a, int _b) {
		if (_a < _b) {
			b += _a + _b;
		} else if (_a > _b) {
			a += _a + _b;
		} else {
			a += _a;
			b += _b;
		}
	}

	void printPoint() {
		System.out.println(a + " " + b);
	}
}

public class Main {
	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		int data, a, b;
		data = a = b = 0;
		while (true) {
			Game game = new Game();
			try {
				data = stdin.nextInt();
			} catch (Exception e) {
				e.printStackTrace();
				data = 0;
			}
			if (data == 0)
				break;
			
			for (int i = 0; i < data; ++i) {
				try {
					a = stdin.nextInt();
					b = stdin.nextInt();
				} catch (Exception e) {
					e.printStackTrace();
				}
				game.play(a, b);
			}
			game.printPoint();
		}
		stdin.close();
	}
}

Measured memory_bytes: 51616
//#pragma GCC optimize("03")
//#pragma GCC target("avx2")
 
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iomanip>
#include <utility>
#include <unordered_map>
#include <unordered_set>
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sqr(a) (a)*(a)
#define um unordered_map 
#define us unordered_set
using namespace std;
 
hash<string> hfn;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef double dbl;
typedef unsigned int ui;
const int inf = 2e9;
const ll mod = 1e9 + 7;
const ld eps = 1e-7;
const ll biginf = 1e18;
const ld pi = acosl(-1);

void solve()
{
  int n;
  cin >> n;
  vector<int> v(n), dp(n);
  for(auto& i : v)
    cin >> i;
  dp[0] = 0;
  dp[1] = abs(v[1] - v[0]);
  for(int i = 2; i < n; i++)
    dp[i] = min(dp[i-2] + abs(v[i-2] - v[i]), dp[i-1] + abs(v[i-1] - v[i]));
  cout << dp.back();
}
 
void multisolve()
{
  int t;
  cin >> t;
  while(t--)
    solve();
}
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  //freopen("hull.in", "r", stdin);
  //freopen("hull.out", "w", stdout);
  solve();
  //multisolve();
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        long a = scanner.nextInt(), b = scanner.nextInt(), c = scanner.nextInt();
        System.out.println(a % 2 + b % 2 + c % 2 == 3 ? Math.min(Math.min(a * b, b * c), c * a) : 0);
    }
}

Measured memory_bytes: 23892
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define G() Cr=getchar()
int Xr;char Cr;
inline int  rd(){
	Xr=0;G();
	while(Cr<'0'||Cr>'9')G();
	while(Cr>='0'&&Cr<='9')Xr=(Xr<<1)+(Xr<<3)+Cr-'0',G();
	return Xr;
}
int n,Ma,Mb,ans=99999999;
int dp[405][405];
int a[100],b[100],c[100];
int suma[100],sumb[100];
int main(){
	n=rd(),Ma=rd(),Mb=rd();
	for(int i=1;i<=n;i++)
		a[i]=rd(),b[i]=rd(),c[i]=rd(),suma[i]=suma[i-1]+a[i],sumb[i]=sumb[i-1]+b[i];
	
	for(int i=0;i<=suma[n];i++)
		for(int j=0;j<=sumb[n];j++)
			dp[i][j]=99999999;
	dp[0][0]=0;	
	
	for(int k=1;k<=n;k++)
		for(int i=suma[k];i>=a[k];i--)
			for(int j=sumb[k];j>=b[k];j--)
				dp[i][j]=min(dp[i][j],dp[i-a[k]][j-b[k]]+c[k]);		
	
	for(int i=1;i<=suma[n];i++)
		for(int j=1;j<=sumb[n];j++)
			if(i*Mb==j*Ma)
				ans=min(ans,dp[i][j]);
	
	printf("%d\n", (ans==99999999)?-1:ans );		
}


Measured memory_bytes: 640
#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 A, B; cin >> A >> B;
  cout << A * B - A - B + 1 << endl;
}


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

int main(){
  int D, G;
  cin >> D >> G;

  vector<int> p(D);
  vector<int> c(D);

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

  int answer = 1.0e9;
  for(int bit = 0; bit < (1<<D); bit++){

    int sum = 0;
    int count = 0;
    int rest_max = -1;
    for(int i = 0; i < D; i++){
      if(bit&(1<<i)){
        sum += p[i] *(i+1) * 100 + c[i];
        count += p[i];
      } else {
        rest_max = i;
      }
    }

    if(sum < G){
      int need = (G - sum - 1) / ((rest_max+1) * 100) + 1;
      if(need > p[rest_max]){
        continue;
      } else {
        sum += need * (rest_max + 1) * 100;
        count += need;
      }
    }

    if(count < answer && G <= sum){
      answer = count;
    }

  }

  cout << answer << endl;
  return 0;
}



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

int main() {
    int a, b;
    cin >> a >> b;
    int ans = max({a + a - 1, a + b, b + b - 1});
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str,s;
  int cnt=0;
  cin >> s;
  for(int i=0,l=s.size();i<l;i++)
    if(s[i]>='A'&&s[i]<='Z')s[i]+=('a'-'A');
  while(cin >> str){
    if(str=="END_OF_TEXT")break;
    for(int i=0,l=str.size();i<l;i++)
      if(str[i]>='A'&&str[i]<='Z') str[i]+=('a'-'A');
    if(s==str) cnt++;
  }
  cout << cnt << endl;
}


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

using namespace std;

int main(){
 	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  //int n,k;
  //cin>>n>>k;
  char s[4];
  cin>>s;
  if((s[0]=='1' && s[1]<='2')||(s[0]=='0' && (s[1]<='9' && s[1]>'0'))){
    if((s[2]=='1' && s[3]<='2')||(s[2]=='0' && (s[3]<='9' && s[3]>'0'))){
      cout<<"AMBIGUOUS";
      return 0;
    }
  	else{
		cout<<"MMYY";
      return 0;
    }
  }
  if((s[2]=='1' && s[3]<='2')||(s[2]=='0' && (s[3]<='9' && s[3]>'0'))){
   		cout<<"YYMM";
    	return 0;
  }
     cout<<"NA";
    
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pi 2*acos(0.0)
#define mod 998244353

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

    ll ans = 0;

    ll n;
    cin >> n;

    while(n--){
        ll input;
        cin >> input;

        if(input%2 == 0){
            while(input%2==0){
                ans ++;
                input /= 2;
            }
        }
    }

    cout << ans <<endl;

    return 0;
}

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

int main() {
    int n, r_co = 0, ans = 0;
    cin >> n;
    vector<char> a(n);
    rep(i, n) {
        cin >> a[i];
        if (a[i] == 'R')
            r_co++;
    }
    for (int i = r_co; i < n; ++i) {
        if (a[i] == 'R')
            for (int j = 0; j < r_co; ++j) {
                if (a[j] == 'W') {
                    swap(a[i], a[j]);
                    ans++;
                    break;
                }
            }
    }
    cout << ans << endl;
    return 0;
}

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


int main(){
  int H,N;
  cin>>H>>N;
  vector<int> a(N);
  vector<int> b(N);
  vector<vector<int>> dp(N+1,vector<int>(H+1));
  for(int i=0;i<N;i++){
    cin>>a[i]>>b[i];
  }
  for(int i=0;i<=N;i++){
    for(int j=0;j<=H;j++){
      dp[i][j]=1234567890;
    }
  }
  for(int i=0;i<=N;i++) dp[i][0]=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<=H;j++){
      dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
      dp[i+1][min(j+a[i],H)] =min(dp[i+1][min(j+a[i],H)], dp[i+1][j]+b[i]);

    }
  }
  cout<<dp[N][H]<<endl;
}


Measured memory_bytes: 39424
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int ans = 1;
	string str;
	int n;
	cin >> n >> str;
	for (int i = 1; i < n; i++)
	{
		ans += str[i] != str[i - 1];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;
public class Main{
  	/*public int minRec(int a[],int dp[],int i,int j)
    {
      if(i==n && j==n)
        	return dp[n][n];
      if(
        return Math.min( Math.abs(a[]
    }*/
	public static void main(String args[]) throws IOException{
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
	  int W = sc.nextInt();
      int w[]=new int[n];
      int v[] = new int[n];
      
      for(int i=0; i<n; i++){
         w[i] = sc.nextInt();
         v[i] = sc.nextInt();
      }
      
      long dp[][] =  new long[n][W+1];
      
      for(int i=0;i<n; i++)
      	Arrays.fill(dp[i], -1);
       
      System.out.println(maxSum(w, v, W, 0, dp));
      
    }
  
  public static long maxSum(int wt[], int v[], int W, int pos, long dp[][]){
    
  	if(pos >= wt.length || W == 0)
      return 0;
    
  //  if(prevSelected!=-1 && dp[pos][prevSelected] != Integer.MIN_VALUE)
    //  return dp[pos][prevSelected];
    
    if(dp[pos][W] != -1)
      return dp[pos][W];
    
    
    int sum = 0;
    if(wt[pos] > W)
      return dp[pos][W] = maxSum(wt, v, W, pos+1, dp);
    
    return dp[pos][W] = Math.max(v[pos]+ maxSum(wt, v, W-wt[pos], pos+1, dp), maxSum(wt, v, W, pos+1, dp));
    
  }
}


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

int main() {
  int a,b,c,d,e;
  string str;
  cin >> a;
  b = a/1000;
  c = a%1000/100;
  d = a%1000%100/10;
  e = a%1000%100%10;
  
  if (b == c && c == d) {
    str = "Yes";
  }
  else if (c ==d && d ==e) {
    str = "Yes";
  }
 else {
   str = "No";
  }
  cout << str << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int A[100], i, N, key, j, k;
  

  scanf("%d", &N);

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

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

  for(i = 1; i <= N - 1; i++){
    key = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > key){
      A[j + 1] = A[j];
      j--;
    }
    
    A[j + 1] = key;
    
    for(k = 0; k < N-1; k++) printf("%d ", A[k]);
    printf("%d", A[k]);
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 604
#define MM_USE_COMP_MACRO

#ifdef MM_USE_COMP_MACRO
//DO NOT READ THIS SECTION:YOU'RE WASTING YOUR TIME
#ifndef MM_USE_COMP_MACRO_DEF
#define MM_USE_COMP_MACRO_DEF

#define _USE_MATH_DEFINES
#include <cstdio>
#include <utility>
#include <cmath>
#include <string>
#include <iostream>

typedef long long signed int ll;

template<class T>
using abp2 = std::pair<T, T>;
template<class T>
using abp3 =  std::pair<std::pair<T,T>, T>;
template<class T>
using abp4 = std::pair<std::pair<T, T>, std::pair<T, T>>;

typedef abp2<ll> ln2;
typedef abp3<ll> ln3;
typedef abp4<ll> ln4;

#define mlp2_t(i,j) std::pair<i,j>
#define mlp3_t(i,j,k) std::pair<std::pair<i,j>,k>
#define mlp4_t(i,j,k,l) std::pair<std::pair<i,j>,std::pair<k,l>>
#define mkp2(i,j) make_pair(i,j)
#define mkp3(i,j,k) make_pair(make_pair(i,j),k)
#define mkp4(i,j,k,l) make_pair(make_pair(i,j),make_pair(k,l))
#define gtp2_1(a) a.first
#define gtp2_2(a) a.second
#define gtp3_1(a) a.first.fisrt
#define gtp3_2(a) a.first.second
#define gtp3_3(a) a.second
#define gtp4_1(a) a.first.fisrt
#define gtp4_2(a) a.first.second
#define gtp4_3(a) a.second.first
#define gtp4_4(a) a.second.second

#define vect_d(a) printf("Dump: In \"%s\" at line %d.\n",__FILE__,__LINE__);for(auto& e:a)std::cout<<e<<" ";std::cout<<std::endl;

#define loop3(i,j,k) for(ll i = j;i < k;i++)
#define loop2(i,j) for(ll i = 0;i < j;i++)
#define loop(j) for(ll i = 0;i < j;i++)
/*
template<class T>
auto gst = []() { T a; std::cin >> a; return a; };
auto gsti = gst<int>;
auto gstll = gst<ll>;
auto gsts = gst<std::string>;
*/
template<class T>
constexpr T mpi = (T)M_PI;
constexpr auto pi_i = mpi<int>;
constexpr auto pi_ll = mpi<ll>;

#ifndef N_MOD
#pragma message( "Warning!! No N_MOD macro is defined. Falling back to 1000000007." )
#define N_MOD 1000000007
#endif

#ifdef _DEBUG
#define assert_error {printf("Error: In \"%s\" at line %d.\n",__FILE__,__LINE__);throw;}
#else
#define assert_error {throw;}
#endif

#endif
#endif

#include <string>
#include <iostream>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <map>
#include <set>

using namespace std;

int main() {
	string s,t;
	vector<string> u;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'A') {
			t += 'x';
			continue;
		}
		if (i < s.length() - 1 && s[i] == 'B' && s[i + 1] == 'C') {
			t += 'y';
			i++;
			continue;
		}
		if (t.length() > 0) {
			u.push_back(t);
			t.clear();
		}
	}
	if (t.length() > 0) {
		u.push_back(t);
		t.clear();
	}
	ll res = 0;
	for (auto& e : u) {
		ll cnt = 0;
		for (auto f : e) {
			if (f == 'x') cnt++;
			else res += cnt;
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 3196
import java.util.Scanner;
class Main{
	int a,b,c;
	int x,y,i;
	public void Germany() {
		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		for(i = a;i <= b;i++) {
			x = c % i;
			if(x == 0){
				y++;
			}
		}
		System.out.println(y);
	}
	    public static void main(String[] args) {
	        new Main().Germany();
	    }
	}

Measured memory_bytes: 17228
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
ll mod=1e9+7;
      
      
int main(){
  int k,a,b;
  cin >> k >> a >> b;
  for(int i=a;i<=b;i++){
    if(i%k==0){cout << "OK" << endl;
    return 0;}
  }
  cout << "NG" << endl;
}

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

string S;

int main() {
    cin >> S;

    if (S.substr(0, 4) == "YAKI") cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cmath>
#define _GLIBCXX_DEBUG
typedef long long ll;
using namespace std;
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; }


int main(){
vector<int>n(34);
int i=-1;
n.at(0)=1;
do{
    i++;
    cin>>n.at(i);
}while(n.at(i)!=0);

vector<int>dp(1000000);
i=0;
while (n.at(i)!=0)
{
    dp.at(n.at(i))=1;
    for(int j=n.at(i)-1;j>=0;j--){
        dp.at(j)=dp.at(j+1)+dp.at(j+2)+dp.at(j+3);
    }
    i++;
    cout<<(dp.at(0)+3649)/3650<<endl;
}
}


Measured memory_bytes: 6792
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = InputNumList();

            WriteLine(a[0] <= a[2] && a[2] <= a[1] ? "Yes" : "No");
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}



Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <cstdlib>
 
using namespace std;
 
#define INF (10000000)
 
int main()
{
    int N;
    cin >> N;
 
    vector<int> L;
 
    for(int i=0; i<N; ++i) {
        int temp;
        cin >> temp;
        if(i!=0) temp+=L[i-1];
        L.push_back(temp);
    }
 
    pair<int,int> dp[N][N];
 
    for(int i=1; i<N; ++i) { // initialize ... divide into 2 parts / i...last index
        int mx=INF, mn=-1, gap=INF;
        for(int j=0; j<N-1; ++j) {
            int temp=abs(L[i]-2*L[j]); // when cut after index-j
            if(gap>temp) { // compare gap
                mx=max(L[i]-L[j],L[j]); //update
                mn=min(L[i]-L[j],L[j]);
                gap=temp;
            }
        }
        dp[1][i].first=mx;
        dp[1][i].second=mn;
    }
 
    for(int i=2; i<N; ++i) { // i... number of divides
        for(int j=1; j<N; ++j) { // j... last index
            int mx=INF, mn=-1, gap=INF;
            for(int k=1; j-k>=i-1; ++k) { // k...add new section to i-1 divides
                int temp=abs(L[j]-L[j-k]);
                if(max(dp[i-1][j-k].first,temp)-min(dp[i-1][j-k].second,temp)<gap) {
                    mx=max(dp[i-1][j-k].first,temp);
                    mn=min(dp[i-1][j-k].second,temp);
                    gap=mx-mn;
                }
            }
            dp[i][j].first=mx;
            dp[i][j].second=mn;
        }
    }
 
    int ans=10000000;
 
    for(int i=1; i<N; ++i) {
        ans=min(ans,dp[i][N-1].first-dp[i][N-1].second);
    }
 
    cout << ans << endl;
 
    return 0;
}



Measured memory_bytes: 3160
# -*- coding: utf-8 -*-

N = int(input())
count = 0

for i in range(1, N + 1):
    a = []
    if i % 2 == 0:
        continue

    for j in range(1, i + 1):
        if i % j == 0:
            a.append(j)

    if len(a) == 8:
        count += 1

print(count)



Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    string s,t; cin>>s>>t;
    int n=s.size();
    string ans="Yes";
    int a[26],b[26]; rep(i,26) a[i]=b[i]=-1;
    rep(i,n){
        if(a[s[i]-'a']!=-1&&a[s[i]-'a']!=t[i]-'a') ans="No";
        a[s[i]-'a']=t[i]-'a';
        if(b[t[i]-'a']!=-1&&b[t[i]-'a']!=s[i]-'a') ans="No";
        b[t[i]-'a']=s[i]-'a';
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 776
<?php
list($n) = ints();
$a = ints();
$b = ints();
$suma = array_sum($a);
$sumb = array_sum($b);
if ($sumb > $suma) exit('-1');
$md = $pd = [];
for ($i = 0; $i < $n; ++$i) {
    $d = $a[$i] - $b[$i];
    if ($d < 0) $md[] = $d;
    elseif ($d > 0) $pd[] = $d;
}
if (count($md) === 0) exit('0');
$ans = count($md);
$sum_md = array_sum($md);
$i = 0;
rsort($pd);
while ($sum_md < 0) {
    $sum_md += $pd[$i];
    ++$i;
}
$ans += $i;
echo $ans;

function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 30784