akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

int main(void)
{
    int a, b;
    char op;
    std::cin >> a >> op >> b;
    if (op == '+')
    {
        a += b;
    }
    else
    {
        a -= b;
    }
    std::cout << a << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lson rt<<1
#define rson rt<<1|1
#define scd(x) scanf("%d",&x)
#define scdd(x,y) scanf("%d%d",&x,&y)
const int maxn=3e5+10;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=0x3f3f3f3f;
string str;
int main() {
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif // LOCAL
    int n,k;
    scdd(n,k);
    cin>>str;
    char last='?';
    int num=0;
    for(int i=0;i<n;i++){
        if(str[i]!=last){
            num++;
            last=str[i];
        }
    }
    int ans=n-num;
    if(num%2==0){
        num/=2;
       // cout<<num<<endl;
        if(k<num){
            ans+=2*k;
        }
        else{
            ans+=2*(num-1)+1;
        }
    }
    else {
        k=min(k,num/2);
        ans+=2*k;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

int main(){
    int N;
    cin >> N;
    vector<LL> A(N);
    vector<LL> B(N);   
    REP(i,N)cin>>A[i]>>B[i];

    LL ans = 0;
    for(int i=N-1; i>=0; i--){
        LL r = (A[i]+ans) % B[i];
        if(r==0){continue;}

        ans += B[i] - r;
    }

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

Measured memory_bytes: 4844
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    int n, m, p, sum = 0;
    int[] x = new int[1001];
    Scanner sc = new Scanner(System.in);

    n = sc.nextInt();
    m = sc.nextInt();
    p = sc.nextInt();
    sc.nextLine();

    while (n != 0) {
      for (int i = 0; i < n; i++) {
        x[i] = Integer.parseInt(sc.nextLine());
        sum += x[i];
      }
      
      try {
        System.out.println((sum * (100 - p)) / x[m - 1]);
      } catch (ArithmeticException e) {
        System.out.println("0");
      }
      
      sum = 0;
      n = sc.nextInt();
      m = sc.nextInt();
      p = sc.nextInt();
      sc.nextLine();
    }
    sc.close();
  }

}

Measured memory_bytes: 43124
#include <stdio.h>

#define N 500000

void merge(int*, int, int);

int a[N],n,count=0;
int temp[N];


int main(){

  int i,j;

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

    merge(a,0,n-1);

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

  return 0;
}


void merge(int x[],int left,int right){

  int mid,i,j,k;

  if(left>=right) return;

  mid=(left+right)/2;

  merge(x,left,mid);
  merge(x,(mid+1),right);

  for(i=left;i<=mid;i++){
    temp[i]=x[i];
  }

  for(i=(mid+1),j=right;i<=right;i++,j--){
    temp[i]=x[j];
  }

  i=left;
  j=right;

  for(k=left;k<=right;k++){

    if(temp[i]<=temp[j]) x[k]=temp[i++];
    else x[k]=temp[j--];

    count++;
}

}

Measured memory_bytes: 4504
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1e5+5,M=8*N;
int n,pa,pb,d,i,g[N];long long ans;
struct arr{int x,y,id;}a[N];
bool operator < (arr A,arr B){
	return A.x<B.x||A.x==B.x&&A.y<B.y;
}
int read(){
	char c=getchar();int k=0;for (;c<48||c>57;c=getchar());
	for (;c>47&&c<58;c=getchar()) k=(k<<3)+(k<<1)+c-48;return k;
}
int et,he[N];struct edge{int l,to;}e[M];
void line(int x,int y){
	e[++et].l=he[x];he[x]=et;e[et].to=y;
	e[++et].l=he[y];he[y]=et;e[et].to=x;
}
void work(int k){
	int i,j,l,r;sort(a+1,a+n+1);
	for (i=j=l=r=1;i<=n;i++){
		for (;a[l].x<a[i].x-d||
			a[l].x==a[i].x-d&&a[l].y<a[i].y-k;l++);
		for (;a[r].x<a[i].x-d||
			a[r].x==a[i].x-d&&a[r].y<=a[i].y+k;r++);
		g[a[i].id]+=r-l;j=max(j,l);if (j>=r) continue;
		for (line(a[i].id,a[j].id);j+1<r;j++)
			line(a[j].id,a[j+1].id);
	}
}
bool vis[N];
void dfs(int x){
	vis[x]=1;ans+=g[x];
	for (int i=he[x];i;i=e[i].l)
		if (!vis[e[i].to]) dfs(e[i].to);
}
int main(){
	n=read();pa=read();pb=read();
	for (i=1;i<=n;i++){
		int x=read(),y=read();
		a[i]=(arr){x+y,x-y,i};
	}
	d=max(abs(a[pa].x-a[pb].x),abs(a[pa].y-a[pb].y));
	for (work(d),i=1;i<=n;i++) swap(a[i].x,a[i].y);
	work(d-1);dfs(pa);printf("%lld",ans);
}


Measured memory_bytes: 9984
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main{

	static PrintWriter out;
	static InputReader ir;

	static void solve(){
		int n=ir.nextInt();
		int[] a=ir.nextIntArray(n);
		boolean[] f=new boolean[1000];
		for(int i=0;i<n;i++){
			f[a[i]]=true;
			if(i+1<n)
				f[a[i]*10+a[i+1]]=true;
			if(i+2<n)
				f[a[i]*100+a[i+1]*10+a[i+2]]=true;
		}
		int ans=0;
		while(f[ans])
			ans++;
		out.println(ans);
	}

	public static void main(String[] args) throws Exception{
		ir=new InputReader(System.in);
		out=new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer=new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}

		public boolean hasNextByte() {
			if(curbuf>=lenbuf){
				curbuf= 0;
				try{
					lenbuf=in.read(buffer);
				}catch(IOException e) {
					throw new InputMismatchException();
				}
				if(lenbuf<=0) return false;
			}
			return true;
		}

		private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}

		private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}

		private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}

		public boolean hasNext(){skip(); return hasNextByte();}

		public String next(){
			if(!hasNext()) throw new NoSuchElementException();
			StringBuilder sb=new StringBuilder();
			int b=readByte();
			while(!isSpaceChar(b)){
				sb.appendCodePoint(b);
				b=readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if(!hasNext()) throw new NoSuchElementException();
			int c=readByte();
			while (isSpaceChar(c)) c=readByte();
			boolean minus=false;
			if (c=='-') {
				minus=true;
				c=readByte();
			}
			int res=0;
			do{
				if(c<'0'||c>'9') throw new InputMismatchException();
				res=res*10+c-'0';
				c=readByte();
			}while(!isSpaceChar(c));
			return (minus)?-res:res;
		}

		public long nextLong() {
			if(!hasNext()) throw new NoSuchElementException();
			int c=readByte();
			while (isSpaceChar(c)) c=readByte();
			boolean minus=false;
			if (c=='-') {
				minus=true;
				c=readByte();
			}
			long res = 0;
			do{
				if(c<'0'||c>'9') throw new InputMismatchException();
				res=res*10+c-'0';
				c=readByte();
			}while(!isSpaceChar(c));
			return (minus)?-res:res;
		}

		public double nextDouble(){return Double.parseDouble(next());}

		public int[] nextIntArray(int n){
			int[] a=new int[n];
			for(int i=0;i<n;i++) a[i]=nextInt();
			return a;
		}

		public long[] nextLongArray(int n){
			long[] a=new long[n];
			for(int i=0;i<n;i++) a[i]=nextLong();
			return a;
		}

		public char[][] nextCharMap(int n,int m){
			char[][] map=new char[n][m];
			for(int i=0;i<n;i++) map[i]=next().toCharArray();
			return map;
		}
	}
}

Measured memory_bytes: 24568
#include<stdio.h>
int main(void)
{
	int c;
	scanf("%c",&c);
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
			printf("vowel\n");
	}
	else{
			printf("consonant\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

typedef priority_queue<int> QI;

int main(void){
  int n, qn;
  vector<QI> vq;
  
  cin >> n >> qn;
  vq = vector<QI>(n);
  for (int i=0; i<qn; i++){
    int q, t;
    cin >> q >> t;
    if (q==0){
      int x;
      cin >> x;
      vq[t].push(x);
    } else if (q==1){
      if (!vq[t].empty()) cout << vq[t].top() << endl;
    } else { // q==2
      if (!vq[t].empty()) vq[t].pop();
    }
  }
  
  return 0;
}


Measured memory_bytes: 3932
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
// numeric_limits<int>::max()

ll gcd(ll a, ll b) {
    if (a == 0) return b;
    if (b == 0) return a;
    ll large, small;
    if (a > b) {
        large = a;
        small = b;
    } else {
        large = b;
        small = a;
    }
    ll mod = large % small;
    while (mod != 0) {
        large = small;
        small = mod;
        mod = large % small;
    }
    return small;
}

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N), L(N, 0), R(N, 0);
    for (ll i = 0; (i < N); ++i) {
        cin >> A[i];
    }
    L[0] = 0;
    L[1] = A[0];
    for (ll i = 2; (i < N); ++i) {
        L[i] = gcd(A[i-1], L[i-1]);
    }
    R[N-1] = 0;
    R[N-2] = A[N-1];
    for (ll i = N-3; (i >= 0); --i) {
        R[i] = gcd(A[i+1], R[i+1]);
    }
    ll result = 0;
    for (ll i = 0; (i < N); ++i) {
        ll curGcd = gcd(L[i], R[i]);
        result = max(result, curGcd);
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
using namespace std;
int main()
{	
	long int i,n,a;
	while(cin>>n)
	{
	a=1;
	for(i=n;i>=1;i--)
	{
	a=a*i;	
	}
    cout<<a<<endl;
}
	return 0;
}

Measured memory_bytes: 3068
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<functional>
using namespace std;
int n, m, k;
int main() {
	cin >> n >> m >> k;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			int V = i*(m - j) + j*(n - i);
			if (V == k) { cout << "Yes" << endl; return 0; }
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,sum=0;
  bool is=false;
  cin >> n;
  string s[n],x;
  ll t[n];
  for(int i=0;i<n;i++){
    cin >> s[i] >> t[i];
  }
  cin >> x;
  for(int i=0;i<n;i++){
    if(is) sum += t[i];
    if(s[i]==x) is = true;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#define maxn 200010
using namespace std;
int n,a[2][maxn],ans;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i)
    {scanf("%d",&a[0][i]);a[0][i]+=a[0][i-1];}
    for(int i=1;i<=n;++i)
    {scanf("%d",&a[1][i]);a[1][i]+=a[1][i-1];}
    for(int i=1;i<=n;++i)
    {ans=max(ans,a[0][i]+a[1][n]-a[1][i-1]);}
    cout<<ans;
    
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

ll powmod(ll n, ll k) {
    ll r = 1, t = n % P;
    for (; k != 0; k /= 2) {
        if (k & 1) r = r * t % P;
        t = t * t % P;
    }
    return r;
}
ll inv(ll n) {
    return powmod(n, P - 2);
}

vector<int> f0, f1;
void init(int n) {
    f0.resize(n + 1);
    f0[0] = 1;
    for (int i = 1; i <= n; i++) {
        f0[i] = (ll)f0[i - 1] * i % P;
    }
    f1.resize(n + 1);
    f1[n] = inv(f0[n]);
    for (int i = n; i > 0; i--) {
        f1[i - 1] = (ll)f1[i] * i % P;
    }
}
ll fact(int k) {
    return f0[k];
}
ll comb(int n, int k) {
    if (n < k || k < 0) return 0;
    return (ll)f0[n] * f1[k] % P * f1[n - k] % P;
}

ll f(int r, int c, int k) {
    ll x = comb(r + c, r);
    ll u = 1;
    for (int i = k - 1; i > 0; i--) {
        ll t = comb(r + c + i, r);
        ll s = comb(r + c + i, c);
        x += (t + s) * u % P;
        u = u * 2 % P;
    }
    return x % P;
}

int main() {
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    r2++; c2++;

    init((int)3e6);
    ll r = f(r1, c1, (r2 - r1) + (c2 - c1)) - f(r1, c2, r2 - r1) - f(r2, c1, c2 - c1);

    r %= P;
    if (r < 0) r += P;

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 23680
A,B,C,X,Y = map(int, input().split())

List=[(A*X)+(B*Y)]

AB=0
AP=0
BP=0
ANS=0
while 1:
    if AP>=X and BP>=Y:
        #print(ANS)
        List.append(ANS)
        break
    if AB==2:
        AP+=1
        BP+=1
        AB=0
    else:
        ANS+=C
        AB+=1

AB=0
AP=X
BP=Y
ANS=0
while 1:
    if AP==0:
        ANS+=(BP*B)
        List.append(ANS)
        break
    elif BP==0:
        ANS+=(AP*A)
        List.append(ANS)
        break
    else:
        if AB==2:
            AP-=1
            BP-=1
            AB=0
        else:
            ANS+=C
            AB+=1
            
#print(List)
print(min(List))


Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	xm := make(map[int]int)
	for i := 0; i < 3; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		xm[a]++
		xm[b]++
	}

	if len(xm) != 4 {
		fmt.Println("NO")
	} else {
		c1, c2 := 0, 0
		for _, v := range xm {
			if v == 1 {
				c1++
			} else if v == 2 {
				c2++
			}
		}
		if c1 == 2 && c2 == 2 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}


Measured memory_bytes: 512
use std::io;
use std::str::FromStr;

type Position = (usize, usize);

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_tuple() -> (usize, usize) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<usize> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn dfs(now: Position, grid: &Vec<Vec<char>>, fliped_grid: &Vec<Vec<char>>, goal: Position, memo: &mut Vec<Vec<Vec<u64>>>, fliped: bool) -> u64 {
    // println!("{:?}", now);
    if fliped {
        if memo[0][now.0][now.1] != 9_999 {
            return memo[0][now.0][now.1];
        }
    } else {
        if memo[1][now.0][now.1] != 9_999 {
            return memo[1][now.0][now.1];
        }
    }
    
    if now == goal {
        return 0;
    }

    let mut min = 1_000_000_000;
    
    if now.1 < goal.1 && grid[now.0][now.1 + 1] == '.' {
        let result = dfs((now.0, now.1 + 1), grid, fliped_grid, goal, memo, fliped);
        if result < min {
            min = result;
        }
    }

    if now.0 < goal.0 && grid[now.0 + 1][now.1] == '.' {
        let result = dfs((now.0 + 1, now.1), grid, fliped_grid, goal, memo, fliped);
        if result < min {
            min = result;
        }
    }

    // println!("flip!");
    if now.1 < goal.1 {
        let result = dfs((now.0, now.1 + 1), fliped_grid, grid, goal, memo, !fliped) + 1;
        if result < min {
            min = result;
        }
    }

    if now.0 < goal.0 {
        let result = dfs((now.0 + 1, now.1), fliped_grid, grid, goal, memo, !fliped) + 1;
        if result < min {
            min = result;
        }
    }

    if fliped {
        memo[0][now.0][now.1] = min;
    } else {
        memo[1][now.0][now.1] = min;
    }
    min
}



fn main() {
    let (h, w) = input_tuple();
    // let h = 100;
    // let w = 100;
    let mut grid: Vec<Vec<char>> = Vec::new();
    let mut fliped_grid: Vec<Vec<char>> = Vec::new();
    for _ in 0..h {
        let line: String = input();
        let line: Vec<char> = line.chars().collect();
        let mut fliped_line: Vec<char> = Vec::new();
        for i in 0..w {
            if line[i] == '#' {
                fliped_line.push('.');
            } else {
                fliped_line.push('#');
            }
        }
        // let line = vec!['#'; 100];
        // let fliped_line = vec!['.'; 100];
        grid.push(line);
        fliped_grid.push(fliped_line);
    }

    let mut memo = vec![vec![vec![9_999; 100]; 100];2];
    let result;
    if grid[0][0] == '#' {
        result = dfs((0,0), &fliped_grid, &grid, (h-1, w-1), &mut memo, true) + 1;
    } else {
        result = dfs((0,0), &grid, &fliped_grid, (h-1, w-1), &mut memo, false);
    }

    if result % 2 == 0 {
        println!("{}", result / 2);
    } else {
        println!("{}", result / 2 + 1);        
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>
#include <string.h>
#include <cctype>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long gcd(long long a, long long b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

long long lcm(long long a, long long b)
{
	return a * b / gcd(a, b);
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	return a.second < b.second;
}


int main()
{
	int p, q, r;
	cin >> p >> q >> r;
	cout << (min(p + q, min(q + r, p + r)));
}



Measured memory_bytes: 31488
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    string s; cin>>s;
    int N=s.size();

    reverse(ALL(s));

    int i=0;
    while(i<N){
        if(s.substr(i,5)=="maerd") i+=5;
        else if(s.substr(i,7)=="remaerd") i+=7;
        else if(s.substr(i,5)=="esare") i+=5;
        else if(s.substr(i,6)=="resare") i+=6;
        else break;
    }
    cout<<(i==N? "YES":"NO")<<endl;
    
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
void bubbleSort(int a[], int n)
{
	int i, j,k=0,count=0;
	for ( i = n - 1; i>0; i--)
	{
		for (j = n - 1; j > k ; j--)
		{
			if (a[j] < a[j - 1])
			{
				int temp;
				temp = a[j];
				a[j] = a[j - 1];
				a[j - 1] = temp;
				count++;
			}
		}
		k++;
	}
	for (int i = 0; i < n; i++)
	{
		if (i > 0)
			cout << " ";
		cout << a[i];
	}
	cout << "\n" << count<<endl;
}
int main()
{
	int a[100], n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	bubbleSort(a, n);
	return 0;

}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long int ll;
const ll mod=1e9+7;
ll f[2006];
int main()
{
	ios;
	f[0]=1;
	for(int i=3;i<=2000;++i)
		for(int j=3;j<=i;++j)
		{
			f[i]=(f[i]+f[i-j])%mod;
		}
	int s;
	cin>>s;
	cout<<f[s]<<'\n';
}

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

int main() {
    ll n;
    cin >> n;
    ve<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.rbegin(),a.rend());
    ll ans = a[0];
    ll cnt = 1;
    ll i = 1;
    while(cnt<n-2){
        ans += a[i] * 2;
        i++;
        cnt += 2;
    }
    if(cnt != n-1) ans += a[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4844
#include<stdio.h>
int main(){
  int n,i,j,k;
  int A[140000];//14万！？うせやろ？
  scanf("%d",&n);
  for(i=0;i<100001;i++)A[i]=0;
  for(i=0;i<n;i++){scanf("%d",&j);A[j]++;}
  k=i=0;j=100000;
  while(1){
    while(A[i]<2)i++;
    while(A[j]<2)j--;
    if(j<i)break;
    k++;A[i]--;A[j]--;
  }
  printf("%d",n-2*k);
}


Measured memory_bytes: 512
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  auto s = readln.chomp.to!(char[]);

  char[] t;
  foreach (i; 0 .. (s.length)) {
    if (i % 2 == 0) {
      t ~= s[i];
    }
  }
  writeln(t);
}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


Measured memory_bytes: 664
#include<bits/stdc++.h>
using namespace std;
int main(){
	int S;
	cin >> S;
	int h = 0;
	int m = 0;
	int s = 0;
	
	int H_S = 60*60;
	int M_S = 60;
	
	while(S>=H_S){
		h+=1;
		S-=H_S;
	}
	while(S>=M_S){
		m+=1;
		S-=M_S;
	}
	s = S;
	cout << h << ":" << m << ":" << s << endl;
	
	
	return 0;
}


Measured memory_bytes: 3112
def read_input():
    n = int(input())
    return n


def lucas(n, l1, l2):
    if n == 0:
        return l2
    return lucas(n - 1, l2 + l1, l1)

def submit():
    n = read_input()
    print(lucas(n, 1, 2))

if __name__ == '__main__':
    submit()

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

int main(int argc, char *argv[]){
  int n;
  while(std::cin >> n, n){
    vector<int> a(n);
    map<int, int> um;
    for (int i = 0; i < n; i++) {
      std::cin >> a[i];
    }
    for (int i = 0; i < a.size(); i++) {
      um[a[i]]++;
    }
    int ans = -1;
    for (auto i:um) {
      if(i.second > a.size()/2)ans = i.first;
    }
    if(ans == -1)std::cout << "NO COLOR" << std::endl;
    else std::cout << ans << std::endl;
  }
  return 0;
}

Measured memory_bytes: 9476
#include <stdio.h>

int main()
{
    int a,b,c,k;
    scanf("%d %d %d", &a, &b, &c);
    scanf("%d", &k);
    while(b <= a){
        b *= 2;
        k--;
    }
    while(c <= b){
        c *= 2;
        k--;
    }
    (k >= 0)? printf("Yes") : printf("No");
}

Measured memory_bytes: 1732
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int max(int a,int b){return (a>b ? a:b);}
int min(int a,int b){return (a<b ? a:b);}

//int compare_int(const void *a, const void *b){return *(int*)a - *(int*)b;}
//これは昇べきの順のソート

int compare_int(const void *a, const void *b){return *(int*)b - *(int*)a;}
//これは降べきの順のソート

//qsort(配列, 長さ, sizeof(int), compare_int);

double BS(int array[],int len,int target);

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


char S[10];

int main(){
    scanf("%s",S);

    int l=0, L=0;
    int i = 0;
    while(S[i] != '\0'){
        if(S[i]=='A' || S[i]=='C' || S[i]=='G' || S[i]=='T'){
            l++;
            i++;
            //printf("a\n");
        }else{
            L = max(l,L);
            l = 0;
            i++;
            //printf("b\n");
        }
    }
    L = max(l,L);

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

    return 0;
}



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


double BS(int array[],int len,int target){ //(配列,長さ,見つける値)
    int low,mid,high;

    low = 0;
    high = len-1;

    int mark;

    while(low <= high){
        mid = (low + high) / 2;
        if(array[mid] == target){
            mark = 0;
            break;
        }else if(array[mid] < target){
            low = mid + 1;
            mark = 1;
        }else{
            high = mid - 1;
            mark = -1;
        }
    }
    if(mark == 0){
        return mid; //配列の何番目か（０から）
    }else if(mark == 1){
        return (double)mid + 0.5;//なかったらどこのあいだか
    }else{
        return (double)mid - 0.5;
    }
}


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

main()
{
    int i,j,k,l,m,n;

    while(cin>>n)
    {
        int x[n];
        for(i=0; i<n; i++)
            cin>>x[i];
        sort(x,x+n);
        m=x[0];
      for(i=0;i<n;i++){
        m=__gcd(m,x[i]);
      }
      cout<<m<<endl;
    }
    return 0;
}

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

int main() {
  string str1, str2;
  cin >> str1 >> str2;
  sort(str1.begin(), str1.end());
  sort(str2.begin(), str2.end());
  reverse(str2.begin(), str2.end());
  cout << (str1<str2?"Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int S, h, m, s;
  scanf("%d",&S);
  h=S/3600;
  m=(S-h*3600)/60;
  s=S-(m*60+h*3600);
  printf("%d:%d:%d\n",h,m,s);
  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n, m;
ll a[201010];
vector<pair<ll, ll>> vp; // <c[i], b[i]>
priority_queue<pair<ll, ll>> pq;
int main() {
    cin>>n>>m;
    REP(i, 0, n) cin>>a[i];
    REP(i, 0, m){
        ll b, c;
        cin>>b>>c;
        vp.emplace_back(c, b);
    }

    sort(vp.begin(), vp.end());
    reverse(vp.begin(), vp.end());


    ll cnt=0;
    REP(i, 0, m){
        REP(j, 0, vp[i].second){
            a[n+cnt]=vp[i].first;
            cnt++;

            if(cnt>=n) break;
        }
        if(cnt>=n) break;
    }

    sort(a, a+n+cnt);
    reverse(a, a+n+cnt);

    ll ans=0;
    REP(i, 0, n) ans+=a[i];

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

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

using namespace std;

int main(){
	char a;
	int sum = 0;
	int M = 0;
	for (int i = 0; i < 3; i++)
	{
		cin >> a;
		if (a == 'R') sum++;
		else sum = 0;
		M = max(M, sum);
	}
	cout << M << endl;
}

Measured memory_bytes: 3524
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
namespace mp = boost::multiprecision;
// 任意長整数型
using bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;
// ついでに有理数型
using rat = boost::rational<bint>;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
const string YES = "Yes";
const string NO = "No";

void solve(std::string N){
	ll x = 0;
	for (int i = 0; i < N.length(); i++) {
		
		x += (int)(N[i]-'0');
	}
	cout << (x % 9 == 0 ? YES:NO) << endl;
}

int main(){
    std::string N;
  std::cin >> N;
    solve(N);
    return 0;
}


Measured memory_bytes: 3860
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    assume s1 was bottom
    s1-w0 > s0-w1 better solidness
    s1+w1 > s0+w0
    otherwise
    s1+w1 < s0+w0

    OPT[i][j] - maximum value up to i-th brick with weight j
    OPT[i][j] = OPT[i-1][j-w[i]]+v[i] if we take i-th brick, 0 <= j-w[i] <= s[i]
                OPT[i-1][j]
    OPT[0][w[0]] = v[0], otherwise OPT[0][j] = 0
    """
    N = read_int()
    pairs = []
    max_w = 0
    max_s = 0
    for _ in range(N):
        w0, s0, v0 = read_ints()
        max_w = max(max_w, w0)
        max_s = max(max_s, s0)
        pairs.append((s0+w0, w0, s0, v0))
    MAX_WEIGHT = max_w+max_s+1
    pairs.sort()
    OPT = [
        [0]*MAX_WEIGHT for _ in range(N)
    ]
    OPT[0][pairs[0][1]] = pairs[0][3]
    for i in range(1, N):
        for j in range(MAX_WEIGHT):
            OPT[i][j] = max(OPT[i][j], OPT[i-1][j])
            if 0 <= j-pairs[i][1] <= pairs[i][2]:
                OPT[i][j] = max(OPT[i][j], OPT[i-1][j-pairs[i][1]]+pairs[i][3])
    return max(OPT[-1])


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 190364
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    ll k = n/(a+b);
    ll ans= 0;
    if(n%(a+b)!=0){
         ans = (k)*a;

        ll nn = n-(k)*(a+b);

        if(nn>=a){
            ans+=a;
        }else{
            ans+=nn;
        }
    }else{
        ans=k*a;
    }


    cout<<ans<<endl;

    
return 0;
}


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

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var s = Console.ReadLine();
		long wa = 0;
		for(int i = 0; i < s.Length / 2 + 1; i++)
		{
			if(s[i] != s[s.Length - i - 1])
			{
				wa++;
			
			}
			if(s.Length - i - 1== i+1)
				break;
		}
		Console.WriteLine(wa);
		
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


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

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

int main(void)
{
    ll n,sum=0,sum_a=0;
    cin >> n;
    vector<ll> a(n);
    const ll mod=1000000007;

    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        sum_a+=a[i];
    }
//    sum_a%=mod;
    for(int i=0;i<n;i++)
    {
        sum_a-=a[i];
        sum=(sum%mod)+(sum_a%mod)*(a[i]%mod);
        sum%=mod;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 4804
#include <bits/stdc++.h>
#include<iostream>
#include<queue>
using namespace std;
#define ll long long
#define PI 3.1415926535898

int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n; ll n1[100005];
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> n1[i];
	}
	ll ans = 0, tempmax = 0;
	for (int i = 0; i < n-1; i++)
	{
		if (n1[i] >= n1[i + 1])
			tempmax++;
		else
		{
			ans = max(tempmax, ans);
			tempmax = 0;
		}
	}
	ans = max(tempmax, ans);
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;
typedef vector<pair<ll, ll>> vpll;

//mt19937 random(566);
//uniform_int_distribution<ll> distr;
//ll rnd(ll a, ll b) {return a + distr(random) % (b - a + 1);}

const int N = 5e5;
const int M = 26;

int t[4 * N][M];
int a[N];

void build(int v, int tl, int tr) {
    if (tl == tr) t[v][a[tl]] = 1;
    else {
        int tm = (tl + tr) / 2;
        build(2 * v, tl, tm);
        build(2 * v + 1, tm + 1, tr);
        forn(i, M) t[v][i] = t[2 * v][i] + t[2 * v + 1][i];
    }
}

void update(int v, int tl, int tr, int pos, int x) {
    if (tl == tr) {
        t[v][a[tl]]--;
        a[tl] = x;
        t[v][x]++;
    } else {
        int tm = (tl + tr) / 2;
        if (pos <= tm) update(2 * v, tl, tm, pos, x);
        else update(2 * v + 1, tm + 1, tr, pos, x);
        forn(i, M) t[v][i] = t[2 * v][i] + t[2 * v + 1][i];
    }
}

vi get(int v, int tl, int tr, int l, int r) {
    if (r < tl || tr < l) return vi(M);
    if (l <= tl && tr <= r) {
        vi ans(M);
        forn(i, M) ans[i] = t[v][i];
        return ans;
    } else {
        int tm = (tl + tr) / 2;
        vi ansl = get(2 * v, tl, tm, l, r);
        vi ansr = get(2 * v + 1, tm + 1, tr, l, r);
        vi ans(M);
        forn(i, M) ans[i] = ansl[i] + ansr[i];
        return ans;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    string s;
    cin >> n >> s;
    forn(i, n) a[i] = s[i] - 'a';
    build(1, 0, n - 1);
    int q;
    cin >> q;
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            int x;
            string a;
            cin >> x >> a;
            x--;
            update(1, 0, n - 1, x, a[0] - 'a');
        } else {
            int l, r;
            cin >> l >> r;
            l--, r--;
            vi cnt = get(1, 0, n - 1, l, r);
            cout << 26 - count(all(cnt), 0) << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 109468
#include <stdio.h>

int main(){

  int a;
  scanf("%d", &a);
  
  if(a%10 == 3){
    printf("bon\n");
  }else if(a%10 == 0 || a%10 == 1 || a%10 == 6 || a%10 == 8){
    printf("pon\n");
  }else{
    printf("hon");
  }
}

Measured memory_bytes: 1684
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,q;
	int x;
	int box[100000];
	int i;
	cin>>n;
	for(i=0;i<n;i++)	cin>>box[i];
	cin>>q;
	for(i=0;i<q;i++){
		cin>>x;
		if(binary_search(box,box+n,x))	cout<<1<<endl;
		else						cout<<0<<endl;
	}
	return 0;
}



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

int main() {
  int N,B;
  cin >> N >>B;
  
  for (int i = 0; i < 100; i++) {
    if ((N-1)*i + 1 >= B) {
      cout << i <<endl;
      break;
    }
  }
  
}


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

int     main() {
        int A, B, C, K;
        cin >>A >>B >>C >>K;
        int D=max(A, max(B, C));
        int E=A+B+C-D;
        E += D*pow(2, K);
        cout <<E <<endl;
        return 0;
};

Measured memory_bytes: 512
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto X = RD;
	auto Y = RD;
	auto Z = RD;
	auto K = RD;
	auto A = RDR.ARR;
	auto B = RDR.ARR;
	auto C = RDR.ARR;
	//A.sort!"a > b"();
	//B.sort!"a > b"();
	//C.sort!"a > b"();

	auto dp = new long[](X*Y);
	foreach (i; 0..X)
	{
		foreach (j; 0..Y)
		{
			dp[i*Y+j] = A[i] + B[j];
			//debug writeln(i, ":", j, " ", dp[i*Y+j]);
		}
	}
	dp.sort!"a > b"();
	
	/*auto dpd = new long[](X*Y-1);
	foreach (i; 0..X*Y-1)
	{
		dpd[i] = dp[i] - dp[i+1];
	}
	auto cd = new long[](Z-1);
	foreach (i; 0..Z-1)
	{
		cd[i] = C[i] - C[i+1];
	}*/

	auto dp2 = new long[](min(K, X*Y)*Z+1);
	foreach (i; 0..min(K, X*Y))
	{
		foreach (j; 0..Z)
		{
			dp2[i*Z+j] = dp[i] + C[j];
			//debug writeln(i, ":", j, " ", dp2[i*Z+j]);
		}
	}
	dp2.sort!"a > b"();
	
	foreach (e; dp2[0..K])
		writeln(e);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 36604
#include<iostream>
#include<string>
using namespace std;
int main()
    {
    string line;
    getline(cin,line);
    int size=0;
    for(int i=0;i<line.size();i++){
            size++;
    }
     for(int i=0;i<size;i++){
     	cout<<"x";
	 }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A;
    cin>> A;
    int B;
    cin>>B;
    int C;
    cin>>C;
    if(A<=C && B>=C){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
    }
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define load ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ll long long
#define ull unsigned long long
#define fori(i,n) for (int i=0; i<int(n);i++)
#define srt(v) sort(v.begin(), v.end())
#define MOD 1000000007
const int INF = 1e9;
const double PI = 3.14159265358979323846;
ll gcd(ll a, ll b) {
    return b != 0 ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}
ll spow(ll base, ll exp){
	ll ans = 1;
	for(ll i=0;i<exp;i++) ans = ans * base % MOD;
	return ans;
}
ll divide(ll a, ll b){
	return a * spow(b, MOD-2) % MOD;
}
void solve(){
	
}

int main(){
	//~ load;
	//~ int t;
	//~ cin >> t;
	//~ while(t--){
		//~ solve();
	//~ }
	
	int n;
	cin >> n;
	vector<int> v(n);
	ll sum = 0;
	for(int i=0; i<n; i++){
		cin >> v[i];
		sum += v[i];
		sum %= MOD;
	}
	long res = 0;
	for(int i=0; i<n; i++){
		sum -= v[i];
		if (sum < 0) sum += MOD;
		res += v[i] * sum;
		res %= MOD;
	}
	cout << res << "\n";
}



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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String str = in.readLine();
    
    if(str.equals("A"))
      System.out.println("T");
    else if(str.equals("T"))
      System.out.println("A");
    else if(str.equals("G"))
      System.out.println("C");
    else
      System.out.println("G");
  }
}

Measured memory_bytes: 21204
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define SIZE 5000000
ll inv[SIZE + 1];
ll kai[SIZE + 1];
ll invkai[SIZE + 1];
void invinit()
{
	inv[1] = 1;
	for (int i = 2; i <= SIZE; i++)
	{
		inv[i] = mod - (mod / i)*inv[mod%i] % mod;
	}
	kai[0] = invkai[0] = 1;
	for (int i = 1; i <= SIZE; i++)
	{
		kai[i] = kai[i - 1] * i%mod;
		invkai[i] = invkai[i - 1] * inv[i] % mod;
	}
}
ll com(ll a, ll b)
{
	if (b < 0 || a < b)return 0;
	return (invkai[b] * invkai[a - b]) % mod*kai[a] % mod;
}
ll dp[2001][2001];
int main()
{
	invinit();
	int num, k;
	scanf("%d%d", &num, &k);
	if (k == 1)
	{
		printf("1\n");
		return 0;
	}
	dp[0][0] = 1;
	for (int i = 1; i <= num; i++)
	{
		ll sum = 0;
		for (int j = i; j >= 1; j--)
		{
			sum = (sum + dp[i - 1][j - 1]) % mod;
			dp[i][j] = sum*com(i*k - j - 1, k - 2) % mod;
		}
	}
	ll ans = 0;
	for (int i = 0; i <= num; i++)ans = (ans + dp[num][i]) % mod;
	for (int i = 1; i <= num; i++)ans = ans*i%mod;
	printf("%lld\n", ans);
}

Measured memory_bytes: 147200
#include <stdio.h>
 
int abs(int z){
	if(z<0){
		z*=(-1);
	}
	return z;
}
int main (){
    int x, a, b;
    scanf ("%d %d %d", &x, &a, &b);
    if(abs(x-a)<abs(x-b)){
    	printf("A\n");
	}else{
		printf("B\n");
	}
    
    return 0;
}

Measured memory_bytes: 1648
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int i,n,m,p=0;
  cin>>n>>m;
  float sum=0;
  vector<int> v(n);
  for(i=0;i<n;i++)
  {
    cin>>v[i];
    sum+=v[i];
  }
  for(i=0;i<n;i++)
  {
    if(v[i]<(sum)/(4*m))
    {
      p++;
    }
  }
  if(n-p>=m)
    cout<<"Yes\n";
  else cout<<"No\n";
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		for(;;){
			int n=sc.nextInt();
			if(n==0){
				break;
			}
			int[] a=new int[10];
			for(int i=0; i<n; i++){
				a[sc.nextInt()]++;
			}
			for(int i=0; i<10; i++){
				if(a[i]>0){
					for(int k=0; k<a[i]; k++){
						print("*");
					}
					println("");
				}else{
					println("-");
				}
			}
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

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

using namespace std;

typedef long long ll;

#define int long long

int N;
int last, cnt;

const string s[9] =
{
	".,!? ",
	"abc",
	"def",
	"ghi",
	"jkl",
	"mno",
	"pqrs",
	"tuv",
	"wxyz"
};

string Output(int n)
{
	string res;
	if (n == 0)
	{
		if (cnt > 0) res.push_back(s[last - 1][--cnt % s[last - 1].size()]);
		cnt = 0;
		return res;
	}
	last = n;
	cnt++;
	return "";
}

signed main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		string S, ans;
		cin >> S;
		for (int j = 0; j < S.size(); j++)
		{
			ans += Output(S[j] - '0');
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
from collections import Counter

n = input()
d = list(map(int, input().split()))
mod = 998244353

dcnt = Counter(d)
if d[0] > 0 or dcnt[0] > 1:
    print(0)
else:
    ans = 1
    for i in dcnt:
        if i > 0:
            ans = ans * dcnt[i - 1]**dcnt[i] % mod
    print(ans)


Measured memory_bytes: 19928
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int n;
	cin >> n;
	string s;
	cin >> s;
	int answer = 0, current = 0;
	for(auto &c : s)
	{
		c == 'I' ? ++current : --current;
		answer = max(answer, current);
	}
	cout << answer << '\n';
}

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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

string S;
bool d[4];

int main(){
    cin >> S;
    for(char ch:S)
    {
        if(ch=='N')d[0]=true;
        else if(ch=='S')d[1]=true;
        else if(ch=='W')d[2]=true;
        else if(ch=='E')d[3]=true;
    }
    if(d[0] && d[1] && d[2] && d[3])cout << "Yes" << endl;
    else if(d[0] && d[1] && !d[2] && !d[3])cout << "Yes" << endl;
    else if(!d[0] && !d[1] && d[2] && d[3])cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

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

  for (int i = 0; i < n.size(); i++) {
    if (n[i] == '1'){
      n[i] = '9';
    } else if (n[i] == '9') {
      n[i] = '1';
    }
  }

  cout << n;
}

Measured memory_bytes: 256