akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int N=in.nextInt();
			int M=in.nextInt();
			if((N|M)==0)
				return;
			int a[]=new int[101];
			for(int i=0;i<N;i++)
			{
				int m=in.nextInt();
				for(int j=0;j<m;j++)
					a[in.nextInt()]++;
			}
			int t=0;
			for(int i=1;i<=100;i++)
				if(a[t]<a[i])
					t=i;
			if(a[t]>=M)
				System.out.println(t);
			else
				System.out.println(0);
		}
	}
}

Measured memory_bytes: 13000
#include<bits/stdc++.h>
using namespace std;
long long cnt[10000005],x,ans;
int main()
{
          cin>>x;
          for(int i=1;i<=x;++i)
            for(int j=i;j<=x;j+=i)cnt[j]++;
          for(int i=1;i<=x;++i)ans+=i*cnt[i];
          cout<<ans;
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a) {if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(int a) {if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
void AorB(int a,string b,string c) {if(a){cout<<b<<endl;}else{cout<<c<<endl;}}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}


signed main(){start();
    int k,t;
    cin>>k>>t;
    Vi a(t);
    REP(i,0,t) cin>>a[i];
    int ma=*max_element(ALL(a));
    if(ma<=RUP(k,2)){cout<<0<<endl;return 0;}
    else cout<<2*ma-k-1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
bool asingle,bsingle,csingle;
if(a<c*2){asingle=false;}else{asingle=true;}
if(b<c*2){bsingle=false;}else{bsingle=true;}
if(a+b<c*2){csingle=false;}else{csingle=true;}
int x,y;
cin>>x>>y;
int au=0;
int bu=0;
int cu=0;
if(asingle==true){cu+=x*2;y-=x;x=0;}
if(bsingle==true and y>
0){cu+=y*2;x-=y;y=0;}
if(csingle==true and x>0 and y>0){
int k=min(x,y);
cu+=k*2;x-=k;y-=k;
}
if(x>0){au+=x;}
if(y>0){bu+=y;}
cout<<au*a+bu*b+cu*c<<endl;
}

Measured memory_bytes: 256
x,k,d=map(int,input().split())
if x>=0:
    if int(x/d)>=k:
        print(x-d*k)
    else:
        f = k-int(x/d)
        if f%2==0:
            print(x%d)
        else:
            print(d-x%d)
else:
    x=-x
    if int(x/d)>=k:
        print(x-d*k)
    else:
        f = k-int(x/d)
        if f%2==0:
            print(x%d)
        else:
            print(d-x%d)



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

a=[[int(i) for i in input().split()] for j in range(2)]

sentou=[]
usiro=[]

for i in range(n):
    if i==0:
        sentou.append(a[0][0])
        usiro.append(a[1][-1])
    else:
        sentou.append(a[0][i]+sentou[-1])
        usiro.append(a[1][-i-1]+usiro[-1])

usiro=usiro[::-1]
ans=[]
for i in range(n):
    ans.append(sentou[i]+usiro[i])
print(max(ans))

Measured memory_bytes: 9224
#include <stdio.h>
#include <math.h>
int main(void){
    // Your code here!
    double x1,y1,x2,y2;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    printf("%f\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
    return 0;
}



Measured memory_bytes: 2100
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int even_odd(int num){
	if(num % 2 == 0) return 0;
	else return 1 ;
}

int main (void){
	int n = 0;
	int num[100000];

	int i = 0;
	int cnt = 0;

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

	if(even_odd(cnt) == 0) printf("YES\n");
	else printf("NO\n");

	return 0;

}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int n;
int a[maxn];
int b[maxn];
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

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

  int l=0; int r=n-1;
  bool flag=true;
  for (int i=n-1; i>=0; i--) {
    b[l] = a[i];
    if (flag) {
      l++;
    } else {
      l--;
    }
    flag = !flag;
    swap(l, r);
  }
  

  for (int i=0; i<n; i++) {
    cout<<b[i]<<" ";
  }
  cout<<endl;
  return 0;
}


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

/*
a=97
z=122
*/

int main(void){
	int i,l,s,f=0,t;
	char in[90],ans[90],c[10],ca[4]={"the\0"},cb[5]={"this\0"},cc[5]={"that\0"};
	
	while(1){
		for(i=0;i<90;i++){
			in[i]=NULL;
			ans[i]=NULL;
		}
		for(i=0;;i++){
			if(scanf("%c",&in[i])==EOF)return 0;
			if(in[i]=='\n')break;
		}
		
		for(s=1;;s++){//sはずらす数
			//in[i]を、アルファベットならずらして、それ以外ならそのままコピー
			for(i=0;i<(int)strlen(in);i++){
				if((int)in[i]>=97 && (int)in[i]<=122){
					t=(int)in[i]+s;
					if(t>122)t-=26;
					ans[i]=(char)t;
				}
				else ans[i]=in[i];
			}
			
			for(i=0,f=0;i<(int)strlen(ans);i++){
				for(l=0;l<3;l++){
					if(ans[i+l]!=ca[l])break;
					if(l==2)f=1;
				}
				for(l=0;l<4;l++){
					if(ans[i+l]!=cb[l])break;
					if(l==3)f=1;
				}
				for(l=0;l<4;l++){
					if(ans[i+l]!=cc[l])break;
					if(l==3)f=1;
				}
				if(f==1)break;
			}
			if(f==1){
				for(i=0;i<(int)strlen(ans);i++)printf("%c",ans[i]);
				break;
			}
		}
	}
}
				
				
			
				
				
			
			
		
		
			
			

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    unsigned long long a,b,n;
    cin >> a >> b >> n;

 	unsigned long long ans = (a*n)/b - a*(n/b);
 	if(b-1 <n){
        ans  = (a*(b-1))/b - a*((b-1)/b);
 	}
 	cout << ans ;

    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
const int N=200005;
#define inf 1e18+8
const int mod=1e9+7;
#define pii pair<int, int>
#define vi vector<int>
#define vf vector<float>
#define sz(x) x.size()
#define float double
#define set multiset
//#define all((int)x) begin(x), end(x)
#define vpii vector<pair<int,int> > 
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
float dp[3001][3001];
int n;
float arr[N];
float rec(int heads,int tails)
{
    if(heads==0 && tails==0) return 1;
    if(heads<0 || tails<0 ) return 0;
    if(dp[heads][tails]!=-1) return dp[heads][tails];
   // if((heads+tails)<1 || (heads+tails)>n) return 0;
   //  cout<<(p[heads+tails]*rec(heads-1,tails)+(1-p[heads+tails])*rec(heads,tails-1));
    return dp[heads][tails]=(arr[heads+tails]*rec(heads-1,tails)+(1-arr[heads+tails])*rec(heads,tails-1));

}
signed main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
      //std::cout << std::setprecision(10);
    for(int i=0;i<3001;i++)
    {
        for(int j=0;j<3001;j++)
        {
            dp[i][j]=-1;
        }
    }
    cin>>n;
 //   p.resize(n+1);
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
        //cout<<p[i];
    }
   // rec(n,0);
  /*  for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            cout<<dp[i][j];
        }
        cout<<"\n";
    }
        */
    float ans=0.0;
    int h=n;
    int t=0;
    while(true)
    {
       // cout<<rec(h,t);
        if(t>=h) break;
        ans+=rec(h,t);
        t++; h--;


    }
    std::cout << std::setprecision(12) << ans << '\n';
    //cout<<ans<<"\n";
    
        

        

    

    

}
 
    

Measured memory_bytes: 70784
import java.util.Scanner;

class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
  int R=sc.nextInt();
  int C=sc.nextInt();
  int N=sc.nextInt();
  int sum=0,count=0;
  if(R>C){
  while(sum<N){
  sum+=R;
    count++;
  }
  }
  else{
  while(sum<N){
  sum+=C;
    count++;
  }
  }
  System.out.print(count);
}
}

Measured memory_bytes: 21972
#include "bits/stdc++.h"
using namespace std;
#define MAX 10000
#define NIL -1

struct Node{int p,l,r;};
Node T[MAX];
int n;

void preParse(int u){
	if(u==NIL)return;
	cout<<" "<<u;
	preParse(T[u].l);
	preParse(T[u].r);
}
void inParse(int u){
	if(u==NIL)return;
	inParse(T[u].l);
	cout<<" "<<u;
	inParse(T[u].r);
}
void postParse(int u){
	if(u==NIL)return;
	postParse(T[u].l);
	postParse(T[u].r);
	cout<<" "<<u;
}

int main(){
	int v,l,r,root;
	scanf("%d",&n);
	for (int i = 0; i < n; ++i) {T[i].p=NIL;}
	for (int i = 0; i < n; ++i) {
		scanf("%d %d %d",&v,&l,&r);
		T[v].l=l;
		T[v].r=r;
		if(l!=NIL)T[l].p=v;
		if(r!=NIL)T[r].p=v;
	}
	for (int i = 0; i < n; ++i) {if(T[i].p==NIL)root=i;}
	printf("Preorder\n");
	preParse(root);
	printf("\n");
	printf("Inorder\n");
	inParse(root);
	printf("\n");
	printf("Postorder\n");
	postParse(root);
	printf("\n");
	return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define ll long long
#define M 1000000007 
#define MM 998244353
#define PI 3.14159265 
using namespace std;

int main()
{
	long long int n, t1 = 1, t2 = 1, t3 = 1, t;

	cin >> n;

	for (long long int i = 0; i < n; i++)
	{
		t1 = (t1*10)%M;
		t2 = (t2*9)%M;
		t3 = (t3*8)%M;
	}

	t2 = (2*t2)%M;

	t = (t1 - t2);

	if (t < 0)
	{
		t = t + M;
	}

	t = (t + t3)%M;

	cout << t;

  	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

struct tri{
  ll f,s,t;
};

bool comp(const tri& l, const tri& r){
  return l.t < r.t;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;ll K;cin >> N >> K;
  vector<tri> v(N);
  ll b;
  b = K+2*N-1;
  int index = 0;
  repp(x,K,K+N){
    if((x&1)==0)continue;
    v[index].f = x;
    v[index].s = b;
    v[index].t = x+b;
    ++index;
    --b;
  }
  repp(x,K,K+N){
    if(x&1)continue;
    v[index].f = x;
    v[index].s = b;
    v[index].t = x+b;
    ++index;
    --b;
  }

  sort(all(v),comp);
  ll c = K+2*N;
  rep(i,N){
    if(v[i].t>c){
      cout << -1 << endl;
      return 0;
    }
    v[i].t = c;
    ++c;
  }
  rep(i,N) cout << v[i].f SP v[i].s SP v[i].t << endl;
  return 0;
}


Measured memory_bytes: 4608
#include<bits/stdc++.h>
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
using namespace std;
typedef long long LL;
vector<int> v[105];
vector<int> dfs(int a,int f){
    vector<int> ret;
    for(auto it:v[a]){
        if(it!=f){
            vector<int> vv=dfs(it,a);
            for(int i=0;i<vv.size();i++){
                if(ret.size()==i)
                ret.pb(0);
                ret[i]=max(ret[i],vv[i]);
            }
        }
    }
    reverse(ret.begin(),ret.end());
    ret.pb(v[a].size()-1);
    reverse(ret.begin(),ret.end());
    return ret;
}
int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n-1;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        v[a].pb(b);
        v[b].pb(a);
    }
    pll ans=mp(1e9,0);
    for(int i=1;i<=n;i++){
        vector<int> vv;
        vv=dfs(i,0);
        LL ret=1;
        vv[0]++;
        for(int j=0;j<vv.size()-1;j++){
            ret*=vv[j];
            if(ret%vv[j]!=0){
                ret=-1;
                break;
            }
        }
        if(ret>0)
        ans=min(ans,mp((LL)vv.size(),ret));
    }
    for(int i=1;i<=n;i++){
        for(auto it:v[i]){
            vector<int> v1=dfs(i,it);
            vector<int> v2=dfs(it,i);
            for(int j=0;j<v2.size();j++){
                if(v1.size()==j)
                v1.pb(0);
                v1[j]=max(v1[j],v2[j]);
            }
            LL ret=1;
            for(int j=0;j<v1.size()-1;j++){
                ret*=v1[j];
                if(ret%v1[j]!=0){
                    ret=-1;
                    break;
                }
            }
            if(ret>0)
                ans=min(ans,mp((LL)v1.size(),ret*2));
        }
    }
    printf("%lld %lld\n",ans.x,ans.y);
}




Measured memory_bytes: 256
import java.util.*;

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

        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();
        int n = sc.nextInt();
        int ans = 0;

        i:
        for(int i = 0; i <= n / r; i++){
            for(int j = 0; j <= n / g; j++){
                int sum = r * i + g * j;
                if(sum > n){
                    continue i;
                }
                if((n - sum) % b == 0){
                    ans++;
                }
            }
        }

        System.out.println(ans);

    }
}


Measured memory_bytes: 23764
import Control.Arrow
import Data.List
import qualified Data.ByteString.Char8 as B
import Debug.Trace

main :: IO ()
main = breads >>= main'
    where
        main' [n, m] = breads >>= print . solve n m

solve :: Int -> Int -> [Int] -> Int 
solve n m = sum . map count . group . sort . scanl (\l r -> val $ l + r) 0 . map val
    where
        count xs = (n * (n - 1)) `div` 2
            where
                n = length xs
        val = (`mod` m)

breads :: IO [Int]
breads = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

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

int main() {
	double a, b;
	cin >> a >> b;
	printf("%.15lf\n", a * b / (a + b));
	return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::input;
use proconio::marker::{Bytes, Chars};
use std::collections::*;

fn main() {
    input! {
        n:usize,
        a:[i64;n],
        q:usize,
        bc:[(i64,i64);q],
    }
    let mut sum: i64 = a.iter().sum();
    let mut count = BTreeMap::new();
    for &x in a.iter() {
        *count.entry(x).or_insert(0) += 1;
    }
    for &(b, c) in bc.iter() {
        let num = *count.entry(b).or_insert(0);
        sum += num * (c - b);
        println!("{}", sum);
        *count.entry(c).or_insert(0) += num;
        *count.entry(b).or_insert(0) = 0;
    }
}

Measured memory_bytes: 8912
use std::io::Read;

fn main() {
    let mut buff = String::new();
    std::io::stdin().read_to_string(&mut buff).unwrap();
    let mut iter = buff.split_whitespace();

    let h: usize = iter.next().unwrap().parse().unwrap();
    let w: usize = iter.next().unwrap().parse().unwrap();

    let mut g = Vec::new();
    for _i in 0..h {
        let s: String = iter.next().unwrap().parse().unwrap();
        let mut h = Vec::new();
        for c in s.chars() {
            h.push(c)
        }
        g.push(h);
    }

    for i in 0..h {
        let mut cnt: usize = 0;
        for j in 0..w {
            if g[i][j] != '#' {
                cnt = cnt + 1;
            }
        }
        if cnt == w {
            for j in 0..w {
                g[i][j] = '@';
            }
        }
    }

    for j in 0..w {
        let mut cnt: usize = 0;
        for i in 0..h {
            if g[i][j] != '#' {
                cnt = cnt + 1;
            }
        }
        if cnt == h {
            for i in 0..h {
                g[i][j] = '@'
            }
        }
    }

    for i in 0..h {
        let mut cnt: i32 = 0;
        for j in 0..w {
            if g[i][j] != '@' {
                cnt = cnt + 1;
                print!("{}", g[i][j]);
            }
        }
        if cnt != 0 {
            println!("");
        }
    }

    ()
}


Measured memory_bytes: 4352
S = input()
if S[0] != "A":
  print("WA")
  exit()
elif S[2:-1].count("C") != 1 or S[:2].count("C") != 0 or S[-1:].count("C") != 0:
  print("WA")
  exit()
else:
  S = S[1:].replace("C", "")
  if S.islower():
    print("AC")
  else:
    print("WA")

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


int main(){
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  if(s.at(0)=='a'&&s.at(1)=='b'&&s.at(2)=='c'){
    cout << "Yes" << endl;
  }
  else{
    cout << "No"<<endl;
  }
  }


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  char s[100010]={0};
  int i;
  scanf("%s",s);
  for(i=0;s[i+1];i++){
    if(s[i]==s[i+1]){
      printf("%d %d\n",i+1,i+2);
      return 0;
    }
    if(s[i]==s[i+2]){
      printf("%d %d\n",i+1,i+3);
      return 0;
    }
  }
  printf("-1 -1\n");
  return 0;
}
  

Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int N,D[101];
int main() {
	cin>>N;

	int A[101]={};
	for(int i=0;i<N;i++){
		cin>>D[i];
		A[D[i]]++;
	}
	int ans=N;
	for(int i=1;i<101;i++){
		if(A[i]>1)ans=ans-A[i]+1;
	}

	cout<<ans<<endl;

	return 0;
}


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

int main() {
    int n = 0, d = 0;
    scanf("%d %d", &d, &n);
    if (d == 0) {
        if (n == 100) printf("101\n");
        else printf("%d\n", n);
    }
    else if (d == 1) {
        if (n == 100) printf("10100\n");
        else printf("%d\n", n * 100);
    }
    else {
        if (n == 100) printf("1010000\n");
        else printf("%d\n", n * 10000);
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int i,j,flag=0;
    for(i=1;i<=9;i++)
    {
        for(j=1;j<=9;j++)
        {
            if(i*j==n)
            {
                cout<<"Yes"<<endl;
                flag=1;
                break;
            }
        }
        if(flag==1) break;
    }
    if(flag==0) cout<<"No"<<endl;
}


Measured memory_bytes: 256
c = [list(map(int,input().split())) for i in range(3)]
d=[0,0,0]
ans='Yes'
for i in range(2):
  for j in range(3):
    d[j] = c[i+1][j]-c[i][j]
  if d[0]==d[1] and d[0]==d[2]:
    continue
  else:
    ans='No'
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,k;
  ll x=0;
  cin >> n >> k;
  vec a(n);
  for(ll i=0;i<n;i++) cin >> a[i];
  ll ans=0;
  for(ll i=44;i>-1;i--) {
    ll cnt=0;
    for(ll j=0;j<n;j++) {
      if(a[j]&(1LL<<i)) cnt++;
    }
    if (cnt<n-cnt) {
      if(ans+(1LL<<i)<=k) ans+=(1LL<<i);
    }
  }
  ll sum=0;
  for(ll i=0;i<n;i++) sum+=ans^a[i];
  cout << sum << endl;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int h, w;
	cin >> h >> w;
	int a[h+1][w+1];
	for(int i=1; i<=h; i++){
		for(int j=1; j<=w; j++){
			cin >> a[i][j];
		}
	}

	int cnt=0;
	vector<tuple<int, int, int, int>> v;
	for(int i=1; i<=h; i++){
		for(int j=2; j<=w; j++){
			if(a[i][j-1]%2==1){
				a[i][j-1]--;
				a[i][j]++;
				v.push_back(make_tuple(i, j-1, i, j));
				cnt++;
			}
		}
	}
	for(int i=2; i<=h; i++){
		if(a[i-1][w]%2==1){
			a[i-1][w]--;
			a[i][w]++;
			v.push_back(make_tuple(i-1, w, i, w));
			cnt++;
		}
	}

	cout << cnt << endl;
	for(int i=0; i<v.size(); i++){
		cout << get<0>(v[i]) << " " << get<1>(v[i]) << " " << get<2>(v[i]) << " " << get<3>(v[i]) << endl;
	}
	return 0;
}

Measured memory_bytes: 5232
PROGRAM C
  IMPLICIT NONE
  INTEGER(8) :: n,i,tmp=0,sum=0
  INTEGER(8),allocatable :: a(:)
  READ *, n
  allocate(a(n))
  READ *, a

  Do i=1,n-1
    tmp=a(i)-a(i+1)
    IF(tmp<0)tmp=0
    sum=sum+tmp
    a(i+1)=a(i+1)+tmp
  End do

  PRINT *, sum
END PROGRAM C


Measured memory_bytes: 4652
#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>;

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  int x=0, y=0, z=0;
  char nxt='a';
  while(nxt!='z') {
    if(nxt=='a') {
      if(x==a.size()) break;
      nxt=a[x];
      x++;
    }
    else if(nxt=='b') {
      if(y==b.size()) break;
      nxt=b[y];
      y++;
    }
    else if(nxt=='c') {
      if(z==c.size()) break;
      nxt=c[z];
      z++;
    }    
  }
  cout << (char)(nxt-'a'+'A') << endl;
  return 0;
}

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

#define ll long long
#define F(i,a,b) for(int i=a;i<=b;++i)
#define R(i,a,b) for(int i=a;i<b;++i)
#define mem(a,b) memset(a,b,sizeof(a))

int n;
int l,r;
int ans;

int main()
{
    cin>>n;
    F(i,1,n) { cin>>l>>r;ans+=r-l+1; }
    cout<<ans;
    return 0;
}

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

using namespace std;

typedef long long lint;
const lint mod = 1e9+7, N = 2e6+100;
lint x, y, fat[N];

lint fpow(lint b, lint e){
	if (b == 0)
		return 0;
	if (e == 0)
		return 1;
	if (e % 2 == 0){
		lint p = (fpow(b, e/2))%mod;
		return (p * p)%mod;
	} else {
		return ((b%mod) * fpow(b, e-1))%mod;
	}
}

int main(){
#ifdef LOCAL
	freopen("input", "r", stdin);
#endif

	scanf("%lld %lld", &x, &y);

	if ((x + y)%3 != 0){
		printf("0\n");
		return 0;
	}

	lint a = (2*y - x) / 3;
	lint b = (2*x - y) / 3;

	//cout << a << "  " << b << endl;

	if (a < 0 || b < 0){
		printf("0\n");
		return 0;
	}

	fat[0] = fat[1] = 1;

	for (lint i = 2; i < N; i++){
		fat[i] = (i * fat[i - 1])%mod;
	}

	lint ans = fat[(a+b)] * fpow(fat[b], mod-2) % mod * fpow(fat[a], mod-2) % mod;

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

	return 0;
}

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

void printv(vector<ll> v) {
  for (ll i : v)
    cout << i << endl;
}

int main() {
  while (true) {
    ll n, m;
    cin >> n >> m;
    if (!n && !m)
      break;
    ll danger = 0;
    vector<pair<ll, ll>> pairs;
    rep(i, n) {
      ll d, p;
      cin >> d >> p;
      danger += d * p;
      pairs.push_back(make_pair(p, d));
    }
    sort(pairs.begin(), pairs.end());
    ll re_m = m;
    ll cnt = 1;
    while (true) {
			if(cnt==n+1)break;
      if (pairs[n - cnt].second < re_m) {
        re_m -= pairs[n - cnt].second;
        danger -= pairs[n - cnt].second * pairs[n - cnt].first;
        cnt++;
      } else {
        danger -= re_m * pairs[n - cnt].first;
        break;
      }
    }
    cout << danger << endl;
  }
}



Measured memory_bytes: 3280
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		final int n = sc.nextInt();
		
		int taro = 0, hanako = 0;
		for(int i = 0; i < n; i++){
			final String fst = sc.next();
			final String snd = sc.next();
			
			if(fst.compareTo(snd) < 0){
				hanako += 3;
			}else if(fst.compareTo(snd) > 0){
				taro += 3;
			}else{
				taro++;
				hanako++;
			}
		}
		
		System.out.println(taro + " " + hanako);
		
	}
}

Measured memory_bytes: 20804
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long idx=0;
    long N;
    cin >> N;
    vector<long> A(N);
    ll init_rain = 0;
    for(size_t i=0;i<N; i++)
    {
        //ダムの水の量は i の山の雨の量 / 2 + (i + 1) の山の雨の量 / 2
        cin >> A[i];
        if(i % 2 == 0) init_rain += A[i];
        else init_rain -= A[i];
    }
    cerr << init_rain << endl;
    long prev_rain, current_rain;
    for(size_t i=0;i<N; i++)
    {
        if(i == 0)
        {
            cout << init_rain << " ";
            prev_rain = init_rain;
        }else
        {
            current_rain = 2 * A[i-1] - prev_rain;
            cout << current_rain << " ";
            prev_rain = current_rain;
        }
    }
    cout << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 2176
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String s = br.readLine();
		String str[] = s.split("");

		int now = str.length;
		for (int i = str.length; i >= 1;) {
			if (i - 7 >= 0) {
				String ss = s.substring(i - 7, i);
				if (ss.equals("dreamer")) {
					i -= 7;
					now = i;
					continue;
				}
			}
			if (i - 6 >= 0) {
				String ss = s.substring(i - 6, i);
				if (ss.equals("eraser")) {
					i -= 6;
					now = i;
					continue;
				}
			}
			if (i - 5 >= 0) {
				String ss = s.substring(i - 5, i);
				if (ss.equals("dream") || ss.equals("erase")) {
					i -= 5;
					now = i;
					continue;
				}
			}
			if (now == i) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}
}


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

int A, B;

void read() {
    cin >> A >> B;
}


void work() {
    for (int i = 1; i <= 3; ++i) {
        if (i != A && i != B) {
            cout << i << endl;
            break;
        }
    }
}


int main() {
    read();
    work();
    return 0;
}


Measured memory_bytes: 256
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]

ab.sort(key=lambda x: x[1])

flag = True
t = 0
for i in range(len(ab)):
    a, b = ab[i]
    t += a
    if b < t:
        flag = False
        break


print('Yes' if flag else 'No')

Measured memory_bytes: 53596
#include<iostream>
#include<vector>
#include<utility>

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
    vector<int> left;
    vector<pair<int, int> > puddles;
    char geo;
    for(int i=0; cin>>geo; i++) {
        if(geo=='\\') {
            left.push_back(i);
        } else if(geo=='/') {
            if(left.empty()) continue;
            int l=left.back();
            left.pop_back();
            int area=i-l;
            while(!puddles.empty()&&l<puddles.back().first) {
                area+=puddles.back().second;
                puddles.pop_back();
            }
            puddles.emplace_back(l, area);
        }
    }
    int sum=0;
    for(const auto& a : puddles ) {
        sum+=a.second;
    }
    cout<<sum<<'\n'<<puddles.size();
    for(const auto& a : puddles) {
        cout<<' '<<a.second;
    }
	cout<<'\n';

	return 0;
}



Measured memory_bytes: 3296
-- 入力を (金額, 単位) のリストとしてまとめる
-- 単位によって円の金額を計算して足しあげる

import Control.Applicative
import Control.Monad as M

main :: IO ()
main = do
  n <- getLine
  gifts <- M.replicateM (read n) (words <$> getLine)
  putStrLn $ show (solve gifts)

type Gift = (Double, String)

strToGift :: [String] -> Gift
strToGift [value, unit] = (read value :: Double, unit)

strToGifts :: [[String]] -> [Gift]
strToGifts = map strToGift

giftToValue :: Gift -> Double
giftToValue (value, unit) = case unit of
  "JPY" -> value
  "BTC" -> 380000.0 * value

solve :: [[String]] -> Double
solve = sum . map giftToValue . strToGifts


Measured memory_bytes: 636
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main()
{
	int cnt = 0,ret = 0;
	string s; cin >> s;
	for(int i=0;i<s.size();i++){
		if(s[i] == 'S'){
			cnt++;
		}
		else{
			if(cnt) cnt--;
			else ret++;
		}
	}
	cout << ret+cnt << endl;
}

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

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;


int main(){
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int ans = 0;

    if(K <= A){
        cout << K << endl;
    } else if (K <= A + B){
        cout << A << endl;
    } else {
        cout << A - (K - A - B) << endl;
    }
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<ll> A(N), sum(N+1), posSum(N+1);
  rep(i, N) {
    cin >> A[i];
    sum[i+1] = sum[i] + A[i];
    posSum[i+1] = posSum[i] + (A[i]>=0 ? A[i] : 0);
  }
  ll mx = -longinf;
  rep(i, N-K+1) {
    mx = max(posSum[i] + (sum[i+K]-sum[i]) + (posSum[N]-posSum[i+K]), mx);
    mx = max(posSum[i] + 0 + (posSum[N]-posSum[i+K]), mx);
  }
  cout << mx << endl;
  return 0;
}


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

int main()
{
    int N;
    cin >> N;
    vector<ll> A;
    ll common;
    cin>>common;
    for (int i = 1; i < N; i++)
    {
        ll ai;
        cin >> ai;
        common=__gcd(common,ai);
    }
    cout << common << 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 all(x) (x).begin(), (x).end()

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

    // start
    int a, b;
    char op;
    cin >> a >> op >> b;
    if (op == '+')
        cout << a + b << endl;
    else
        cout << a - b << endl;
    // end

    return 0;
}


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

namespace Program {
    class Program {
        static void Main(string[] args) {
            var cr = new CR();
            var N = cr.i;
            var M = cr.i;

            var count = Math.Pow(2, M);
            var ans = (M * 1900 + (N - M) * 100) * count;

            Console.WriteLine(ans);
        }

        private class CR {
            System.IO.TextReader _r;
            Queue<string> _d;
            public CR() { _r = Console.In; _d = new Queue<string>(); }
            string Read() {
                while (_d.Count == 0)
                    foreach (var v in _r.ReadLine().Split(' '))
                        if (v != "")_d.Enqueue(v);
                return _d.Dequeue();
            }
            public int i { get { return int.Parse(Read()); } }
            public string s { get { return Read(); } }
        }
    }
}

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

using namespace std ;

const int MAX = 2e5 + 10 ;

vector< vector<int> >v(26) ;
int n ;

string s ;

int dp[MAX] ;

int solve(int idx)
{
	if(idx == n)
		return 0 ;
	int &ret = dp[idx] ;
	if(ret != -1)
		return ret ;
	ret = 1e9 ;
	for(int i = 0 ; i < 26 ; ++i)
	{
		int idx2 = upper_bound(v[i].begin() , v[i].end() , idx) - v[i].begin() ;
		ret = min(ret , solve(v[i][idx2]) + 1) ;
	}
	return ret ;
}

void build(int idx)
{
	if(idx == n)
		return ;
	for(int i = 0 ; i < 26 ; ++i)
	{
		int idx2 = upper_bound(v[i].begin() , v[i].end() , idx) - v[i].begin() ;
		if(solve(idx) == solve(v[i][idx2]) + 1)
		{
			cout<<(char)(i+'a') ;
			build(v[i][idx2]) ;
			break ;
		}
	}
}

int main()
{
	memset(dp , -1 , sizeof(dp)) ;
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>s ;
	s = "#" + s ;
	n = s.size() ;
	for(int i = 1 ; i < n ; ++i)
		v[s[i]-'a'].push_back(i) ;
	for(int i = 0 ; i < 26 ; ++i)
		v[i].push_back(n) ;
	build(0) ;
	return 0 ;
}		

Measured memory_bytes: 5680
n,m=map(int,input().split())

a=["0"]*n

for i in range(m):
    s,c=map(int,input().split())
    if a[s-1]=="0":
        a[s-1]=c
    elif a[s-1]!=c:
        print(-1)
        exit()

if n>1 and a[0]==0:
    print(-1)
    exit()

if n>1 and a[0]=="0":
    a[0]=1

print(*a,sep="")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb emplace_back
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define deb(x) cout << #x << " - " << x << endl;

using namespace std;

int main()
{	IOS;
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
	string s; cin >> s;
	string x1 = "YYMM", x2 = "MMYY", x3 = "AMBIGUOUS", x4 = "NA";

	string m = "", y = "";
	m += string(1, s[0]) + string(1, s[1]);
	y += string(1, s[2]) + string(3, s[3]);

	int my = 0, ym = 0;
	if ((m[0] == 48 && m[1] <= 57 && m[1] != 48) || (m[0] == 49 && m[1] <= 50)) {
		if (y[0] == 0 && y[1] == 0) my = 0;
		else my = 1;
	}
	if ((y[0] == 48 && y[1] <= 57 && y[1] != 48) || (y[0] == 49 && y[1] <= 50)) {
		if (m[0] == 0 && m[1] == 0) ym = 0;
		else ym = 1;
	}
	if (my && ym) cout << x3;
	else if (!my && !ym) cout << x4;
	else if (my) cout << x2;
	else if (ym) cout << x1;

	return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = sc.nextInt();
		int ans = 0;
		for (int i = 1; i <= n; i++) {
			ans += i;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 25172
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  long long int b,i,n,m,a[100010],sum[100010];
  scanf("%lld %lld\n",&n,&m);
  for(i=0;i<n;i++){
    scanf("%lld ",&a[i]);
  }
  sort(a,a+n);
  sum[0]=0;
  for(i=0;i<n;i++){
    sum[i+1]=sum[i]+a[i];
  }
  long long int sum1=0,ans=0,min=-1,max=200001,mid,ans1;
  while(abs(min-max)>1){
    sum1=0,ans=0;
    mid=(min+max)/2;
    for(i=0;i<n;i++){
      b=mid-a[i];
      if(b<0){
        sum1+=n;
        ans+=sum[n]+a[i]*n;
        continue;
      }
      long long int right=-1,left=n,cen;
      while(abs(right-left)>1){
        cen=(right+left)/2;
        if(b<=a[cen]){
          left=cen;
        }
        else{
          right=cen;
        }
      }
      sum1+=n-left;
      ans+=sum[n]-sum[left];
      ans+=a[i]*(n-left);
    }
    if(sum1>=m){
      min=mid;
      ans1=ans-(sum1-m)*min;
    }
    else{
      max=mid;
    }
  }
  printf("%lld\n",ans1);
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int n,a[201],ans;
int main(){
	cin>>n;
	n*=2;
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+n);
	for(int i=n;i;i-=2){
		ans+=a[i-1];
	}
	cout<<ans;
}

Measured memory_bytes: 256
use std::collections::HashMap;
use std::io;
//use std::collections::BinaryHeap;
//use std::collections::HashSet;
//use std::mem; // mem::swap(&mut x,&mut y);
use std::cmp; // cmp::max,cmp::min

// Rust memo: https://hackmd.io/i0lQY1OKTDW1t66TECOmiw?both

#[allow(dead_code)]
fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn read_charvec() -> Vec<char> {
    read_line().chars().collect()
}

#[allow(dead_code)]
fn read_ints() -> Vec<i64> {
    let s = read_line();
    let split: Vec<&str> = s.split(" ").collect();
    split
        .iter()
        .map(|&x| x.to_string().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_int() -> i64 {
    read_ints()[0]
}

#[allow(dead_code)]
fn reverse(s: &String) -> String {
    s.chars().rev().collect::<String>()
}

#[allow(dead_code)]
fn read_lines(n: i64) -> Vec<String> {
    let mut xs = Vec::new();

    for _i in 0..n {
        xs.push(read_line());
    }

    xs
}

#[allow(dead_code)]
fn read_ints2(n: i64) -> Vec<i64> {
    read_lines(n).iter().map(|x| x.parse().unwrap()).collect()
}

#[allow(dead_code)]
fn arange(start: i64, end: i64, step: i64) -> Vec<i64> {
    let mut ret = Vec::new();
    let mut i = start;

    while i < end {
        ret.push(i);
        i += step;
    }

    ret
}

#[allow(dead_code)]
const DXS: [i64; 4] = [0, 0, 1, -1];
#[allow(dead_code)]
const DYS: [i64; 4] = [1, -1, 0, 0];
#[allow(dead_code)]
const INF: i64 = 99999999999;
#[allow(dead_code)]
const N_PRIME: i64 = 1000000007;

////////////////////////////////////////////////

fn combination2(n: i64) -> i64 {
    if n == 0 {
        return 0;
    } else {
        return n * (n - 1) / 2;
    }
}

fn main() {
    let mut h = HashMap::new();
    let _ = read_int();
    let xs = read_ints();

    for x in xs.clone() {
        let v = match h.get(&x) {
            Some(v) => v + 1,
            None => 1,
        };
        h.insert(x, v);
    }

    let mut ans = 0;
    for (num, count) in &h {
        let val = combination2(*count);
        ans += val;
    }

    for x in xs.clone() {
        let n_original = h.get(&x).unwrap();
        let n_ori_combi = combination2(*n_original);
        let n_new_combi = combination2(*n_original - 1);
        println!("{}", ans - n_ori_combi + n_new_combi);
    }
}


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

bool isExponential(int n){
    if(n==1) return true;
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0){
            int cnt=0,nn=n;
            while(nn%i==0){
                nn/=i;
                cnt++;
            }
            if(nn==1 && cnt>=2) return true;

        }
    }
    return false;
}

int main(){
    int x; cin >> x;
    for(int i=x;i>=1;i--){
        if(isExponential(i)){
            cout << i << endl;
            break;
        } 
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

ll lcm(vector<ll> a, int p, ll ans = 1LL){
    if(p>=a.size())return ans;
    ans = a[p]/__gcd(ans, a[p])*ans;
    ans = lcm(a, p+1, ans);
    return ans;
}

int main(){
	int N;
	cin>>N;
	vector<ll> t(N);
	rep(i,N)cin>>t[i];
	cout<<lcm(t,0)<<endl;
	return 0;
}

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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
//  long long int n,k,ans=1;
 long long int n;
  cin>>n;
  long long int a[n];
  for(int i=0;i<n;i++)
  {
     cin>>a[i];
  }
  sort(a,a+n,greater<int>());
  if(n<3)
  {
      cout<<a[0];
  }
  else{
  long long int ans=0,i=1,j=n-2;
  while(1)
  {
      ans+=a[i];
      j--;
      if(j==0)
        break;
      ans+=a[i];
      j--;
      if(j==0)
        break;
      i++;
  }
  ans+=a[0];
  cout<<ans;}
  }

Measured memory_bytes: 5136
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long MOD = 1000000007;

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

	string s;
	cin >> s;
	if (s[0] != s[1] || s[1] != s[2]) {
		cout << "Yes" << "\n";
	}
	else {
		cout << "No" << "\n";
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int kMaxN = 200001;
const int kM = 998244353;

struct V {
  long long d, v;
} v[kMaxN * 4];

long long f[10][kMaxN];
int n, q, l, r, d;

void C(int i, int ml, int mr, int d) {
  v[i].d = d;
  v[i].v = f[d][mr - ml + 1];
}

void U(int i, int ml, int mr, int nl, int nr, int d) {
  if (ml == nl && mr == nr) {
    C(i, ml, mr, d);
    return;
  }
  int m = (ml + mr) >> 1;
  if (v[i].d) {
    C(i * 2, ml, m, v[i].d);
    C(i * 2 + 1, m + 1, mr, v[i].d);
    v[i].d = 0;
  }
  if (nl <= m) {
    U(i * 2, ml, m, nl, min(nr, m), d);
  }
  if (nr > m) {
    U(i * 2 + 1, m + 1, mr, max(nl, m + 1), nr, d);
  }
  v[i].v = (v[i * 2].v * f[0][mr - m] + v[i * 2 + 1].v) % kM;
}

int main() {
  cin >> n >> q;
  f[0][0] = 1;
  for (int i = 0; i <= 9; i++) {
    for (int j = 1; j <= n; j++) {
      f[i][j] = (f[i][j - 1] * 10 + i) % kM;
    }
  }
  U(1, 1, n, 1, n, 1);
  for (int i = 1; i <= q; i++) {
    cin >> l >> r >> d;
    U(1, 1, n, l, r, d);
    cout << v[1].v << endl;
  }
  return 0;
}

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

namespace AtCoder_BeginerContest
{
    class Program
    {

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string str = Console.ReadLine();
            var progression = str.Split(' ').Select(int.Parse);
            var twoProgressions = progression.Select((p, i) => new { Content = p, Index = i });
            var evenProgression = twoProgressions.Where(p => p.Index % 2 == 0).Select(p => p.Content);
            var oddProgression = twoProgressions.Where(p => p.Index % 2 == 1).Select(p => p.Content);

            int modNumEvenProg = evenProgression.Mode();
            int modNumOddProg = oddProgression.Mode();

            if (modNumOddProg == modNumEvenProg)
            {
                int count1, count2;
                int secoundmodNumOddProg = oddProgression.SecoundMode();
                int secoundmodNumEvenProg = evenProgression.SecoundMode();
                if (secoundmodNumEvenProg == modNumEvenProg && secoundmodNumOddProg == modNumOddProg)
                {
                    Console.WriteLine(n / 2);
                    return;
                }
                count1 = oddProgression.Count(op => op != modNumOddProg);
                count1 += evenProgression.Count(ep => ep != secoundmodNumEvenProg);
                count2 = oddProgression.Count(op => op != secoundmodNumOddProg);
                count2 += evenProgression.Count(ep => ep != modNumEvenProg);

                Console.WriteLine(count1 > count2 ? count2 : count1);
                return;
            }

            // 修正する箇所の数を計測
            int count;
            count = evenProgression.Count(ep => ep != modNumEvenProg);
            count += oddProgression.Count(op => op != modNumOddProg);
            Console.WriteLine(count);
        }
    }

    public static class MyExtension 
    {
        public static int Mode(this IEnumerable<int> progression)
        {
            var NumsOfElements = new Dictionary<int, int>();
            progression.Distinct().ToList().ForEach(p =>
            {
                NumsOfElements.Add(p, 0);
            });
            progression.ToList().ForEach(p =>
            {
                NumsOfElements[p]++;
            });
            var elements = NumsOfElements.OrderByDescending(noe => noe.Value);
            return elements.ElementAt(0).Key;
        }

        public static int SecoundMode(this IEnumerable<int> progression)
        {
            var NumsOfElements = new Dictionary<int, int>();
            progression.Distinct().ToList().ForEach(p =>
            {
                NumsOfElements.Add(p, 0);
            });
            progression.ToList().ForEach(p =>
            {
                NumsOfElements[p]++;
            });
            var elements = NumsOfElements.OrderByDescending(noe => noe.Value);
            if (NumsOfElements.Count < 2)
            {
                return elements.ElementAt(0).Key;
            }
            return elements.ElementAt(1).Key;
        }
    }
}


Measured memory_bytes: 37104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();

		if (A+B > A-B && A+B > A*B) {
			System.out.println(A+B);
		} else if (A*B > A-B && A*B > A+B) {
			System.out.println(A*B);
		} else {
			System.out.println(A-B);
		}


	}

}

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

int main () {
    int n, m;
    cin >> n >> m;
    int maxL = 1;
    int minR = n;
    int l, r;
    int ans = 0;

    for (int i = 0; i < m; ++i) {
        cin >> l >> r;
        maxL = max(maxL, l);
        minR = min(minR, r);
    }

    ans = max(minR - maxL + 1, 0);
    cout << ans << endl;

}




Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int d = scanner.nextInt();
        while(true){
            c = c-b;
            if(c <= 0){break;}
            a = a-d;
            if(a <= 0){break;}
            
        }
        if(a>0){System.out.println("Yes");}
        else{System.out.println("No");}
        return;
    }
}

Measured memory_bytes: 35832