akhauriyash/Code-Regression huggingface dataset:
//2019.5.15 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-10
#define RG register
inline int read() {
    res s=0,ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline LL Read() {
    RG LL s=0;
    res ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N=200+10;
namespace MAIN {
    int n,m;
    char str[N][N];
    int dp[2][N][N][N],ans;
    inline void MAIN(){
        n=read(),m=read();
        for(res i=1;i<=n;i++)scanf("%s",str[i]+1);
        res cur=0;
        for(res i=n;i;i--)
            for(res j=i;j<=n;j++)
                for(res h=m;h;h--){
                    res &DP=dp[0][i][j][h];
                    if(i==j||(str[i][h]==str[i+1][h]&&dp[0][i+1][j][h]>h)){
                        if(h!=m&&str[i][h]==str[i][h+1])DP=dp[0][i][j][h+1];
                        else DP=h+1;
                    }
                    else DP=h;
                }
        while(dp[cur][1][n][1]!=m+1){
            for(res i=n;i;i--)
                for(res j=i;j<=n;j++)
                    for(res h=m;h;h--){
                        res &DP=dp[cur^1][i][j][h],DP0=dp[cur][i][j][h];
                        DP=(DP0<=m?dp[cur][i][j][DP0]:m+1);
                        if(i!=j){
                            res l=i,r=j-1;
                            while(l<=r){
                                res mid=(l+r)>>1,F=dp[cur][i][mid][h],G=dp[cur][mid+1][j][h];
                                DP=max(DP,min(F,G));
                                if(F>G)l=mid+1;
                                else r=mid-1;
                            }
                        }
                    }
            cur^=1,ans++;
        }
        printf("%d\n",ans);
    }
}
int main() {
//    srand((unsigned)time(NULL));
//    freopen("graph.in","r",stdin);
//    freopen("graph.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 67456
H,W = map(int,input().split())

table = [[0]*(W+1) for i in range(H+1)]

for row in range(H):
    work = list(map(int,input().split())) 
    for col in range(W):
        table[row][col] = work[col]


for row in range(H):
    for col in range(0,W):
        table[row][W] += table[row][col]


for col in range(0,W+1):
    for row in range(0,H):
        table[H][col] += table[row][col]


for row in range(0,H+1):
    print("%d"%(table[row][0]),end="")
    for col in range(1,W+1):
        print(" %d"%(table[row][col]),end = "")
    print()


Measured memory_bytes: 6200
import java.util.*;
public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int N = sc.nextInt();
        int[] A = new int[N];
        for(int i=0;i<N;i++){
            A[i] = sc.nextInt();
        }
        int sep = K-A[N-1] + A[0];
        for(int i=1;i<N;i++){
            sep = Math.max(sep, A[i]-A[i-1]);
        }
        System.out.println(K-sep);
    }

}


Measured memory_bytes: 79296
#include<stdio.h>
int main(){
int w,n,a,b,x[40],i,k;
scanf("%d",&w);
scanf("%d",&n);
for(i=0;i<w;i++)
x[i]=i+1;
for(i=0;i<n;i++){
scanf("%d,%d",&a,&b);
k=x[a-1];
x[a-1]=x[b-1];
x[b-1]=k;
}
for(i=0;i<w;i++)
printf("%d\n",x[i]);
return 0;
}

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

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

  int l,r;
  l=a+b;
  r=c+d;
  
  if (l < r) {
    cout << "Right" << endl;
  }
  else if (l>r) {
    cout << "Left" << endl;
  } 
  else {
    cout << "Balanced" << endl;
  } 
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

    int a[3];
    int i = 0, n = 0;

    scanf("%d %d %d", &a[0], &a[1], &a[2]);

    while (i <= 1)
    {
      if (a[i] > a[i + 1])
        {
        n        = a[i];
        a[i]     = a[i + 1];
        a[i + 1] = n;
        }
      i++;
    }

    if (a[0] > a[1])
    {
    n    = a[0];
    a[0] = a[1];
    a[1] = n;
    }

    printf("%d %d %d\n", a[0], a[1], a[2]);

return 0;
}

Measured memory_bytes: 596
S = input()

ac = True

if S[0] != "A":
    ac = False

cnt = 0
for s in S[2:-1]:
    if s == "C":
        cnt += 1
if cnt != 1:
    ac = False

for s in S[1:]:
    if s != "C" and s.isupper():
        ac = False

if ac:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3064
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N1 15
#define ll long long
#define inf 0x3f3f3f3f
#define mod 998244353
using namespace std;

int n,a[N1];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		printf("ACL");
	}
	puts("");
	return 0;
}



Measured memory_bytes: 3228
#include <stdio.h>
int main(void){
int m=0,f=0,r;
while(scanf("%d %d %d", &m, &f, &r)!=EOF){
    int s = m + f;
    if(m == -1 && f == -1 && r == -1){ 
      break;
  }
    if(m==-1 || f==-1){
        printf("F");
    }
  
    else if (s>=80){
      printf("A");
  }
    else if(65<=s){
      printf("B");
  }
    else if(50<=s||r>=50){
      printf("C");
  }    
    else if(30<=s){
      printf("D");
  }
    else if(s<30){
      printf("F");
  }
    printf("\n");
}
    return(0);
}



Measured memory_bytes: 2128
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main(){
    int a,b,c,d;
    while(~scanf("%1d%1d%1d%1d",&a,&b,&c,&d)){
        if(a==b||b==c||c==d)
            printf("Bad\n");
        else
            printf("Good\n");
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<functional>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<vector>
#include<deque>
#include<stack>
#include<map>
using namespace std;

#define mod 10007

#define ll long long
#define ull unsigned long long


int main() {
	ll answer = 0;
	ll n;
	cin >> n;
	ll temp = (n / 11);
	n -= ((n / 11) * 11);
	answer += (temp * 2);
	while (n > 0) {
		n -= 6;
		answer += 1;
		if (n <= 0)break;
		n -= 5;
		answer += 1;
	}
	printf("%lld",answer);
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, m; cin >> n >> m;
  map<int, int> mp;
  mp[1] = 2; mp[2] = 5; mp[3] = 5; mp[4] = 4; mp[5] = 5;
  mp[6] = 6; mp[7] = 3; mp[8] = 7; mp[9] = 6;
  vector<int> a(m); REP(i, m) cin >> a[i];
  set<int> st;
  REP(i, m) st.insert(mp[a[i]]);
  vector<int> dp(n + 1, -INF);
  dp[0] = 0;
  REP(i, n) if (dp[i] >= 0) {
    for (int e : st) if (i + e <= n) {
      dp[i + e] = max(dp[i + e], dp[i] + 1);
    }
  }
  map<int, string> hukugen;
  sort(ALL(a), greater<int>());
  string ans = "";
  for (int i = n; i > 0; ) {
    REP(j, m) {
      int tmp = mp[a[j]];
      if (i - tmp >= 0 && dp[i] == dp[i - tmp] + 1) {
        ans += to_string(a[j]);
        i -= tmp;
        break;
      }
    }
  }
  sort(ALL(ans));
  reverse(ALL(ans));
  cout << ans << '\n';
  return 0;
}


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


#define testcases ll t;cin>>t;while(t--)
#define queries ll q;cin>>q;while(q--)
#define ll long long 
#define loop(i,x,n) for(ll i=x;i<n;i++)
#define ff first
#define ss second
#define pb push_back
#define elif else if
#define flush cout<<endl;
#define mod 1000000007


int main(){

    string a;
    cin>>a;

    long n = a.size(),ct = 0;

    loop(i,0,n/2){
        if(a[i]!=a[n-i-1])
            ct++;
    }

    cout<<ct;
    flush;



}


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

int main() {
  int l,r,d;
  cin >> l >> r >> d;
  int res = 0;
  for(int i = l; i <=r; ++i) {
    if(i % d == 0) res++;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
const int N=6005;
int n,p[N],pp[N],t[N];
int q[N],head,tail;
string res[N],now;
char s[N];
vector <int> a,b;
int main(){
    scanf("%d",&n);
    n<<=1;
    scanf("%s",s+1);
    a.clear(),b.clear();
    for (int i=1;i<=n;i++)
        if (s[i]=='a')
            a.push_back(i);
        else
            b.push_back(i);
    for (int i=1;i<=n/2;i++)
        p[b[i-1]]=a[i-1],pp[a[i-1]]=b[i-1];
    for (int i=1;i<=n+1;i++)
        res[i]="";
    int tot=0;
    int nxt=n+1;
    for (int i=n;i>=1;i--){
        if (s[i]=='a')
            tot++;
        else
            tot--;
        if (tot)
            continue;
        memset(t,0,sizeof t);
        head=1,tail=0;
        res[i]=res[nxt];
        for (int j=i;j<nxt;j++){
            if (s[j]=='a'){
                if (t[j]){
                    now="";
                    for (int k=i;k<nxt;k++)
                        if (s[k]=='b'){
                            if (t[k]||k>j)
                                now+="b";
                        }
                        else if (t[k]||k>p[q[tail]])
                            now+="a";
                    res[i]=max(res[i],now+res[nxt]);
                    head++;
                    t[j]=t[pp[j]]=0;
                }
                continue;
            }
            if (p[j]<j)
                continue;
            q[++tail]=j;
            t[j]=t[p[j]]=1;
        }
        memset(t,0,sizeof t);
        if (tail==0){
            for (int j=i;j<nxt;j++){
                if (s[j]=='b')
                    continue;
                t[j]=t[pp[j]]=1;
                now="";
                for (int k=i;k<=pp[j];k++)
                    if (t[k])
                        now+=s[k];
                res[i]=max(res[i],now+res[nxt]);
                j=pp[j];
            }
        }
        nxt=i;
    }
    cout << res[1];
    return 0;
}

Measured memory_bytes: 10624
#include <stdio.h>
#include <math.h>
#define INF 2000000

int n,p[301],m[301][301];

void matrixChainOrder(){
  int i,j,k,l,q;
  for(i=1;i<=n;i++)m[i][i]=0;
  for(l=2;l<=n;l++)
    for(i=1;i<=n;i++){
      j=i+l-1;
      m[i][j]=INF;
      for(k=i;k<=j;k++){
	q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	m[i][j]=fmin(m[i][j],q);
      }
    }
}

int main(){
  int i;
  scanf("%d",&n);
  for(i=1;i<=n;i++)scanf("%d %d",&p[i-1],&p[i]);
  matrixChainOrder();
  printf("%d\n",m[1][n]);
  return 0;
}



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

int main() {
	int a, b, d, r;
	double fa,fb,f;

	cin >> a >> b;

	d = a / b;
	r = a % b;
	fa = a;
	fb = b;

	f = fa / fb;

	cout << d << " " << r << " " << fixed << setprecision(20) << f << endl;

	return 0;
}


Measured memory_bytes: 3260
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
string table[]={"dream","dreamer","erase","eraser"};
string s;
const long long MOD = 1e9 + 7;
bool f[100100];
int main(void){
    long long n,a=1;
    cin>>n;
    rep(i,n){
        a=a*(i+1)%MOD;
    }
    cout<<a<<endl;
    return 0;
}

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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

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

    ll a = 1, b = 1;
    for(int i = 0; i < n; ++i) {
        ll x, y;
        cin >> x >> y;

        ll c1 = (x + a - 1) / x;
        ll c2 = (y + b - 1) / y;
        ll c = max(c1, c2);

        a = x * c;
        b = y * c;
    }

    cout << a + b << endl;

    return 0;
}

Measured memory_bytes: 256
//####################################################################
//#####In the Name Of Allah,the Most Gracious,the Most Merciful.######
//####################################################################

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

#define maxn            100010
#define esp             1e-6
#define mod             1000000007
#define ll              long long
#define inf             1061109567
#define ff  first
#define ss  second

typedef pair<int, int> ii;
typedef pair<int, ii> iii;

int Set(int N, int pos) {return N = N | (1 << pos);}
int reset(int N, int pos) {return N = N & ~ (1 << pos);}
bool check(ll N, int pos) {return (bool) (N & (1LL << pos));}

vector<int> A, B, C;
int Brr[maxn];
ll csum[maxn];
int n, x;

int main()
{
        scanf("%d", &n);

        for(int i = 1; i <= n; i ++){
                scanf("%d", &x);
                A.push_back(x);
        }

        for(int i = 1; i <= n; i ++){
                scanf("%d", &x);
                B.push_back(x);
        }
        for(int i = 1; i <= n; i ++){
                scanf("%d", &x);
                C.push_back(x);
        }
        sort(A.begin(), A.end());
        sort(B.begin(), B.end());
        sort(C.begin(), C.end());
        ll last = 0;
        for(int i = 0; i < n; i ++){
                int lo = upper_bound(C.begin(), C.end(), B[i]) - C.begin();
                Brr[i] = n - lo;
                csum[i] = Brr[i] + last;
                last = csum[i];
        }
        ll ans = 0;
        for(int i = 0; i < n; i ++){
                int lo = upper_bound(B.begin(), B.end(), A[i]) - B.begin();
                ll bad = 0;
                if(lo - 1 >= 0) bad = csum[lo - 1];
                ans += (csum[n - 1] - bad);
        }
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 2680
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
    int mn=1000000007,mx=0,res=0,tg=0,a[100001],n;
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        cin>>a[i];
        mn=min(mn,a[i]);
        mx=max(mx,a[i]);
        res+=a[i];
        tg+=i;
    }
    if(res%tg!=0){cout<<"NO";exit(0);}
    if(mn<res/tg){cout<<"NO";exit(0);}
    if(mx>res/tg*n){cout<<"NO";exit(0);}
    for(int i=1;i<=n;++i)
    {
        int trc=i-1;
        if(trc==0)trc=n;
        trc=a[trc];
        trc+=res/tg;
        if(trc<a[i]){cout<<"NO";exit(0);}
        if((trc-a[i])%n!=0){cout<<"NO";exit(0);}
        if((trc-a[i])/n>res/tg){cout<<"NO";exit(0);}
    }
    cout<<"YES";
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const double PI=acos(-1.0);


int gcd(int a, int b)
{
    int c=a%b;
    while(c!=0){
        a=b; b=c; c=a%b;
    }
    return b;
}

int N; 
void input()
{
    cin>>N;
}

void solve()
{
    ll ans=0;
    for(int i=1;i<N+1;++i){
        int j=1;
        while(i*j<=N){
            ans+=i*j; ++j;
        }
    }
    cout<<ans<<endl;
}

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

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

int main(void)
{
    using namespace std;
    int X, Y, Z;
    scanf("%d %d %d", &X, &Y, &Z);

    swap(X, Y);
    swap(X, Z);

    printf("%d %d %d\n", X, Y, Z);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <ios>
#include <iomanip>
#include <cmath>
#include <regex>
#include <bitset>
using namespace std;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a+b>=c ? "Yes": "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define F first
#define S second
#define ld long double
int const M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e9+10;
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
ll pow(ll a, ll b){ll res = 1;for(int i = 1; i<=b; ++i) res *= a;return res;}
ll isPrime(ll n){for(ll i=2; i<=sqrt(n); i++){if(n%i==0) return 0;}return 1;}
ll fact(ll n){if(n==0 || n==1) return 1; else return n*fact(n-1);}
ll gcd (ll a, ll b) {return b ? gcd (b, a % b) : a;}
int a[18]={2,3,5,7,11,13,13,17,19,23,29,31,37,41,43,47,53,59};
void Sieve(ll n, ll prime[]){for(int p=2; p*p<=n; p++){if(prime[p] == true){for(int i=p*2; i<=n; i += p)prime[i] = false;}}for(int p=2; p<=n; p++)if(prime[p])cout << p << " ";}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a,a+3);
	ll res=a[2]*10  + a[0] + a[1];
	cout << res;
	return 0;
}
/* The judge is never wrong! Your code is buggy 😈
   Look for:
 * * an easier and alternate approach
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * overflow (ll vs int?)
 * * array bounds
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */


Measured memory_bytes: 256
import java.util.*;


public class Main{ 

	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int operationNum = scan.nextInt();
		BinarySearchTree tree = new BinarySearchTree();
		scan.nextLine();
		for(int i=0; i<operationNum; i++)
			tree.operation(scan);
		// ArrayList<BinarySearchTreeNode> list = 
		//  tree.inOrderConnect(new ArrayList<BinarySearchTreeNode>());

	}

}
class BinarySearchTree{
	private BinarySearchTreeNode root=null;
	public BinarySearchTree(){
		//root = new BinarySearchTreeNode();
	}
	public void operation(Scanner sc){
		if(sc.next().equals("print"))
			print();
		else{
			//String[] key = code.split(" ");
			insert(Integer.parseInt(sc.next()));		
		}

	}
	public void insert(int key){
		if(root==null)
			root = new BinarySearchTreeNode(key);
		else
			root.insertNode(key);
	}
	public void print(){
		ArrayList<BinarySearchTreeNode> list = new ArrayList<BinarySearchTreeNode>();
		keyOrderToString(this.root.inOrderConnect(list));
		list = new ArrayList<BinarySearchTreeNode>();
		keyOrderToString(this.root.preOrderConnect(list));
	}
	private static void keyOrderToString(ArrayList<BinarySearchTreeNode> list){
		// StringBuilder temp = new StringBuilder();
		// for(Iterator<BinarySearchTreeNode> iter = list.iterator(); iter.hasNext();)
		// 	temp.append(" "+iter.next().getKey());
		// System.out.println(new String(temp));
		for(Iterator<BinarySearchTreeNode> iter = list.iterator(); iter.hasNext();){
			System.out.print( new StringBuilder().append(" ").append(iter.next().getKey()));

		}
		System.out.println("");	
	}

}



class BinarySearchTreeNode{
	protected int key;
	protected BinarySearchTreeNode parent = null;
	protected BinarySearchTreeNode LeftChild = null;
	protected BinarySearchTreeNode RightChild = null;
	public BinarySearchTreeNode(int key){
		this.key = key;
	}
	public BinarySearchTreeNode(int key, BinarySearchTreeNode parent){
		this.key = key;
		this.parent = parent;
	}
	void insertNode(int key){
		if(key < this.key){
			if(this.LeftChild ==null)
				this.LeftChild = new BinarySearchTreeNode(key, this);
			else
				this.LeftChild.insertNode(key);
			return;
		}else{
			if(this.RightChild ==null)
				this.RightChild = new BinarySearchTreeNode(key, this);
			else
				this.RightChild.insertNode(key);
			return;
		}
	}
	public ArrayList<BinarySearchTreeNode> preOrderConnect(ArrayList<BinarySearchTreeNode> list){
		list.add(this);
		if(LeftChild!=null)
			LeftChild.preOrderConnect(list);
		if(RightChild!=null)
			RightChild.preOrderConnect(list);
		return list;
	}
	public ArrayList<BinarySearchTreeNode> inOrderConnect(ArrayList<BinarySearchTreeNode> list){
		if(LeftChild!=null)
			LeftChild.inOrderConnect(list);
		list.add(this);
		if(RightChild!=null)
			RightChild.inOrderConnect(list);
		return list;
	}	
	public int getKey(){
		return this.key;
	}

}

Measured memory_bytes: 200864
from bisect import bisect_left, bisect_right

N = int(input())
A = sorted([int(x) for x in input().split()])
B = sorted([int(x) for x in input().split()])
C = sorted([int(x) for x in input().split()])

ans = 0
for b in B:
    ans += bisect_right(A, b - 1) * (N - bisect_left(C, b + 1))
print(ans)


Measured memory_bytes: 23232
#include <stdio.h>
#pragma warning(disable : 4996)
long double a, b, c, d, e, f, x, y;
int main() {
	while (~scanf("%Lf%Lf%Lf%Lf%Lf%Lf", &a, &b, &c, &d, &e, &f)) {
		x = (c * e - b * f) / (a * e - b * d);
		y = (a * f - c * d) / (a * e - b * d);
		if (-0.0005 < x && x < 0.0005) x = 0.0;
		if (-0.0005 < y && y < 0.0005) y = 0.0;
		printf("%.3Lf %.3Lf\n", x, y);
	}
	return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] X = new int[N];
		for(int i=0; i<N; i++) {
			X[i] = scan.nextInt();
		}
		scan.close();

		Arrays.sort(X);

		int sum = 0;
		for(int i=0; i<X.length-1; i++) {
			sum+=X[i];
		}
		sum+=X[X.length-1]/2;
		System.out.println(sum);
	}
}


Measured memory_bytes: 21972
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
	string str;
	cin >> str;
	for (int i = 0; i < str.size(); i++) {
		if (str.at(i) == '1') str.at(i) = '9';
		else str.at(i) = '1';
	}
	cout << str;
}

Measured memory_bytes: 764
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x,a;
        x = sc.nextInt();
        a = sc.nextInt();
        if(x<a){
            System.out.println(0);
        }else{
            System.out.println(10);
        }

    }
}


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

int main() {
    int n, odd = 0, even = 0;
    cin >> n;
    rep(i, n) {
        ll a;
        cin >> a;
        if (a & 1)
            odd++;
        else
            even++;
    }
    while (1) {
        bool changed = false;
        if (odd >= 2) {
            odd -= 2;
            even++;
            changed = true;
        }
        if (even >= 2) {
            even--;
            changed = true;
        }
        if (!changed) break;
    }
    puts(odd ^ even ? "YES" : "NO");
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	vector<pii>V(5);
	for (int i = 0; i < 5; ++i) {
		int a;
		cin >> a;
		V[i].first = a % 10;
		V[i].second = a;
	}
	sort(V.begin(), V.end());
	int key = 6;
	for (int i = 0; i < 5; ++i) {
		if (V[i].first != 0) {
			key = i;
			break;
		}
	}
	if (key == 6) {
		int sum = 0;
		for (int i = 0; i < 5; ++i) {
			sum += V[i].second;
		}
		cout << sum << endl;
	}
	else {
		int sum = 0;
		for (int i = 0; i < 5; ++i) {
			if (V[i].first % 10 == 0 || i == key) {
				sum += V[i].second;
			}
			else {
				sum += (V[i].second + (10 - (V[i].first)));
			}
		}
		cout << sum << endl;
	}
	return 0;
}

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

int N,A,B,C,D;
string S;
int cont = 0;
const int MAX_A = 200000;
const int MAX_B = 200000;
bool reachA[MAX_A]= {false};
bool reachB[MAX_B]= {false};
int func(int A,int B){
    //cout << A<<B<<endl;
    

    
    //cout <<S.substr(A-1,1)<<endl;
    if(S.substr(A-1,1)=="#")return 0;
    //cout <<S.substr(B-1,1)<<endl;
    if(S.substr(B-1,1)=="#")return 0;
    if(A==B)return 0;
    if(reachA[A]&&reachB[B])return 0;
    
    // for(int i = 0; i < S.length();i++){
    //     if(i==A-1)cout <<"A";
    //     else if(i==B-1)cout <<"B";
    //     else cout <<S.substr(i,1);
    // }
    // cout << endl;
    
    if(A==C&&B==D){
        cont++;
        return 0;
        
    }
    
    reachA[A]=true;
    reachB[B]=true;
    if(A<C&&A+1<=S.length())func(A+1,B  );
    
    if(A<C&&A+2<=S.length())func(A+2,B  );
    
    
    if(B<D&&B+1<=S.length())func(A  ,B+1);
    
    if(B<D&&B+2<=S.length())func(A  ,B+2);
    
    
    return 0;
}



int main(void){
    
    cin >> N >> A >> B >> C >> D;
    cin >> S;
    string ans = "No";
    func(A,B);
    //cout << cont <<endl;
    if(cont > 0)ans ="Yes";
    cout <<ans <<endl;
    
}


Measured memory_bytes: 12932
let n = read_int ()
let f n = let rec f i = if i > n then 0 else f (i + 1) + if n mod i = 0 then 1 else 0 in f 1
let ans = ref 0
let _ = for i = 1 to n do if i mod 2 = 1 && f i = 8 then incr ans done; Printf.printf "%d\n" !ans

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
const int mod=1e9+7;
using LL=long long;
using std::cout;using std::endl;using std::cin;
using std::vector;using std::string;using std::set;using std::multiset;
using std::pair;using std::map;
using std::min;using std::max;

namespace ndifix{
}

int main(){
  int a,p;cin>>a>>p;
  cout<<(3*a+p)/2<<endl;

  
  return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
from bisect import bisect_right
N, M, K = map(int,input().split())
A = [0]+list(accumulate(map(int,input().split()), lambda x,y:x+y))
B = [0]+list(accumulate(map(int,input().split()), lambda x,y:x+y))
ans = 0
for i in range(N+1):
    left = K-A[i]
    if left < 0:
        break
    j = bisect_right(B, left)
    ans = max(ans, i+j-1)
print(ans)

Measured memory_bytes: 45672
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;

    int X=x2-x1;
    int Y=y2-y1;

    cout<<x2-Y<<" "<<y2+X<<" "
        <<x1-Y<<" "<<y1+X<<endl;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int a, b;
    std::cin >> a >> b;
    const auto c = a + b;
    if (c >= 10)
    {
        std::cout << "error" << std::endl;
    }
    else
    {
        std::cout << c << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define MAX 110
#define inf 1<<28
#define f first
#define s second
#define mp make_pair
using namespace std;
 
int w,h,n,si,sj,gi,gj;
bool grid[MAX][MAX]={};
int Y[4]={1,0,-1,0};
int X[4]={0,1,0,-1};
int d[MAX][MAX];
 
int bfs(){
  for(int i=0;i<MAX;i++){
    for(int j=0;j<MAX;j++)d[i][j]=inf;
  }
  d[si][sj]=0;
  queue<pair<int,int> > q;
  q.push(mp(si,sj));
 
  while(q.size()){
    pair<int,int> u=q.front();
    q.pop();
    if(u.f==gi && u.s==gj)return d[gi][gj];
 
    for(int k=0;k<4;k++){
      int a=u.f+Y[k],b=u.s+X[k];
      if(grid[a][b])continue;
      a+=Y[k];
      b+=X[k];
      if(d[a][b]==inf){
    d[a][b]=d[u.f][u.s]+1;
    q.push(mp(a,b));
      }
    }
  }
  return -1;
}
 
int main()
{
  int a,b,c,d;
  
  cin>>w>>h>>n;
 
  for(int i=0;i<=h*2;i++)grid[i][0]=grid[i][w*2]=true;
  for(int i=0;i<=w*2;i++)grid[0][i]=grid[h*2][i]=true;
 
  for(int i=0;i<n;i++){
    cin>>a>>b>>c>>d;
    for(int j=min(a,c)*2;j<=max(a,c)*2;j++){
      for(int k=min(b,d)*2;k<=max(b,d)*2;k++)grid[k][j]=true;
    }
  }
  cin>>sj>>si>>gj>>gi;
  si=si*2+1;
  sj=sj*2+1;
  gi=gi*2+1;
  gj=gj*2+1;
 
  int dis=bfs(),ans=0;
 
  for(int i=2;i<=h*2-2;i+=2){
    for(int j=1;j<=w*2-1;j+=2){
      if(grid[i][j])continue;
      grid[i][j]=true;
      ans=max(bfs()-dis,ans);
      grid[i][j]=false;
    }
  }
  for(int i=1;i<=h*2-1;i+=2){
    for(int j=2;j<=w*2-2;j+=2){
      if(grid[i][j])continue;
      grid[i][j]=true;
      ans=max(bfs()-dis,ans);
      grid[i][j]=false;
    }
  }
  cout<<ans<<endl;  
 
  return 0;
}


Measured memory_bytes: 3160
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  ll n,z,w;cin>>n>>z>>w;
  vl a(n);
  rep(i,n)cin>>a[i];
  ll p=abs(a[n-1]-w);
  ll q=0;
  if(n>=2)q=abs(a[n-1]-a[n-2]);
  cout<<max(p,q)<<endl;
}
  
    
      
  

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

const Int MOD = 998244353;

int main(){
    Int A, B, C, D;
    cin >> A >> B >> C >> D;

    Int h, w;
    h = C - A + 1;
    w = D - B + 1;
    vector<vector<Int>> dp(3010, vector<Int>(3010,0));
    dp[0][0] = 1;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (i == 0 && j == 0) continue;
            if (i == 0) dp[i][j] = (dp[i][j-1] * A) % MOD;
            else if (j == 0) dp[i][j] = (dp[i-1][j] * B) % MOD;
            else dp[i][j] = (((((dp[i][j-1] * (Int)(A + i)) % MOD) + ((dp[i-1][j] * (Int)(B + j)) % MOD)) % MOD) - (((dp[i-1][j-1] * (Int)(A+i-1)) % MOD * (Int)(B+j-1)) % MOD) +  MOD) % MOD;
        }
    }
    cout << dp[h-1][w-1] << endl;

    return 0;

}

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

int main(){
    int n, k; cin >> n >> k;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    sort(h.begin(), h.end());
    rep(i, min(k, n)) h[n-1-i] = 0;
    ll ans = 0;
    rep(i, n) ans += h[i];
    cout << ans << endl;
}

Measured memory_bytes: 1792
// be name khoda
#include<bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define int long long
#define mpr make_pair 
#define pii pair<int,int>
typedef long long ll;
#pragma GCC optimize("Ofast")

const int maxn = 2e5+10;
const int mod = 998244353;
const int inf = 1e9+10;

int n, x;
int a[maxn];

signed main()
{
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    cin>> n >> x;
    if(x == 1 || x == 2*n-1) return cout<<"No", 0;
    
    a[n-1] = x-1; a[n] = x; a[n+1] = x+1;
    int L = 1;
    cout<<"Yes\n";
    for(int i = 1; i <= 2*n-1; i++)
    {
        if(!a[i])
        {
            if(L == x-1)
                L = x+2;
            a[i] = L++;
        }
        cout<< a[i] <<"\n";
    }
}

 





Measured memory_bytes: 3072
ar1 = list(map(int, input().split()))
ar2 = list(map(int, input().split()))
ar3 = list(map(int, input().split()))

for i in range(100):
	a1 = i
	b1 = ar1[0] - a1
	b2 = ar1[1] - a1
	b3 = ar1[2] - a1
	a2 = ar2[0] - b1
	a3 = ar3[0] - b1
	if a2 + b2 == ar2[1] and a2 + b3 == ar2[2] and a3 + b2 == ar3[1] == ar3[1] and a3 + b3 == ar3[2]:
		print ("Yes")
		exit()
print ("No")

Measured memory_bytes: 3064
while True:
    a, op, b = input().split()
    if op=="+":
        print(int(a) + int(b))
    elif op=="-":
        print(int(a)-int(b))
    elif op=="*":
        print(int(a)*int(b))
    elif op=="/":
        print(int(a)//int(b))
    else:
        break

Measured memory_bytes: 7644
class Node:
    def __init__(self, num, children):
        self.num = num
        self.children = children
        self.parents = -1
        self.type = None
        self.depth = 0

    def output(self):
        print('node {0}: parent = {1}, depth = {2}, {3}, {4}'.format(self.num,
                                                                      self.parents,
                                                                      self.depth,
                                                                      self.type,
                                                                      self.children))


def set_node(num, children):
    node = Node(num, children)
    T[num] = node
    for n in children:
        T[-1] -= n  # ?????£???T[-1]???root???????????????????????????


def set_pdt(n_i, parent, depth):
    node = T[n_i]
    node.parents = parent
    node.depth = depth
    if node.children:
        node.type = 'internal node'
        for n in node.children:
            set_pdt(n, n_i, depth + 1)
    else:
        node.type = 'leaf'


n = int(input())
tree = [list(map(int, input().split())) for i in range(n)]
T = [None] * n
T += [n * (n - 1) // 2]
for j in tree:
    set_node(j[0], j[2:])

set_pdt(T[-1], -1, 0)

T[T[-1]].type = 'root'

for n in T[:-1]:
    n.output()

Measured memory_bytes: 69288
import std.stdio;
import std.string, std.conv;
import std.array, std.algorithm;
import std.typecons;

void main() {
  for(int N; N = readln.chomp.to!int, N; ) {

    alias Tuple!(int, "name", int, "time") team;
    auto v = new team[N];

    foreach(i; 0 .. N) {
      auto s = readln.split.map!(to!int).array;
      int name = s[0];
      int c1 = s[1] * 60 + s[2];
      int c2 = s[3] * 60 + s[4];
      int c3 = s[5] * 60 + s[6];
      int c4 = s[7] * 60 + s[8];

      v[i] = tuple(name, c1 + c2 + c3 + c4);
    }
    sort!("a.time < b.time")(v);

    writeln(v[0].name);
    writeln(v[1].name);
    writeln(v[v.length - 2].name);
  }
}

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

int main(){
  int n;
  cin >> n;
  int ans = 0;
  int cnt = 1;

  for (int i = 0; i < n; i++)
  {
    int a;
    cin >> a;
    if(a!=cnt) ans++;
    else cnt++;
  }
  if(ans==n) cout << -1 << endl;
  else cout << ans << endl;
}

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

struct UnionFind {
    vector<int> data;
    UnionFind(int n=0): data(n, -1) {}
    int find(int x) {
        if (data[x] < 0) return x;
        return data[x] = find(data[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -data[find(x)]; }
};

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        uf.unite(a, b);
    }
    int ans = 0;
    rep(i, n) ans = max(ans, uf.size(i));
    cout << ans << endl;
    return 0;
}

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

total = []


for i in range(1, n + 1):
    if i % 15 == 0:
        "FizzBuzz"
    elif i % 5 == 0:
        "Buzz"
    elif i % 3 == 0:
        "Fizz"
    else:
        total.append(i)  # リストに加える
print(sum(total))

Measured memory_bytes: 29696
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll a,b;
  cin >> a >> b;
  if(a <= 9 && b <= 9)cout << a * b << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(VECTOR) (VECTOR).begin(), (VECTOR).end()

//parent[i]:ノード番号iの親のノード番号
//親が存在しないときは-(属するグループのサイズ)を格納
//parent = vector<int>(N, -1);で初期化
vector<int> parent;
//ノードXの根を返す
int root(int X){
	if(parent[X] < 0)return X;
	return parent[X] = root(parent[X]);
}
//ノードXが属するグループのサイズ(属するノード数)を返す
int size(int X){
	return -parent[root(X)];
}
//Xの属するグループとYの属するグループを繋ぐ
//それぞれの根どうしを繋ぐ
bool connect(int X, int Y){
	//根同士をつなぐため指すノードを根にする
	X = root(X);
	Y = root(Y);
	//すでに繋がっているときは繋がずにfalseを返す
	if(X == Y){
		return false;
	}
	//大きいほうに小さいほうを繋ぎたいので逆ならスワップ
	if(size(X) < size(Y))swap(X, Y);
	//繋がれる方のサイズを更新
	parent[X] += parent[Y];
	//繋ぐ方の親を設定
	parent[Y] = X;
	return true;
}

int main(){

	int N;
	cin >> N;
	vector<int> A(N);
	for(int i = 0; i < N; i ++){
		cin >> A[i];
	}
	sort(all(A));
	bool flag = false;
	int a = -1, b = -1;
	for(int i = A.size() - 2; i >= 0; i --){
		if(!flag && A[i] == A[i + 1]){
			flag = true;
			a = A[i];
			//cout << "a " << i << endl;
			i --;
			continue;
		}
		if(flag && A[i] == A[i + 1]){
			b = A[i];
			//cout << "b " << i << endl;
			break;
		}
	}
	if(b == -1)cout << "0" << endl;
	else cout << (ll)a * b << endl;

	return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long count = 0;
        for (int i = 0; i < n; i++) {
           int temp  = sc.nextInt();
           while(temp % 2 == 0) {
               count++;
               temp /= 2;
           }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 33548
#include <bits/stdc++.h>
#include <stdlib.h>
#include <math.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e15;

int main(){
    string S; cin>>S;
    int N=S.size();
    
    ll ans=0;
    char memory='<';
    ll count=0;
    vector<ll> d;
    for(int i=0;i<N;i++){
        if(memory==S.at(i)) count++;
        else {
            d.push_back(count);
            count=1;
            memory=S.at(i);
        }
    }
    d.push_back(count);

    int K=d.size()/2;
    int P=d.size();
    //cout<<K<<endl;
    
    //for(int i=0;i<P;i++) cout<<d.at(i)<<' ';

    if(K>0){
        for(int i=0;i<K;i++){
            ll A=d.at(2*i), B=d.at(1+(2*i));
            if(A>B) swap(A,B);
            ans+=(B*(B+1)/2);
            ans+=(A*(A-1)/2);
        }
    }

    if(P%2==1) ans+=(d.at(P-1)*(d.at(P-1)+1)/2);
    cout<<ans<<endl;
    


}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
 
    int V[N], C[N], ans=0, i;
 
    for (i=0; i<N; i++){
        cin >> V[i];
    }
    for (i=0; i<N; i++){
        cin >> C[i];
    }
 
    for (i=0; i<N; i++){
        if (V[i] >= C[i]){
            ans+=(V[i] - C[i]);
        }
    }
 
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll mod = 1e9 + 7;



string S;

ll A, B;;

int main() {

	cin >> A >> B;

	if ((A + B) % 2 == 1)cout << "IMPOSSIBLE" << endl;
	else {
		cout << (A + B) / 2 << endl;
	}
	
	


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long gcd(long long x, long long y){
    long long tmp;
    while( (tmp = x%y) != 0){
        x = y;
        y = tmp;
    }
    return y;
}
long long lcm(long long x, long long y){
    return x*y/gcd(x,y);
}
int main(){
    long long int a,b;
    long long c,d, tmp;
    long long int tf, ft, tt, ff;
    cin >> a >> b >> c >> d;
    tmp = lcm(c,d);
    tf = b/c - (a-1)/c;
    ft = b/d - (a-1)/d;
    tt = b/(tmp) - (a-1)/(tmp);
    ff = b - (a-1) - tf - ft + tt;
    cout << ff << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,p1,p2,dep[100005],sz[100005],fa[100005];
vector<int> arr[100005];
void dfs(int cur,int pre,int d) {
    dep[cur]=d; sz[cur]=1; fa[cur]=pre;
    for (int i=0; i<arr[cur].size(); i++) {
        if (arr[cur][i]==pre) continue;
        dfs(arr[cur][i],cur,d+1);
        sz[cur]+=sz[arr[cur][i]];
    }
}
int main() {
    cin>>n;
    for (int i=0; i<n-1; i++) {
        cin>>p1>>p2; p1--; p2--;
        arr[p1].push_back(p2);
        arr[p2].push_back(p1);
    }
    dfs(0,-1,0);
    int up=(dep[n-1]-dep[0]-1)/2,cur=n-1;
    while (up!=0) {
        up--; cur=fa[cur];
    }
    if (n-sz[cur]>sz[cur]) cout<<"Fennec\n";
    else cout<<"Snuke\n";
}

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

int main()
{
	const int N = 3000;
	int x = 0, y = 0;
	for(int i = 0; i < N ; i++)
	{
	    cin >> x >> y;
		if(x == 0 && y == 0){ break; }
		if ( x > y )
		{ 
			int tmp = x;
			x = y;
			y = tmp;
		}
		cout << x << " " << y << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
 
int main() {
  int N;
  cin >> N;
  string S, T;
  cin >> S >> T;
  //cout << S.size() << endl;
  rep(i, N){
    cout << S.at(i) << T.at(i);
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define MAX 250

typedef struct node{
  int l;
  int r;
  int p;
  int key;
}Node;

Node A[MAX];

int main(){
  int H;
  int i;

  scanf("%d",&H);
  
  for(i=1;i<=H;i++){
    scanf("%d",&A[i].key);
  }

  for(i=1;i<=H;i++){
    A[i].l=2000000001;
    A[i].r=2000000001;
    A[i].p=2000000001;
  }

  for(i=1;i<=H;i++){
    if((i/2)>0 && A[i].p==2000000001)A[i].p=A[i/2].key;

    if((2*i)<=H && A[i].l==2000000001)A[i].l=A[i*2].key;

    if((2*i+1)<=H && A[i].r==2000000001)A[i].r=A[i*2+1].key;
  }


  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i].key);

    if(A[i].p!=2000000001)printf("parent key = %d, ",A[i].p);

    if(A[i].l!=2000000001)printf("left key = %d, ",A[i].l);

    if(A[i].r!=2000000001)printf("right key = %d, ",A[i].r);
    
    printf("\n");
    


  }
  return 0;
}



Measured memory_bytes: 2056
from heapq import heappop, heappush

import numpy as np

from numba import njit


@njit('UniTuple(i8[:],4)(i1[:],i8,i8,i8)')
def reachable(field, h2, w2, k):
    # 各マスから上下左右にどこまで行けるか
    hw = h2 * w2
    up = np.full(hw, -1, dtype=np.int64)
    dw = np.full(hw, -1, dtype=np.int64)
    lf = np.full(hw, -1, dtype=np.int64)
    rg = np.full(hw, -1, dtype=np.int64)
    lf_tmp = -1
    for i in range(w2, hw - w2):
        if field[i]:
            if lf_tmp == -1:
                lf_tmp = i
            lf[i] = max(lf_tmp, i - k)
        else:
            lf_tmp = -1
    rg_tmp = -1
    for i in range(hw - w2, w2 - 1, -1):
        if field[i]:
            if rg_tmp == -1:
                rg_tmp = i
            rg[i] = min(rg_tmp, i + k)
        else:
            rg_tmp = -1
    wk = w2 * k
    for j in range(1, w2):
        up_tmp = -1
        for i in range(j, hw, w2):
            if field[i]:
                if up_tmp == -1:
                    up_tmp = i
                up[i] = max(up_tmp, i - wk)
            else:
                up_tmp = -1
        dw_tmp = 0
        for i in range(hw - w2 + j, w2 - 1, -w2):
            if field[i]:
                if dw_tmp == -1:
                    dw_tmp = i
                dw[i] = min(dw_tmp, i + wk)
            else:
                dw_tmp = -1
    return up, dw, lf, rg


@njit('i8(i8,i8,i8,i1[:],i8,i8,i8,i8)')
def solve(h2, w2, k, field, x1, y1, x2, y2):
    s = x1 * w2 + y1
    t = x2 * w2 + y2
    up, dw, lf, rg = reachable(field, h2, w2, k)

    INF = 10 ** 18
    ans = [[INF, INF] for _ in field]
    ans[s][0] = ans[s][1] = 0

    q = [(0, s)]
    while q:
        cost, v = heappop(q)
        if v == t:
            return cost
        nc = cost + 1

        for u in range(up[v], v, w2):
            if ans[u][0] <= nc:
                break
            ans[u][0] = nc
            heappush(q, (nc, u))

        for u in range(dw[v], v, -w2):
            if ans[u][0] <= nc:
                break
            ans[u][0] = nc
            heappush(q, (nc, u))

        for u in range(lf[v], v, 1):
            if ans[u][1] <= nc:
                break
            ans[u][1] = nc
            heappush(q, (nc, u))

        for u in range(rg[v], v, -1):
            if ans[u][1] <= nc:
                break
            ans[u][1] = nc
            heappush(q, (nc, u))

    return -1


h, w, k = map(int, input().split())
x1, y1, x2, y2 = map(int, input().split())
h2 = h + 2
w2 = w + 2

field_tmp = [input() for _ in range(h)]
field = [0] * w2
for row in field_tmp:
    field.append(0)
    field.extend(map('@.'.index, row))
    field.append(0)
field.extend([0] * w2)
field = np.array(field, dtype=np.int8)
print(solve(h2, w2, k, field, x1, y1, x2, y2))


Measured memory_bytes: 550596
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define fin(ans) cout << (ans) << endl
const int INF = 1<<30;
const ll MOD = 1000000007;

int main() {
  string s,t,u;
  int a, b;
  cin >> a >> b;
  //cin >> s >> t >> u;
  
  if(b>=a) cout <<  "unsafe" << endl; 
  else cout << "safe" << endl; 
  
}

Measured memory_bytes: 3620
while True:
    a, b = map(int, input().split())
    if a >= -1000 and a <= 1000:
        if b >= -1000 and b <= 1000:
            break

if a < b:
    print('a < b')
elif a > b:
    print('a > b')
else :
    print('a == b')


Measured memory_bytes: 5596
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main(){
    int n, x;
    cin >> n >> x;
    int l[n];
    int d = 0;
    int a[n+1];
    for (size_t i = 0; i < n; i++)
    {
        cin >> l[i];
    }
    int counter = 0;
    for (size_t i = 0; i < n+1; i++)
    {
        if(i!=0){
            d = d+l[i-1];
        }
        a[i] = d;
    }
    
    for (size_t i = 0; i < n+1; i++)
    {
        if(a[i]<=x) counter ++;
    }
    

    cout << counter << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());

        System.out.println(IntStream.of(1, 2, 3).filter(x -> x != A && x != B).toArray()[0]);
    }

}

Measured memory_bytes: 27092
#include <cstdio>
#include <algorithm>
#include <stack>
using namespace std;

int main(){

    int c;
    stack<int> s;
    while(scanf("%d", &c) != EOF) {
        if (c == 0 && !s.empty()) { printf("%d\n", s.top()); s.pop(); }
        else if (c > 0) s.push(c);
    }
    return 0;
}






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

int main() {
    int n;
    scanf("%d", &n);// don't forget &
    set<int> st;
    for (int i = 1; i <= n; i++) {
        int x;
        scanf("%d", &x);// don't forget &
        st.insert(x);
    }
    if (n == (int)st.size()) {
        puts("YES");
    } else {
        puts("NO");
    }
    
    return 0;
}


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

typedef long long ll;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int maxm = 0;
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		if (s[i] == 'I') {
			cnt++;
		}else {
			cnt--;
		}
		maxm = max(maxm,cnt);
	}
	cout << maxm;
}



















Measured memory_bytes: 256