akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long 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; }

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
  int P, Q, R;
  cin >> P >> Q >> R;

  int ans = P + Q;
  if(ans > Q + R) ans = Q + R;
  if(ans > P + R) ans = P + R;

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	public static void main(String[] args){
		Scanner sn = new Scanner(System.in);
		
		while(sn.hasNext()){
			int n = sn.nextInt();
			int[] times = new int[n];
			for(int i = 0; i < n; i++){
				times[i] = sn.nextInt();
			}
			Arrays.sort(times);
			int sum = 0;
			int m = n;
			for(int i = 0; i < n; i++){
				sum += times[i]*m;
				m--;
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 27632
#include <iostream>

using namespace std;

int main(){
  string str;cin >> str;
  for(int i=0;i<str.length()-1;i++){
    for(int j=i+1;j<str.length();j++){
      if(str[i]==str[j]){
        cout << "no" << endl;
        return 0;
      }
    }
  }
  cout << "yes" << endl;
}

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

int souwa(int i);
int souwa(int i){
  int one,ten,hun,tho,man;
  int Ans;
  one = i%10;
  ten = (i%100 - i%10)/10;
  hun = (i%1000 - i%100)/100;
  tho = (i%10000 - i%1000)/1000;
  man = (i%100000 - i%10000)/10000;
  Ans = one + ten + hun + tho + man;
  return(Ans);
}

int main(){
  int N,A,B;
  int cnt = 0;
  cin >> N >> A >> B;
  for(int i=1;i<=N;i++){
    if(A<=souwa(i) && souwa(i)<=B) cnt += i;
  }
  cout << cnt;
}

Measured memory_bytes: 256
from itertools import combinations


if __name__ == '__main__':
    while True:
        # ??????????????\???
        n, s = [int(x) for x in input().split(' ')]
        if n == 0 and s == 0:
            break

        # ????????????
        answer = 0
        combi = combinations(range(0, 10), n)
        for c in combi:
            if sum(c) == s:
                answer += 1

        # ???????????¨???
        print(answer)

Measured memory_bytes: 7520
abcx = []
for i in range(4):
  abcx.append(int(input()))

  
x = abcx[3]
count = 0
for a in range(abcx[0]+1):
  for b in range(abcx[1]+1):
    for c in range(abcx[2]+1):
      if 500*a + 100*b + 50*c == x:
        count += 1
print(str(count))

Measured memory_bytes: 3060
#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 pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int a[101];
int main(){
    int n;
    cin>>n;
    rep(i,n) cin>>a[i];
    sort(a,a+n);
    int ans=0;
    rep(i,n-1) ans+=a[i+1]-a[i];
    cout<<ans<<endl;
    return 0;
}

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

nums = []
for _ in range(N):
    nums.append(list(map(int, input().split())))

nums = sorted(nums, key=lambda x: x[0])

acc = [0]*N
acc[0] = nums[0][1]
for i in range(1, N):
    acc[i] += acc[i-1]+nums[i][1]


for i in range(N):
    if acc[i] >= K:
        print(nums[i][0])
        exit()


Measured memory_bytes: 32052
# 解説そのまま
n = int(input())
def dfs(s):
    if int(s) > n:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0
    for c in '753':
        ret += dfs(s + c)
    return ret
print(dfs('0'))

Measured memory_bytes: 3060
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = myconv(next(),1);
  var list = myconv(next(),4);
  list.sort(function(a,b){
  	return a - b;
  });
  var output = 10000000000;
  for(var i = 1; i <= 100; i++){
    var sum = 0;
    for(var j = 0; j < N; j++){
      sum += Math.pow(i - list[j],2);
    }
    output = Math.min(output,sum);
  }
  myout(output);
}

Measured memory_bytes: 22076
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    ll N;
    cin >> N;
    vector<ll> H(N);
    for(ll i=0; i<N; ++i) cin >> H[i];
    for(ll i=0; i<N-1; ++i){
        if(H[i]>H[i+1]){
            if(H[i]-1>H[i+1]){
                cout << "No" << endl;
                return 0;
            }
            H[i+1]++;

        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1024
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
# import time,random,resource

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)
def IF(c, t, f): return t if c else f


def floor_sum(n, m, a, b):
    ans = 0
    if a >= m:
        ans += (n - 1) * n * (a // m) // 2
        a %= m

    if b >= m:
        ans += n * (b // m)
        b %= m

    y_max = (a * n + b) // m
    x_max = (y_max * m - b)
    if y_max == 0:
        return ans

    ans += (n - (x_max + a - 1) // a) * y_max
    ans += floor_sum(y_max, a, m, (a - x_max % a) % a)
    return ans


def main():
    t = I()
    qa = [LI() for _ in range(t)]

    r = []
    for n,m,a,b in qa:
        r.append(floor_sum(n,m,a,b))

    return JA(r, "\n")


print(main())




Measured memory_bytes: 39852
#include<bits/stdc++.h>
using namespace std;
typedef long long 	ll;
const ll 	MOD		=  	1e+9+7;
const ll 	N 		= 	2*1e6;
int dp[10000001];
int arr[10000001];
int n,k;
int solve(int ind)
{
	if(ind==n-1)
	{
		return 0;
	}
	if(dp[ind]!=-1)
	{
		return dp[ind];
	}
	int ans=solve(ind+1)+abs(arr[ind+1]-arr[ind]);
	for(int i=1;i<=k;i++)
	{
		if(ind+i<n)
		{
			ans=min(ans,solve(ind+i)+abs(arr[ind+i]-arr[ind]));
		}
	}
	return dp[ind]=ans;

}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	memset(dp,-1,sizeof(dp));
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	cout<<solve(0)<<"\n";
	
	return 0;
}

Measured memory_bytes: 49188
#include<cstdio>
#include<string>
#include<map>
#include<algorithm>
#include<iostream>
#include<set>
using namespace std;

int d;
set<string> data;

void check(string str){
	for(int i=1;i<str.size();i++){
		string str2="",str3="";
		str2.append(str,0,i);
		str3.append(str,i,str.size()-i);
		string str4;
		str4=str2+str3;
		data.insert(str4);
		str4=str3+str2;
		data.insert(str4);
		reverse(str2.begin(),str2.end());
		str4=str2+str3;
		data.insert(str4);
		str4=str3+str2;
		data.insert(str4);
		reverse(str3.begin(),str3.end());
		str4=str2+str3;
		data.insert(str4);
		str4=str3+str2;
		data.insert(str4);
		reverse(str2.begin(),str2.end());
		str4=str2+str3;
		data.insert(str4);
		str4=str3+str2;
		data.insert(str4);
	}
}

int main(void){
	scanf("%d",&d);
	for(int i=0;i<d;i++){
		data.clear();
		string str;
		cin >> str;
		check(str);
		printf("%d\n",data.size());
	}
	return 0;
}

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

int main(){
  ll n;cin >> n;
  vector< vector<ll> > g(n,vector<ll>(n));
  rep(i,n) rep(j,n) g.at(i).at(j) = -1;

  rep(i,n){
    ll a;cin >> a;
    rep(j,a){
      ll x,y;cin >> x >> y;
      g.at(i).at(x-1) = y;//i番目の人は、x-1番目の人をyだと証言する
    }
  }
  //g.at(i).at(j)が
  // -1 -> 証言なし、何もしない
  // 0 ->　不親切な人だという証言
  //1 ->　正直者だという証言

  int ans = 0;

  //0...0 ~ 1...1　の全ての状態の場合を列挙
  for(ll i=0;i<(1<<n);++i){
    vector<ll> d(n);// 今の状態を配列に保存
    rep(j,n) if( i>>j & 1 ) d.at(j) = 1;
    
    bool ok = true;//矛盾がなければtrue
    rep(j,n){
      if( d.at(j) == 1 ){//j番目の人が正直者だという状態の時
        rep(k,n){
          if( g.at(j).at(k) == -1 ) continue;
          if( g.at(j).at(k) != d.at(k) ) ok = false;
        }
      }
    }
    if( ok ) ans = max(ans,__builtin_popcount(i));
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
#define chmax(a,b) if(b>a) a = b
#define chmin(a,b) if(b<a) a = b
typedef long long ll;
using namespace std;


int main(){
        ios_base::sync_with_stdio(false); 
        cin.tie(NULL);
        ll n,m,k,ans = 0; cin >> n >> m >> k;
        vector<ll> a(n), b(m),ruia(n+1,0),ruib(m+1,0);
        rep(i,n){
                cin >> a[i];
                ruia[i+1] = ruia[i] + a[i];
        }
        rep(i,m){
                cin >> b[i];
                ruib[i+1] = ruib[i] + b[i];
        }
        
        rep(i,n+1){
                auto key = k - ruia[i];
                int l = 0, r = m, mid = (l+r)/2;
                while(l<r-1){
                        mid = (l+r)/2;
                        if(ruib[mid] > key){
                                r = mid;
                        }else{
                                l = mid;
                        }
                }
                if(ruib[r] <= key){
                        chmax(ans,r+i);
                }else if(ruib[l] <= key) chmax(ans,l+i);
        }
        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 9508
#include <iostream>
#include <cstdio>

const int INF=100000;

using namespace std;

int main(void){
    int list[21][21];
    int n,m;
    int a,b,c,d;
    int x,y,z,w;
    int i,j,k;
    int cost;
    
    for(i=0;i<21;i++){
        fill(list[i],list[i]+21,INF);
    }
    
    scanf("%d",&n);
    scanf("%d",&m);
    for(i=0;i<m;i++){
        scanf("%d,%d,%d,%d",&a,&b,&c,&d);
        list[a-1][b-1]=c;
        list[b-1][a-1]=d;
    }
    scanf("%d,%d,%d,%d",&x,&y,&z,&w);
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            for(k=0;k<n;k++){
                if(list[j][k]>list[j][i]+list[i][k]){
                    list[j][k]=list[j][i]+list[i][k];
                }
            }
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
        }
    }
    cost=z-w-list[x-1][y-1]-list[y-1][x-1];
    cout<<cost<<endl;
    return(0);
}

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

using ll = long long;
#define int long long

// [a -> b-1]
#define reps(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
// [0 -> a-1]
#define rep(i, a) reps(i, 0, (a))
// [a-1 -> b]
#define rreps(i, a, b) for (int i = (int)((a)-1); i >= (int)(b); i--)
// [a-1 -> 0]
#define rrep(i, a)a, rreps(i,  0)
#define all(v) (v).begin(), (v).end()
// next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
 * (v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v)\
	sort(all(v));\
	(v).erase(unique(all(v)), v.end())
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
// b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
// c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(15)
#define YES(f) cout << ((f) ? YES_STR : NO_STR) << endl;

int calc(int a) {
	int res = 0;
	while (a) {
		res += 1;
		a /= 10;
	}
	return res;
}

void solve(long long N) {
	int res = 0;
	reps(i,1 ,N+1) {
		res += calc(i) % 2;	
	}
	cout << res << endl;
}

signed main() {
	long long N;
	scanf("%lld",&N);
	solve(N);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

const ll INF = 1LL<<60;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vll a(n), s(n+1, 0);
    rep(i, n) cin >> a[i];
    rep(i, n) s[i+1] = s[i] + a[i];
    ll mn = INF;
    for (int i = 1; i <= n-1; ++i) {
        ll now = abs(s[i] - (s[n] - s[i]));
        chmin(mn, now);
    }
    cout << mn << endl;
}

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

int main() {
  int n;
  cin >> n;
  int m = 3 * n;
  vector<int> a(m);
  for (int i = 0; i < m; i ++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());

  LL ans = 0;
  int tmp = m - 2;
  for (int i = 0; i < n; i ++) {
    ans += a.at(tmp);
    tmp -= 2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n+1];
    for(int i = 1;i<n;i++) cin >> a[i];
    a[0]=a[1];
    a[n]=a[n-1];
    int ans = 0;
    for(int i = 1;i<=n;i++) ans+=min(a[i-1],a[i]);
    cout << ans << endl;
}

Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1010;
struct node
{
	int t,c;
}a[N];
int n,m;
bool cmp(const node &x,const node &y){ return x.c<y.c;}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d%d",&a[i].c,&a[i].t);
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++)
		if(a[i].t<=m){ printf("%d\n",a[i].c);return 0;}
	printf("TLE\n");return 0;
}

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

int main(void){
	double x1,x2,x3,y1,y2,y3,xp,yp,s1,s2,a,b,c,s;
	int i,n,l,f,ans;
	char sa[50],sb[50],*p1,*p2;
	
	
	while(scanf(" %lf %lf %lf %lf %lf %lf %lf %lf" ,&x1 ,&y1 ,&x2 ,&y2 ,&x3 ,&y3 ,&xp ,&yp)!=EOF){
		//入力された三角形の面積を求める
		a=sqrt(pow(x1-x2,2)+pow(y1-y2,2));
		b=sqrt(pow(x2-x3,2)+pow(y2-y3,2));
		c=sqrt(pow(x3-x1,2)+pow(y3-y1,2));
		s=(a+b+c)/2.0;
		s1=sqrt(s*(s-a)*(s-b)*(s-c));
		
		//点xpと三点のうち各2点からなる3つの三角形の面積及びその和を求める
		s2=0;
		
		//1,2
		a=sqrt(pow(x1-x2,2)+pow(y1-y2,2));
		b=sqrt(pow(x2-xp,2)+pow(y2-yp,2));
		c=sqrt(pow(xp-x1,2)+pow(yp-y1,2));
		s=(a+b+c)/2.0;
		s2+=sqrt(s*(s-a)*(s-b)*(s-c));
		
		//2,3
		a=sqrt(pow(xp-x2,2)+pow(yp-y2,2));
		b=sqrt(pow(x2-x3,2)+pow(y2-y3,2));
		c=sqrt(pow(x3-xp,2)+pow(y3-yp,2));
		s=(a+b+c)/2.0;
		s2+=sqrt(s*(s-a)*(s-b)*(s-c));
		
		//3,1
		a=sqrt(pow(x1-xp,2)+pow(y1-yp,2));
		b=sqrt(pow(xp-x3,2)+pow(yp-y3,2));
		c=sqrt(pow(x3-x1,2)+pow(y3-y1,2));
		s=(a+b+c)/2.0;
		s2+=sqrt(s*(s-a)*(s-b)*(s-c));
		
		
		//s1,s2を文字列に加工
		p1=sa;
		p2=sb;
		sprintf(p1,"%lf",s1);
		sprintf(p2,"%lf",s2);
		
		//s1とs2が等しければYES、違うならばNO
		if(strcmp(p1,p2)==0){
			//printf("%lf %lf\n",s1,s2);
			printf("YES\n");
		}
		else{
			//printf("%lf %lf\n",s1,s2);
			printf("NO\n");
		}
		
	}
	
	return 0;
}
		

Measured memory_bytes: 0
import sys

sys.setrecursionlimit(6500)

def find(n):
    if d[n]<0:
        return n
    else:
        d[n]=find(d[n])
        return d[n]

def union(a,b):
    a=find(a)
    b=find(b)
    if a==b:return False
    if d[a]<=d[b]:
        d[a]+=d[b]
        d[b]=a
    else:
        d[b]+=d[a]
        d[a]=b
    return True

def members(n):
    p=find(n)
    ans=[]
    for i in range(N):
        if find(i)==p:
            ans.append(i)
    return ans

def same(a,b):
    if find(a)==find(b):return True
    else:return False

N,M=map(int,input().split())
p=list(map(int,input().split()))

d=[-1]*N

for i in range(M):
    x,y=map(int,input().split())
    x,y=x-1,y-1
    union(x,y)

q=[-1]*N
for i in range(N):
    q[p[i]-1]=i
ans=0
for i in range(N):
    if same(i,q[i]):
        ans+=1
print(ans)

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

int main(){
    int n, k, q;
	cin >> n >> k >> q;
	vector<int> score(n, k+q*-1);
	for(int i=0; i<q; i++){
		int index;
		cin >> index;
		score[index-1]++;
	}
	for(int i=0; i<n; i++){
		if(score[i]>0){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
	
    return 0;
}

Measured memory_bytes: 1024
if __name__ == "__main__":
    list_1=input().split()
    H=int(list_1[0])
    W=int(list_1[1])

    list_2=input().split()
    h=int(list_2[0])
    w=int(list_2[1])
    
    Ans = (H-h)*(W-w)
    print(Ans)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
bool has3(int x){
while(x){
if (x%10==3)return true;
x /= 10;
}
return false;
}

void call(int n){
for(int x = 1; x <= n; x++){
if(x%3==0||has3(x)){
cout << " " << x;
}
}
cout << endl;
}

int main(){
int n;
cin >> n;
call(n);
return 0;


}


Measured memory_bytes: 3080
N, M=map(int, input().split())
mat = [[0 for m in range(M)]for n in range(N)]
vec = [0 for m in range(M)]

for n in range(N):
  mat[n] = list(map(int , input().split()))
for m in range(M):
  vec[m] = int(input())

c = 0
for n in range(N):
 for m in range(M):
  c += mat[n][m] * vec[m]
 print(c)
 c = 0

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

using namespace  std;

struct I{I(){ios::sync_with_stdio(false);cin.tie(0);}}init;

typedef long long LL;
typedef vector<LL> V;

const LL INF=1145141919;
V TSP(V &x,V &y){
    int n=x.size();
    V res(1<<n,INF);
    vector<V> tsp(n,V(1<<n,INF));
    V ord((1<<n)-1);
    iota(ord.begin(),ord.end(),1);
    sort(ord.begin(),ord.end(),[&](int l,int r){return __builtin_popcount(l)<__builtin_popcount(r);});
    for(int i=0;i<n;i++)tsp[i][1<<i]=abs(x[i])+abs(y[i]);
    for(auto &bit:ord){
        for(int i=0;i<n;i++){
            res[bit]=min(res[bit],tsp[i][bit]+abs(x[i])+abs(y[i]));
            for(int j=0;j<n;j++){
                int c=1<<j;
                tsp[j][bit|c]=min(tsp[j][bit|c],tsp[i][bit]+abs(x[i]-x[j])+abs(y[i]-y[j]));
            }
        }
    }
    return res;
}
LL knapsack(V cost,V value,int limit){
    int n=cost.size();
    LL res=0;
    V dp(limit+1,0);
    for(int i=0;i<n;i++)
        for(int j=cost[i];j<=limit;j++)
            res=max(dp[j]=max(dp[j],dp[j-cost[i]]+value[i]),res);
    return res;
}


int main(){
    int N,M,W,T;
    cin>>N>>M>>W>>T;
    V w(M),v(M);
    map<string,int> StoI;
    for(int i=0;i<M;i++){
        string s;
        cin>>s>>w[i]>>v[i];
        StoI[s]=i;
    }
    V x(N),y(N);
    vector<V> valdp(1<<N,V(M,0));
    V val(1<<N,0);
    for(int i=0;i<N;i++){
        int L;cin>>L>>x[i]>>y[i];
        while(L--){
            string s;LL vv;cin>>s>>vv;
            int id=StoI[s];
            vv=max(0ll,v[id]-vv);
            valdp[1<<i][id]=vv;
        }
    }
    auto t=TSP(x,y);
    for(int bit=1;bit<(1<<N);bit++){
        int rest=bit;
        while(rest){
            int now=rest&-rest;
            for(int i=0;i<M;i++)
                valdp[bit][i]=max(valdp[bit][i],valdp[now][i]);
            rest-=now;
        }
        val[bit]=knapsack(w,valdp[bit],W);
    }
    cout<<knapsack(t,val,T)<<endl;
    return 0;
}

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

string S, t;

bool judge() {
	for (int i = S.length() - 1; i >= 0; --i) {
		t += S[i];

		if (t == "maerd" || t == "remaerd" || t == "esare" || t == "resare") {
			t = "";
			continue;
		}

		// tが8文字以上でも条件に当てはまらないのであれば終了
		if (t.length() > 7) {
			return false;
		}
	}

	return true;
}

int main() {
	cin >> S;

	
	if (judge()) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;

}

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

int dp[30];

int main(){

    dp[0] = 1;dp[1] = 2;dp[2] = 4;
    for(int i=3;i<30;++i){
        dp[i] = dp[i-3] + dp[i-2] + dp[i-1];
    }

    while(1){
        int n;
        scanf("%d",&n);
        if(n == 0)break;
        printf("%.0f\n",ceil(dp[n-1]/(365.0*10.0)));
    }

    return 0;
}


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

using namespace std;

string s;
int S,T;
int main() {
    cin >> s;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == 'T') {
            if(S) S--;
            else T++;
        } else {
            S++;
        }
    }
    cout << S + T << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
string s;
int main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>s>>m;
    n=s.size();
    for(i=0;i<n;i++)
    {
        if(s[i]!='1' || i==(m-1))
        {
            cout<<s[i]<<"\n";
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 256
n=int(input())
a=[input() for i in range(n)]
m=int(input())
b=[input() for i in range(m)]
l=set(a+b)
m=0
for x in l:
    c=0
    for y in a:
        if x==y:c+=1
    for z in b:
        if x == z:c-=1
    m=max(m,c)
print(max(m,0))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,X;
  cin>>X;
  for(int i=-300;i<300;i++){
    for(int j=-300;j<300;j++){
      if(pow(i,5)-pow(j,5)==X){
        A=i;
        B=j;
        break;
      }
    }
  }
  cout<<A<<" "<<B<<endl;
}


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

const int N=2010;

int n,m,q,sum[N][N],eup[N][N],elf[N][N];
bool map[N][N];

void Init() {
	scanf("%d%d%d",&n,&m,&q);
	for (int i=1;i<=n;++i)
		for (int j=1;j<=m;++j) {
			char ch=getchar();
			while (ch!='0' && ch!='1') ch=getchar();
			map[i][j]=ch-'0';
		}
}

int Q(int s[][N],int x1,int y1,int x2,int y2) { 
	return s[x2][y2]-s[x1-1][y2]-s[x2][y1-1]+s[x1-1][y1-1]; 
}

void Solve() {
	for (int i=1;i<=n;++i)
		for (int j=1;j<=m;++j) sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+map[i][j];
	for (int i=1;i<=n;++i)
		for (int j=1;j<=m;++j) {
			int op=(map[i][j] && map[i-1][j]);
			eup[i][j]=eup[i-1][j]+eup[i][j-1]-eup[i-1][j-1]+op;
				op=(map[i][j] && map[i][j-1]);
			elf[i][j]=elf[i-1][j]+elf[i][j-1]-elf[i-1][j-1]+op;
		}
	int x1,x2,y1,y2;
	for (int i=1;i<=q;++i) {
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		printf("%d\n",Q(sum,x1,y1,x2,y2)-Q(eup,x1+1,y1,x2,y2)-Q(elf,x1,y1+1,x2,y2));
	}
}

int main() {
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 52992
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	long long a, b;
	cin >> a >> b;
	if (a > 0)cout << "Positive" << endl;
	else if (b >= 0)cout << "Zero" << endl;
	else if ((b - a) % 2 == 0)cout << "Negative" << endl;
	else cout << "Positive" << endl;
}


Measured memory_bytes: 256
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    
    int main(){
      int n;
      cin>>n;
      VEC(long,a,n+1);
      VEC(long,b,n);
      auto p = vec(int,n);
      rep(i,n){
        if(a[i]>=b[i])p[i] = b[i];
        else{
          b[i] -= a[i];
          p[i] = a[i];
          if(a[i+1]>=b[i]){
            a[i+1] -= b[i];
            p[i] += b[i];
          }
          else{
            p[i] += a[i+1];
            a[i+1] = 0;
          }
        }
      }
      long sum = 0;
      rep(i,n)sum += p[i];
      cout<<sum<<endl;
    }


Measured memory_bytes: 2176
import java.util.*;

class Main{
    Main(){
        Scanner SC = new Scanner(System.in);

        int X = Integer.parseInt(SC.next());

        int R = (X / 500) * 1000;
        R += (X % 500) / 5 * 5;

        System.out.println(R);
    }

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


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

string a[114];
int main(){
	int h,w;
	cin>>h>>w;
	for(int i=0;i<h;i++)cin>>a[i];
	for(int i=0;i<h+2;i++){
		for(int j=0;j<w+2;j++){
			if(i==0||j==0||i==h+1||j==w+1)cout<<'#';
			else cout<<a[i-1][j-1];
			}
			cout<<endl;
		}
	}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};


const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];


void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


ll nCr(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll nHr(ll n, ll r) { if (n == 0 && r == 0) return 1; else return nCr(n + r - 1, r); }
ll nPr(ll n, ll r) { if (r < 0 || n < r) return 0; else return (fac[n] * finv[n-r]) % MOD; }


int main(){
    ll n, m; cin >> n >> m;
    if(abs(n - m) > 1){
        cout << 0 << endl;
        return 0;
    }
    COMinit();
    ll ans = fac[n]*fac[m] % MOD;
    if(n == m) MUL(ans, 2);
    cout << ans << endl;
}


Measured memory_bytes: 15592
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n, d, x; cin >> n >> d >> x;
    vector<int> A(n);
    int ans = 0, num;
    REP(i, n){ 
        cin >> num;
        ans += d / num;
        if(d % num != 0) ans++;
    }
    cout << ans + x << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<string>
#include<math.h>

using namespace std;

int main(){
    int A,B,C;
    cin>>A>>B>>C;
    long ans;
    
    if(A+B >= C-1){
        ans = B+C;
    }else{
        int temp = C-A;
        if(temp<=B+1){
            ans = B+C;
        }else{
            ans = A+B+B+1;
        }
    }

    cout<<ans<<endl;
	
	
}


Measured memory_bytes: 256
N = int(input())
X = list(map(int, input().split()))
L = [0 for _ in range(N)]
for i in range(N):
  X[i] = X[i] * N + i
X.sort()
d = N // 2
for i in range(N):
  if i < d:
    L[X[i]%N] = X[d] // N
  else:
    L[X[i]%N] = X[d-1] // N
for i in range(N):
  print(L[i])

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

using namespace std;

using ll = long long;

bool Solve() {
    string s[2];
    cin >> s[0] >> s[1];
    for (int i = 0; i < 3; ++i)
        if (s[0][i] != s[1][2 - i]) return false;
    return true;
}

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

    if (Solve()) cout << "YES\n";
    else cout << "NO\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
	  int N = sc.nextInt();
      int T = sc.nextInt();
      int[] t = new int[N];
      int sum = 0;
      for(int i=0;i<N;i++){
        t[i] = sc.nextInt();
        if(i>0){
          if(t[i-1]+T>t[i]){//前の人のスイッチでまだ流れてたら
            int a = t[i]-t[i-1];
            sum+=a;
          }else{
            sum+=T;
          }
        }
      }
      System.out.println(sum+T);
    }
}

Measured memory_bytes: 60320
#include<bits/stdc++.h>
using namespace std;
int n,w[109],v[109],W;
long long dp[100009];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>W;
	for(int i=0;i<n;i++) cin>>w[i]>>v[i];
	for(int i=0;i<n;i++)
		for(int j=W;j>=w[i];j--)
			dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
	cout<<dp[W]<<endl;
	return 0;
}

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

int main() {
  int N;
  string str = "";
  string add;
  cin >> N;
  for(int i = 0; i < N; i++){
  	cin >> add;
    str += add;
  }

  int Pcheck = 0;
  int Wcheck = 0;
  int Gcheck = 0;
  int Ycheck = 0;
  for (int j = 0; j < str.size(); j++) {
    if (str.at(j) == 'P') {
      Pcheck++;
    }else if (str.at(j) == 'W') {
      Wcheck++;
    }else if (str.at(j) == 'G') {
      Gcheck++;
    }else if (str.at(j) == 'Y') {
      Ycheck++;
    }
  }
  if(Pcheck != 0 && Wcheck != 0 && Gcheck != 0 && Ycheck != 0){
  	cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 384
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>

using namespace std;



int main() {
	unsigned long long h, w;
	cin >> h >> w;
	unsigned long long ans = h*w;
	if (h % 3 == 0 || w % 3 == 0) {
		cout << 0 << endl;
		return 0;
	}
	vector<unsigned long long> s;
	s.resize(3);
	s[0] = ceil((double)h / 3) * w;
	s[1] = (h - ceil((double)h / 3)) * (w / 2);
	s[2] = w*h - s[0] - s[1];
	sort(s.begin(), s.end());
	ans = min(ans, s[2] - s[0]);
	s[0] = ceil((double)w / 3) * h;
	s[1] = (w - ceil((double)w / 3)) * (h / 2);
	s[2] = w*h - s[0] - s[1];
	sort(s.begin(), s.end());
	ans = min(ans, s[2] - s[0]);
	s[0] = floor((double)h / 3) * w;
	s[1] = (h - floor((double)h / 3)) * (w / 2);
	s[2] = w*h - s[0] - s[1];
	sort(s.begin(), s.end());
	ans = min(ans, s[2] - s[0]);
	s[0] = floor((double)w / 3) * h;
	s[1] = (w - floor((double)w / 3)) * (h / 2);
	s[2] = w*h - s[0] - s[1];
	sort(s.begin(), s.end());
	ans = min(ans, s[2] - s[0]);

	s[0] = ceil((double)h / 3) * w;
	s[1] = (unsigned long long)((h - ceil((double)h / 3))/2) * w;
	s[2] = w*h - s[0] - s[1];
	sort(s.begin(), s.end());
	ans = min(ans, s[2] - s[0]);
	s[0] = ceil((double)w / 3) * h;
	s[1] = (unsigned long long)((w - ceil((double)w / 3))/2) * h;
	s[2] = w*h - s[0] - s[1];
	sort(s.begin(), s.end());
	ans = min(ans, s[2] - s[0]);
	s[0] = floor((double)h / 3) * w;
	s[1] = (unsigned long long)((h - floor((double)h / 3))/2) * w;
	s[2] = w*h - s[0] - s[1];
	sort(s.begin(), s.end());
	ans = min(ans, s[2] - s[0]);
	s[0] = floor((double)w / 3) * h;
	s[1] = (unsigned long long)((w - floor((double)w / 3))/2) * h;
	s[2] = w*h - s[0] - s[1];
	sort(s.begin(), s.end());
	ans = min(ans, s[2] - s[0]);

	cout << ans << endl;
	//cin >> w;
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>

using namespace std;
typedef long long ll;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	int ans = 0;
	set<tuple<int, int, int>> s;
	for (;;) {
		auto it = s.find(make_tuple(A, B, C));
		if (it != s.end()) {
			ans = -1;
			break;
		}
		if (A % 2 != 0 || B % 2 != 0 || C % 2 != 0) {
			break;
		}
		s.emplace(A, B, C);
		int a = A / 2;
		int b = B / 2;
		int c = C / 2;
		A += b + c;
		B += a + c;
		C += a + b;
		ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop
class UnionFind:
  def __init__(self, n):
    self.par = [i for i in range(n)]
    self.size = [1]*n
    self.rank = [0]*n
  def find(self, x):
    if self.par[x]==x:
      return x
    else:
      self.par[x] = self.find(self.par[x])
      return self.par[x]
  def unit(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x==y:
      return
    elif self.rank[x]<self.rank[y]:
      self.par[x] = y
      self.size[y] += self.size[x]
      return
    elif self.rank[y]<self.rank[x]:
      self.par[y] = x
      self.size[x] += self.size[y]
    else:
      self.par[y] = x
      self.size[x] += self.size[y]
      self.rank[x] += 1 
  def same(self, x, y):
    return self.find(x)==self.find(y)
  
N = int(input())
X = []
Y = []
for i in range(N):
  x, y = map(int, input().split())
  X += [(x,y,i)]
  Y += [(x,y,i)]
X.sort()
Y.sort(key=lambda x:x[1])
hq = []
for i in range(N-1):
  x1, y1, i1 = X[i]
  x2, y2, i2 = X[i+1]
  heappush(hq, (x2-x1,i1,i2))
  x1, y1, i1 = Y[i]
  x2, y2, i2 = Y[i+1]
  heappush(hq, (y2-y1,i1,i2))

u  = UnionFind(N)
cnt = 1
ans = 0
while cnt<N:
  c, i1, i2 = heappop(hq)
  if u.same(i1,i2):
    continue
  ans += c
  cnt += 1
  u.unit(i1,i2)
print(ans)

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

int main()
{
	int m,n, N;
	int dice[101][101];
	scanf("%d", &N);
	for (n = 0; n < N; n++)
	{
		for (m = 0; m < 6; m++)
		{
			scanf("%d", &dice[n][m]);
		}
	}
	int i = 4, tmp, j = 4;
	for (n = 0; n < N - 1; n++)
	{
		for (m = n + 1; m < N; m++)
		{
			while (i--)
			{
				if (dice[n][0] == dice[m][0]
					&& dice[n][1] == dice[m][1]
					&& dice[n][2] == dice[m][2]
					&& dice[n][3] == dice[m][3]
					&& dice[n][4] == dice[m][4]
					&& dice[n][5] == dice[m][5])
				{
					printf("No\n");
					return 0;
				}
				while (j--)
				{
					tmp = dice[n][1];
					dice[n][1] = dice[n][2];
					dice[n][2] = dice[n][4];
					dice[n][4] = dice[n][3];
					dice[n][3] = tmp;
					if (dice[n][0] == dice[m][0]
						&& dice[n][1] == dice[m][1]
						&& dice[n][2] == dice[m][2]
						&& dice[n][3] == dice[m][3]
						&& dice[n][4] == dice[m][4]
						&& dice[n][5] == dice[m][5])
					{
						printf("No\n");
						return 0;
					}
				}
				j = 4;
				if (i % 2 == 0)
				{
					tmp = dice[n][0];
					dice[n][0] = dice[n][1];
					dice[n][1] = dice[n][5];
					dice[n][5] = dice[n][4];
					dice[n][4] = tmp;
					if (dice[n][0] == dice[m][0]
						&& dice[n][1] == dice[m][1]
						&& dice[n][2] == dice[m][2]
						&& dice[n][3] == dice[m][3]
						&& dice[n][4] == dice[m][4]
						&& dice[n][5] == dice[m][5])
					{
						printf("No\n");
						return 0;
					}
				}
				if (i % 2 == 1)
				{
					tmp = dice[n][0];
					dice[n][0] = dice[n][2];
					dice[n][2] = dice[n][5];
					dice[n][5] = dice[n][3];
					dice[n][3] = tmp;
					if (dice[n][0] == dice[m][0]
						&& dice[n][1] == dice[m][1]
						&& dice[n][2] == dice[m][2]
						&& dice[n][3] == dice[m][3]
						&& dice[n][4] == dice[m][4]
						&& dice[n][5] == dice[m][5])
					{
						printf("No\n");
						return 0;
					}
				}
			}
			i = 4;
		}
	}

	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 2648
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=1;i<=(n);i++)

int main(){
  int n,a,b,ans=0,ttl,ii;cin>>n>>a>>b;
  REP(i,n){
    ttl=0;ii=i;
    REP(j,5){
      ttl+=ii%10;
      ii/=10;
    }
    ans+=(((ttl>=a)&&(ttl<=b))?i:0);
  }
  cout<<ans;
}

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

int sign(int a) {
	if (a < 0) {
		return -1;
	} else if (a > 0) {
		return 1;
	} else {
		return 0;
	}
}

int main() {
	int n, a[100000];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	if (n < 3) {
		cout << 1 << endl;
	} else {
		int c = 1;
		int s = sign(a[1] - a[0]);
		for (int i = 2; i < n; i++) {
			int ss = sign(a[i] - a[i - 1]);
			if (s != 0 && ss != 0 && s != ss) {
				s = 0;
				c++;
			} else if (s == 0) {
				s = ss;
			}
		}
		cout << c << endl;
	}
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i = (m); i < (n); i++)
#define rrep(i,m,n) for(int i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll N;
ll A[100010], B[100010];
bool comp(lpair l1, lpair l2){
    return l1.first + l1.second > l2.first + l2.second;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll A[100010], B[100010];
    cin >> N;
    rep(i,0,N) cin >> A[i] >> B[i];
    vector<lpair> lp;
    rep(i,0,N) lp.push_back(make_pair(A[i], B[i]));
    sort(lp.begin(), lp.end(), comp);
    ll ans = 0;
    rep(i,0,N){
        if(i % 2 == 0){
            ans += lp[i].first;
        }else{
            ans -= lp[i].second;
        }
    }
    print(ans);
}


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

using namespace std;

//#define int long long
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;

inline void setMax(int &a, int b){ a = max(a, b); }
inline void setMin(int &a, int b){ a = min(a, b); }

signed main(){
    cin.tie(0); cout.tie(0); cin.sync_with_stdio(0); cout.sync_with_stdio(0);

    int N;
    cin >> N;
    vi v(N);
    for(auto &i : v) cin >> i;

    long double res = 0;
    for(auto i : v) res += 1/(long double)i;
    cout << setprecision(12) << 1/res;
}

Measured memory_bytes: 256
from bisect import bisect_left
import sys
sys.setrecursionlimit(1000000)



def dfs(p):
    ai = a[p]
    i = bisect_left(dp, ai)
    old = dp[i]
    dp[i] = ai
    ans[p] = bisect_left(dp, INF)-1
    for child in to[p]:
        if ans[child] is None:
            dfs(child)
    dp[i] = old
    
    
        

if __name__ == "__main__":
    n = int(input())
    a = [None] + list(map(int, input().split()))
    to = [[] for _ in range(n+1)]
    for _ in range(n-1):
        u, v = map(int, input().split())
        to[u].append(v)
        to[v].append(u)
    INF = 10**20
    dp = [INF]*(n+1)
    dp[0]= -INF
    ans = [None]*(n+1)
    dfs(1)
    print("\n".join(list(map(str, ans[1:]))))

Measured memory_bytes: 214624
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;


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

	ll n;
	cin >> n;
	vector<ll> a(1000001);
	vector<ll> b(n);

	ll tmp;
	rep(i, n)
	{
		cin >> tmp;
		a[tmp]++;
		b[i] = tmp;
	}

	sort(all(b));

	if (a[1] > 0)
	{
		if (a[1] > 1)
			cout << 0 << endl;
		else
			cout << 1 << endl;
		ret;
	}
	ll ans = 0;
	bool ok = false;

	rep(i, n)
	{
		if (i > 1 && b[i] == b[i - 1])
			continue;
		if (a[b[i]] > 1)
			continue;

		ll tmp = b[i];
		ok = false;
		for (ll j = 1; j * j <= b[i]; j++)
		{
			if (b[i] % j == 0)
			{
				if (a[j] > 0)
				{
					ok = false;
					break;
				}
				if (a[b[i] / j] > 0 && j != 1)
				{
					ok = false;
					break;
				}
				if (a[b[i] / j] > 1 && j == 1)
				{
					ok = false;
					break;
				}
			}
			else
			{
				if ((j + 1) * (j + 1) > b[i])
					ok = true;
				continue;
			}
			ok = true;
		}
		if (ok)ans++;


	}
	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 12700
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
using namespace std;

#define SEG_NUM (1<<20)

vector<map<char, int> > seg(SEG_NUM*2);

void update(int x, char newchr, char delchr){
    x += SEG_NUM;
    seg[x][newchr]++;
    seg[x][delchr]--;
    while(true){
        x /= 2;
        if(x==0)break;
        seg[x][newchr]++;
        seg[x][delchr]--;
    }
}

int find(int x, int y){
    x += SEG_NUM;
    y += SEG_NUM;
    set<char> ans;
    while(x < y){
        if(x % 2 == 1){
            for(char i='a';i<='z';++i){
                if(seg[x][i]>0){
                    ans.insert(i);
                }
            }
            x++;
        }
        x /= 2;
        if(y % 2 == 1){
            for(char i='a';i<='z';++i){
                if(seg[y-1][i]>0){
                    ans.insert(i);
                }
            }
            y--;
        }
        y /= 2;
    }
    /**
    for(auto i=ans.begin();i!=ans.end();++i){
        cout<<*i<<endl;
    }
    **/
    return ans.size();
}

int main() {
    int N;
    cin>>N;
    string S;
    cin>>S;
    for(long i=0;i<S.size();++i){
        seg[SEG_NUM+i][S[i]]++;
    }
    for(long i=0;i<S.size();++i){
        long x = i + SEG_NUM;
        while(true){
            x /= 2;
            if(x==0)break;
            seg[x][S[i]]++;
        }
    }
    int Q;
    cin>>Q;
    int query, left, right, pos;
    char newchr;
    for(int i=0;i<Q;++i){
        cin>>query;
        if(query==1){
            cin>>pos>>newchr;
            pos--;
            update(pos, newchr, S[pos]);
            S[pos] = newchr;
        }
        else{
            cin>>left>>right;
            left--;
            right--;
            cout<<find(left, right+1)<<endl;
        }
    }
}


Measured memory_bytes: 323332
n = int(input())
a = [int(_) for _ in input().split()]
m = int(input())
b = [int(_) for _ in input().split()]

dp = [[False for i in range(4300)]for i in range(2)]
dp[0][0] = True
dp[1][0] = True
c = False
for i in a:
    for j in range(4000):
        if dp[c][j]:
            dp[not(c)][j+i] = True
            dp[not(c)][j] = True
    c = not(c)

for i in b:
    if dp[c][i]:
        print("yes")
    else:
        print("no")

# print(dp[c][:20])



Measured memory_bytes: 5704
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000000
using namespace std;
typedef long long ll;

int main() {
	ll i, j;
	ll S;
	pair<ll, ll> P1, P2;
	cin >> S;
	ll mul1 = mod - ((S - 1) % mod) - 1;
	ll mul2 = S + mul1;
	P1.first = 1;
	P2.second = mul1;
	P2.first = mul2 / mod;
	P1.second = mod; 
	cout << "0 0 1 " << P1.second << " " << P2.first << " " << P2.second << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=5e5+1000;
ll n,v[maxn],c[maxn];
int main()
{
    scanf("%lld",&n);
    ll maxv=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&v[i]);
    }
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&c[i]);
        if(v[i]-c[i]>0)    maxv+=v[i]-c[i];
    }
    printf("%lld",maxv);
    return 0;
}   

Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    int N; cin >> N;
    string S; cin >> S;
    
    vector<int> B(N+1);
    vector<int> W(N+1);
    for(int i=0; i<N; i++){
        if(S[i]=='#') B[i+1] = B[i] + 1;
        else B[i+1] = B[i];
        
        if(S[i]=='.') W[i+1] = W[i] + 1;
        else W[i+1] = W[i];
    }
    
    int ans = INF;
    for(int i=0; i<N+1; i++){
        ans = min(ans, B[i] + W[N] - W[i]);
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 2180
#[test]
fn check_solve() {
    println!("input:\n5\n\noutput:\n{}", solve("5\n"));
    println!("input:\n6\n\noutput:\n{}", solve("6\n"));
    println!("input:\n8\n\noutput:\n{}", solve("8\n"));
}
fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let n: usize = sc.read();

    let lst = vec![
        1, 3, 4, 6, 7, 10, 13, 15, 18, 19, 21, 24, 25, 27, 28, 31, 33, 40, 42, 43, 46, 49, 52, 54,
        57, 60, 63, 64, 66, 69, 70, 75, 76, 81, 82, 88, 91, 94, 97, 99, 102, 103, 105, 106, 109,
        115, 117, 118, 120, 123, 129, 130, 132, 136, 138,
    ];

    let mut ret = String::new();
    use std::fmt::Write;

    for i in 0..n {
        write!(&mut ret, "{} ", lst[i] * 10 + 1).unwrap();
    }

    ret
}
fn main() {
    let mut buf = String::new();
    use std::io::{Read, Write};
    std::io::stdin().read_to_string(&mut buf).unwrap();
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}


Measured memory_bytes: 4352