akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

void solve() {
	int n;
	cin >> n;
	long long a[100001] = {0};
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		long long x;
		cin >> x;
		sum += x;
		a[x]++;
	}
	int q;
	cin >> q;
	while (q--) {
		long long dif = 0;
		long long x, y;
		cin >> x >> y;
		long long raz = y - x;
		a[y] += a[x];
		dif = raz * a[x];
		a[x] = 0;
		sum += dif;
		cout << sum << endl;
	}
}

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

    int t = 1;
//    cin>>t;
    for(; t; t--) {
    	solve();
	}
	return 0;
}

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

int n,m,u,v,p[100];

int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>u>>v;p[u]++;p[v]++;
	}
	for(int i=1;i<=n;i++) cout<<p[i]<<endl;
	return 0;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
#define Size(n) (n).size()

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}
//long long int ruizyo(long long int aa, long long int bb){
  //  if(aa==0){
    //    return 1;
    //}
    //else if(aa%2==0){
      //  long long int tt=ruizyo(aa/2,bb);
        //return (tt*tt)%MOD;
    //}
    //else{
      //  return (ruizyo(aa-1,bb)*bb)%MOD;
    //}
//}フェルマ－のア


//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

//bool fl[100001]//1000000以下の素数を調べよう！
//rrep(i,2,100001){
  //      if(!f[i]){
    //        for(int j=i+i;j<=100000;j+=i){
      //          f[j]=true;
        //    }
        //}
    //}
    //for(int i=3;i<=100000;i+=2){
      //  if(!f[i]){
        //    c[i]++;
      //  }
   // }

//visited=vector<vector<bool>>(10,vector<bool>(10,false));アを全部falseに


long long int n,cnt=0,ans=0,a,b,c[100002],d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;

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

    bool f[100001];//1000000以下の素数を調べよう！
    rrep(i,2,100001){
        f[i]=false;
    }
  rrep(i,2,100001){
        if(!f[i]){
          for(int j=i+i;j<=100000;j+=i){
               f[j]=true;
            }
        }
    }
    for(int i=3;i<=100000;i+=2){
        if(!f[i] && !f[(i+1)/2]){
            c[i]++;
        }
    }
    rrep(i,3,100001){
        c[i]+=c[i-1];
    }
       cin >> a;
       rep(i,a){
           cin>>x>>y;
           Cout(c[y]-c[x-1]);
       }
       
return 0;
}


Measured memory_bytes: 1536
#include<iostream>

using namespace std;

main(){
  
  char str[21];
  int i=0;
  while(cin >> str[i]){i++;}
  
  i--;
  int j=i;
  for(j=i;j>=0;j--){
    
    cout << str[j] ; 
  }
  //cout << '\n' ;

  cout << endl;
  return 0;
}

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

bool dp[100][100][20050];
int a[100][100];
int b[100][100];

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int h,w; cin >> h >> w;
  rep(i,h)rep(j,w) cin >> a[i][j];
  rep(i,h)rep(j,w) cin >> b[i][j];
  rep(i,h)rep(j,w) a[i][j] = abs(a[i][j] - b[i][j]);
  
  dp[0][0][a[0][0]] = true;
  
  rep(i,h)rep(j,w)rep(k,20000){
   if(i>0 && dp[i-1][j][k]){
     dp[i][j][k+a[i][j]] = true;
     dp[i][j][abs(k-a[i][j])] = true;
   }
   if(j>0 && dp[i][j-1][k]){
     dp[i][j][k+a[i][j]] = true;
     dp[i][j][abs(k-a[i][j])] = true;
   }
  }
  rep(k,20000){
    if(dp[h-1][w-1][k]){
      cout << k << endl; 
      return 0;
    }
  }

  return 0;
}

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

int main() {
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
  int64_t a,b,c;
  cin>>a>>b>>c;
  int64_t n,m;
  n=c-a-b;
  m=a*b;
  if(n>0&&4*m<(n*n))
    cout<<"Yes";
  else
    cout<<"No";
}

Measured memory_bytes: 256
use std::io;


/// https://beta.atcoder.jp/contests/abc090/tasks/abc090_b
fn main() {
    let (a, b) = {
        let i = read::<usize>();
        (i[0], i[1] + 1)
    };

    let mut cnt = 0;
    for i in a..b {
        let s = i.to_string();
        if s == s.chars().rev().collect::<String>() { cnt += 1; }
    }
    println!("{}", cnt);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int n,m,x,y,i,a[101],b,c[101],d,e;
	cin>>n>>m>>x>>y;
	for(i=0;i<n;i++) cin>>a[i];
	for(i=0;i<m;i++) cin>>c[i];
	b=-101;
	d=101;
	for(i=0;i<n;i++){
		if(b<a[i]) b=a[i];
	}
	for(i=0;i<m;i++){
		if(d>c[i]) d=c[i];
	}
	e=0;
	for(i=x;i<=y;i++){
		if(x<i && i<=y && b<i && d>=i) e=1;
	}
	if(e==1) cout<<"No War"<<endl;
	else cout<<"War"<<endl;
	return 0;
}

	

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<bitset>
#define Fail puts("NO"),exit(0);
#define eps 1e-10
#define maxn 3010
#define maxm 150010
#define inf 1000000007
#define mod 1000000007
#define inv 500000005
#define G 3
#define pi acos(-1)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll,int>pii;
typedef bitset<maxn> bit;
typedef long double ld;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n;
char s[maxn*2];
struct P{
    char t[maxn*2];
    int len;
    void operator += (P x)
    {
        for(int i=1;i<=x.len;i++)  t[++len]=x.t[i];
    }
}f[maxn],com;
pii p[maxn];
int used[maxn*2],top,nxt[maxn*2],bel[maxn*2];
bool check(P a,P b)
{
    int len=min(a.len,b.len);
    for(int i=1;i<=len;i++)
    {
        if(a.t[i]==b.t[i])  continue;
        if(a.t[i]>b.t[i])  return true;
        return false;
    }
    return (a.len>b.len);
}
int main()
{
    n=read();
    scanf("%s",s+1);
    for(int i=1;i<=2*n;i++)
    {
        if(used[i])  continue;
        for(int j=i+1;j<=2*n;j++)
        {
            if(s[i]!=s[j]&&!used[j])
            {
                p[++top]=mp(i,j);
                used[i]=used[j]=1;
                bel[i]=bel[j]=top;
                nxt[i]=j;
                break;
            }
        }
    }
    for(int i=n;i>=1;i--)
    {
        f[i]=f[i+1];
        if(s[p[i].fi]=='a')
        {
            int cnt=0;
            for(int j=p[i].fi+1;j<p[i].se;j++)  cnt+=(s[j]=='a'); 
            com.t[1]='a';com.t[2]='b';com.len=2;
            com+=f[i+cnt+1];
            f[i]=check(f[i],com)?f[i]:com;
        }
        else{
            com.len=0;
            int L=p[i].fi+1,R=p[i].se;
            while(true)
            {
                int tmp=0;
                for(int j=L;j<=R;j++)
                  if(s[j]=='b') tmp=max(tmp,nxt[j]);
                if(!tmp)  break;
                L=R+1;R=tmp;  
            }
            com.t[++com.len]='b';
            for(int j=p[i].fi+1;j<p[i].se;j++)  
              if(s[j]=='b')  com.t[++com.len]='b';
            com.t[++com.len]='a';
            for(int j=p[i].se+1;j<=R;j++)  com.t[++com.len]=s[j];
            com+=f[bel[R]+1];
            f[i]=check(f[i],com)?f[i]:com;
        }
    }
    for(int i=1;i<=f[1].len;i++)  printf("%c",f[1].t[i]);
    puts("");
	return 0;
}

Measured memory_bytes: 21380
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <string>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;
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 long long INF = 1LL << 60;
using pll = pair<long long, long long>;
typedef long long ll;
#define min(a, b) ((a) < (b) ? (a) : (b))
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)


string ABCD = "";
string res = "";

string getString(char x)
{
	string s(1, x);
	return s;
}

void fnc(int x, string moji) {
	if (moji.length() == 7) {
		if (x == 7) {
			res = moji;
		}
		return;
	}
	int tmp2 = moji.length() / 2 + 1;
	// charで引き算するのわからない。
	int tmp = ABCD[tmp2] - '0';
	fnc(x + tmp, moji + "+" + getString(ABCD[tmp2]));
	fnc(x - tmp, moji + "-" + getString(ABCD[tmp2]));
	return;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	// cout << std::fixed << std::setprecision(15);
	cin >> ABCD;
	fnc(ABCD[0] - '0', to_string(ABCD[0] - '0'));
	cout << res + "=7" << endl;
}


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

long long n, a[5][105];

long long route (long long n, long long a[5][105], long long row, long long col)
{
	long long ans;
	ans = a[row][col];
	
	if (col == n - 1 && row == 0)
		return ans + a[1][col];
		
	if (col == n - 2 && row == 1)
		return ans + a[1][col + 1];	
	
	if (row == 1)
	{
		for (int i = col + 1; i < n; i++)
			ans += a[1][i];
	}
	else
	{
		long long one, two;
		one = route(n, a, 0, col + 1);
		two = route(n, a, 1, col);
//		std::cout << one << " " << two << "\n\n";
		ans += std::max(one, two);
	}
	return ans;
}

int main() 
{	
	std::cin >> n;
	for (int i = 0; i < 2; i++)
		for (int j = 0; j < n; j++)
			std::cin >> a[i][j];
	
			
	long long ans;
	ans = route (n, a, 0, 0);
	std::cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f0(i, n) for(int i(0); i < (n); i++)
#define f1(i, n) for(int i(1); i <= n; i++)

using namespace std;
typedef long long ll;
const int N = 1e5 + 2;

int n, m, a[N], s[N];

void add(int &x, int y){
    x += y;
    int k = x/m;
    x = x - k*1ll*m;
}

map <int, int> g;
int main(){
    ios_base::sync_with_stdio(0);

    cin >> n >> m;
    f1(i, n) cin >> a[i];

    g[0] = 1;
    ll res = 0;
    f1(i, n){
        s[i] = s[i - 1];
        add(s[i], a[i]);
        res = res + g[s[i]];
        g[s[i]]++;
    }
    cout << res;
}



Measured memory_bytes: 3968
#include <iostream>

using namespace std;

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

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

namespace _1_1_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');

            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);

            Console.WriteLine(a * b + " " + (a + b)* 2);
        }
    }
}



Measured memory_bytes: 13912
#include<stdio.h>
int main(void){
	int n;
	scanf("%d",&n);

	char s[n + 1];
	scanf("%s",s);

	int ans = n;
	for(int i = 0; i < n - 1; i++){
		if(s[i] == s[i + 1]){
			ans -= 1;
		}
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int array[3];
	for(int i = 0; i < 3; i++) scanf("%d",&array[i]);
	for(int i = 2; i > 0; i--){
		for(int j = 0; j < i; j++){
			if(array[j] > array[j+1])swap(array[j],array[j+1]);
		}
	}
	printf("%d %d %d\n",array[0],array[1],array[2]);
}



Measured memory_bytes: 2752
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a; cin >> a;
    string s; cin >> s;
    if (a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }

    return 0;
}


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

struct Node{
	char name[10];
	int time;
};

queue<Node >Q;

int t = 0;

int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i = 1;i <= n; i++){
		Node p;
		scanf("%s%d",p.name,&p.time);
		Q.push(p);
	}
	while(!Q.empty()){
		Node point = Q.front();Q.pop();
		if(point.time > m){
			point.time -= m;	
			t += m;
			Q.push(point);
			continue;
		}
		t += point.time;
		printf("%s %d\n",point.name,t);
	}
}

Measured memory_bytes: 3796
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

int N;
int K;
long long h[100010];

long long dp[100100];

int main(){
  int N; cin >> N;
  int K; cin >> K;
  for (int i=0; i<N; ++i) cin >> h[i];

  for (int i=0; i<100010; ++i) dp[i] = INF;
  dp[0] = 0;

  for (int i=0 ;i<N; ++i){
    for (int j=1; j<=K; ++j){
      if (i+j < N){
        chmin(dp[i+j], dp[i] + abs(h[i+j] - h[i]));
      }
    }
  }
  cout << dp[N-1] << endl;
}

Measured memory_bytes: 1920
#include<iostream>
using namespace std;
int main(){

	while(true){
		int n,max=0,num=0;
		cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			int p,d1,d2;
			cin>>p>>d1>>d2;
			if(d1+d2>=max){
				max=d1+d2;
				num=p;
			}
		}
		cout<<num<<" "<<max<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
n = int(input())
ans = {}

for x in range(1,100+1):
    for y in range(1,100+1):
        for z in range(1,100+1):
            tmp=x**2+y**2+z**2+x*y+y*z+z*x
            ans[tmp] = ans.get(tmp, 0) + 1

for i in range(n):
    print(ans.get(i+1,0))


Measured memory_bytes: 11448
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 175, task b, 2020/08/15
//ms,
/*
*/

int main(void){
  int N;
  vector<int64_t> l;
  int ans=0;

  cin >>N;
  for(int i=0;i<N;i++){
    int64_t tmp;
    cin >>tmp;
    l.push_back(tmp);
  }

  for(int i=0;i<N-2;i++){
    for(int j=i+1;j<N-1;j++){
      for(int k=j+1;k<N;k++){
        if(l[i] == l[j] || l[j]==l[k] || l[k]==l[i]) continue;
        if(l[i] < l[j]+l[k] && l[j] < l[k]+l[i] && l[k] < l[i]+l[j]) ans++;
      }
    }
  }

  cout <<ans;

  return 0;
}
/*
*/


Measured memory_bytes: 3640
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        final int N = Integer.parseInt(sc.next());
        String[] ss = new String[N];
        for (int i = 0; i < N; i++) {
            ss[i] = sc.next();
        }
        String ans = "Yes";
        
        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                if (ss[i].equals(ss[j])) {
                    ans = "No";
                    break;
                }    
            }
        }
        for (int i = 0; i < N - 1; i++) {
            char last = ss[i].charAt(ss[i].length() - 1);
            char first = ss[i+1].charAt(0);
            if (last != first) {
                ans = "No";
                break;
            } 
        }
        
        out.println(ans);
        
        out.flush();
    }
}

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

int main(){
    int n;
	cin >> n;
	vector<int> b;
	for(int i=1; i<n; i++){
		int num;
		cin >> num;
		b.push_back(num);
	}
	int sum=b[0];
	int prev=b[0];
	for(int i=0; i<b.size(); i++){
		int cur = b[i];
		if(prev>cur){
			sum-=prev;
			sum+=cur*2;
		}else{
			sum+=cur;
		}
		prev=cur;
	}
	cout << sum << endl;
	
    return 0;
}


Measured memory_bytes: 256
#coding:utf-8
x, y, a, b, c = map(int, input().split())
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]
r = [int(i) for i in input().split()]
p.sort(reverse = True)
q.sort(reverse = True)

p = p[0:x]
q = q[0:y]

p.extend(q)
p.extend(r)
p.sort(reverse = True)

ans = 0

for i in range(x + y):
  ans += p[i]
  
print("{}".format(ans))

Measured memory_bytes: 23340
#include <iostream>
#include <cstdio>
#include <cmath>
#include <queue>
#include <map>
#include <cstring>
#include <string>
#include <set>
#include <vector>
#include <list>
#include <deque>
#include <algorithm>
#include <stack>
#include <numeric>
#include <time.h>
#include<iomanip>
#include<sstream>
#pragma disable:4996)
using namespace std;
const long long inf = 0x7f7f7f7f;
long long GCD(long long a, long long b) { return 0 == b ? a : GCD(b, a%b); }
const long long mod = 1e9 + 7;
const double pi = acos(-1);
long long a[120000];
long long l[120000];
long long r[120000];
int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	l[0] = a[0];
	for (int i = 1; i < n; i++)
		l[i] = GCD(l[i - 1], a[i]);
	r[n - 1] = a[n - 1];
	for (int i = n - 2; i >= 0; i--)
		r[i] = GCD(r[i + 1], a[i]);
	long long ans = 1;
	for (int i = 1; i < n-1; i++)
		ans = max(GCD(l[i - 1], r[i + 1]), ans);
	if (n == 2)
		cout << max(a[0], a[1]) << endl;
	else
		cout << max(ans,max(r[1],l[n-2])) << endl;
}

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

namespace ConsoleApp1
{
    class Program
    {

        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            List<int> A = new List<int>();
            for(int i = 0; i < S.Length; i++)
            {
                A.Add(int.Parse(S.Substring(i, 1)));
                
            }
            int C = A.Sum();
            if(int.Parse(S) % C == 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 28320
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;
   cin>>n;
   int v[n],c[n],dif[n];
   for(int i=0;i<n;i++)
   {
       cin>>v[i];
   }
   for(int i=0;i<n;i++)
   {
       cin>>c[i];
       dif[i]=v[i]-c[i];
   }
   int sum=0;
   for(int i=0;i<n;i++)
   {
       if(dif[i]>0)
       sum+=dif[i];


   }
   cout<<sum<<endl;
}


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

using namespace std;

int l, r, d, ans;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> l >> r >> d;
    for (int i = l; i <= r; ++i) {
        ans += i % d == 0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    string s;
    K -=1;
    cin >> s;
    if(s[K] == 'A') {
        s[K] = 'a';
    } else if(s[K] == 'a') {
        s[K] = 'A';
    } else if(s[K] == 'B') {
        s[K] = 'b';
    } else if(s[K] == 'b') {
        s[K] = 'B';
    } else if(s[K] == 'c') {
        s[K] = 'C';
    } else if(s[K] == 'C') {
        s[K] = 'c';
    }
    cout << s << endl;
    return 0;
}

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


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        boolean end = false;
        int light = a[0];
        int count = 1;
        Set<Integer> set = new TreeSet<>();
        set.add(1);
        set.add(light);
        while (true) {
            if (light == 2) {
                break;
            } else if(set.contains(a[light - 1])) {
                end = true;
                break;
            } else {
                light = a[light - 1];
                set.add(light);
                count++;
            }
        }
        if (end) {
            System.out.println(-1);
        } else {
            System.out.println(count);
        }
    }
}

Measured memory_bytes: 51704
#include<stdio.h>
#include<algorithm>
using namespace std;
int dp[1100][1100];
int c[1100];
int d[1100];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%d",c+i);
	for(int i=0;i<b;i++)scanf("%d",d+i);
	for(int i=0;i<1100;i++)for(int j=0;j<1100;j++)
		dp[i][j]=1010101010;
	dp[0][0]=0;
	for(int i=0;i<b;i++){
		for(int j=0;j<=a;j++){
			if(j<a)dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+c[j]*d[i]);
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
		}
	}
	printf("%d\n",dp[b][a]);
}

Measured memory_bytes: 5756
def get_bin_arr(n):
    arr = []
    while n > 0:
        arr.append(n & 1)
        n >>= 1
    return arr


def bin_arr_to_int(arr):
    return sum([2**i * digit for i, digit in enumerate(arr)])


def count_ones(idx, tier):
    half_cycle = 2**tier
    full_cycle = half_cycle * 2
    return (idx // full_cycle) * half_cycle \
        + max(idx % full_cycle - half_cycle, 0)


# A <= B
A, B = map(int, input().split())

a = get_bin_arr(A)
b = get_bin_arr(B)

my_max = 10**12
bin_digits = len(get_bin_arr(my_max))

# fill
a += [0] * (bin_digits - len(a))
b += [0] * (bin_digits - len(b))

ones = [0] * bin_digits

for i in range(bin_digits):
    ones[i] = count_ones(B + 1, i) - count_ones(A, i)

ans = [i % 2 for i in ones]
print(int(bin_arr_to_int(ans)))


Measured memory_bytes: 3064
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
#include<stdio.h>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

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

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}

int main(){
    int N,D;
    cin >> N >> D;
    double X[N][D];
    double U=0;
    int num=0;
    double r;
    for(int i=0;i<N;++i){
        for(int j=0;j<D;++j){
            cin >> X[i][j];
        }
    }
    double tmp;
    for(int i=0;i<N;++i){
        U=0;
        for(int j=i+1;j<N;++j){
            U=0;
            for(int k=0;k<D;++k){
                tmp=abs(X[i][k]-X[j][k]);
                U+=pow(tmp,2);
            }
            U=sqrt(U);
            if(floor(U)==U){
                ++num;
            }
        }
    }
    cout << num;
    }

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

using Point = complex<double>;

istream& operator>>(istream& is, Point& p) {
    double x, y;
    is >> x >> y;
    p = Point(x, y);
    return is;
}

double dist(const Point& p1, const Point& p2) { return abs(p1 - p2); }

double calc(const double& a, const double& b, const double& c, double s) {
    // s = (2r+a)*r/2 + (b + c) * r / 2 + 2r * (2s/a - r) / 2
    //   = (a+b+c)*r/2 + 2sr/a
    // => r = s/[(a+b+c)/2+2s/a]

    return s / ((a + b + c) / 2. + 2 * s / a);
}

int main() {
    array<Point, 3> points;

    for (auto i : irange(0L, 3L)) {
        cin >> points[i];
    }

    array<double, 3> a;
    for (auto i : irange(0L, 3L)) {
        a[i] = dist(points[i], points[(i + 1) % 3]);
    }

    auto t = (a[0] + a[1] + a[2]) / 2.;
    double s = sqrt(t * (t - a[0]) * (t - a[1]) * (t - a[2]));

    cout << setprecision(20)
         << max({calc(a[0], a[1], a[2], s), calc(a[1], a[2], a[0], s),
                 calc(a[2], a[0], a[1], s)})
         << endl;
}

Measured memory_bytes: 256
from collections import Counter

s = input()

head = s[0]
mid  = dict(Counter(s[2:-1]))
removed = s.replace('A', '').replace('C', '')
if head == 'A' and mid.get('C') is not None and mid['C'] == 1 and removed == removed.lower():
  print('AC')
else:
  print('WA')

Measured memory_bytes: 3316
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int[][] a = new int[n][2];
        for(int i=0; i<n; i++){
            a[i][0] = sc.nextInt();
            a[i][1] = sc.nextInt();
        }

        Arrays.sort(a, (a1, a2) -> (a2[1] - a1[1]));

        int t = a[0][1];
        for(int i=0; i<n; i++){
            t = Math.min(t, a[i][1]);
            t -= a[i][0];
        }
        if(t < 0){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }

    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            }else{
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }else if(b == -1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
    }
}


Measured memory_bytes: 38680
s=input()

for i in range(2**3):
    S=s[0]
    tot=int(s[0])
    for j in range(3):
        if (i>>j)&1:
            S+='+'+s[j+1]
            tot+=int(s[j+1])
        else:
            S+='-'+s[j+1]
            tot-=int(s[j+1])
    if tot==7:
        print(S+'=7')
        exit(0)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<int,int> P;
typedef struct pair<int,P> P2;

ll d[1001]={};

int main() {
	int n;
	cin>>n;
	for(int i=2;i<n+1;++i){
		int k=i;
		for(int j=2;j<i+1;++j){
			while(k%j==0){
				k=k/j;
				d[j]++;
			}
		}
	}
	ll res=1;
	for(int i=2;i<n+1;++i){
		if(d[i]>0)res=res*(d[i]+1);
		res=res%1000000007;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    ll ans = 0;
    ans = min(A, K);
    K -= A;
    if (K <= 0) {
        cout << ans << endl;
        return 0;
    }
    K -= B;
    if (K <= 0) {
        cout << ans << endl;
        return 0;
    }
    ans -= K;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	int A, B; cin >> A >> B;
	if (A == B)cout << "Draw" << endl;
	else if (B == 1)cout << "Bob" << endl;
	else if (A == 1)cout << "Alice" << endl;
	else if (A < B)cout << "Bob" << endl;
	else if (A > B)cout << "Alice" << endl;
	return 0;
}

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

using namespace std;

int main() {

    string integer;
    char checkValue;
    
    
    cin >> integer;

    checkValue = integer[1];



    if((integer[0] == checkValue && integer[2] == checkValue) || (integer[2] == checkValue && integer[3] == checkValue)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
x = int(input())
for i in range(-2*10**2,2*10**2):
    for j in range(-2*10**2,2*10**2):
        if i**5- j**5 ==x:
            print(i,j)
            exit()
        elif j**5 - i**5 == x:
            print(j,i)
            exit()

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

int main(){
  int n, m;
  cin >> n >> m;
  
  vector<int> a(m), b(m);
  rep(i, m)
    cin >> a[i] >> b[i];
    
  vector<int> o(n);
  rep(i, n) o[i] = i+1;
  
  int cnt, ans;
  ans=0;
  do
  {
    if (o[0]!=1) break;
    
    cnt = 0;
    rep(i, n-1){
      rep(j, m){
        if((a[j]==o[i] && b[j]==o[i+1]) ||
           (a[j]==o[i+1] && b[j]==o[i])) cnt++;
      }
    }
    
    if (cnt==n-1) ans++;
  } while (next_permutation(o.begin(), o.end()));
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define DEBUG(x)           cout << '>' << #x << ':' << x << endl;
#define forn(i,n)          for(int i=0;i<(int)n;++i)
#define for1(i,n)          for(int i=1;i<=(int)n;++i)
#define forr(i,n)          for(int i=(int)n-1;i>=0;--i)
#define forre(i,a,b)       for(int i=(int)b;i>=(int)a;--i)
#define fore(i,a,b)        for(int i=(int)a;i<=(int)b;++i)
#define input(arr,n)       for(int i=0;i<n;i++)cin>>arr[i]
#define output(arr,n)      for(int i=0;i<n;i++)cout<<arr[i]<<" "
#define for_each(arr)      for(auto& it:arr)cout<<it<<" "
#define ff                 first
#define ss                 second
#define PI                 acos(-1.0)
#define all(a)             a.begin(),a.end()
#define rall(a)            a.rbegin(),a.rend()
#define Unique(a)          sort(all(a)),a.erase(unique(all(a)),a.end())
#define pb(x)              push_back(x)
#define eb(x)              emplace_back(x) 
#define ppb(x)             pop_back(x)
#define pf(x)              push_front(x)
#define ppf(x)             pop_front(x)
#define in(x,y)            insert({x,y})
#define Sort(a)            sort(a.begin(),a.end())
#define mem(arr,a)         memset(arr,a,sizeof arr)
#define ins(a)             insert(a)
#define max2(a,b)          max(a,b)
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max3(b,c,d))
#define min2(a,b)          min(a,b)
#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min3(b,c,d))
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<char> vc;
typedef vector<double> vd;
/*inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void Set(int & n, int b) { n |= two(b); }
inline void Reset(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }*/
/*int fx1[]={+1,-1,+0,+0};
int fy1[]={+0,+0,+1,-1};
int fx2={+0,+0,+1,-1,-1,+1,-1,+1};
int fy2={-1,+1,+0,+0,+1,+1,-1,-1};
*/

ll a,b,c,n,ans,cn1,cn2,cn3,t;
string s,s1,s2;


int main()
{
    FIO;
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
   // #endif
    cin>>n>>s;
    char ch=s[0];
    s1=s[0];
    for(int i=1;i<n;i++){
        if(s[i]==ch)
            continue;
        else if(s[i]!=ch)
        {
            s1+=s[i];
            ch=s[i];
        }
    }
    cout<<s1.size()<<endl;
    

    
  
    #ifdef ONLINE_JUDGE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    #endif
   return 0;
}
 


Measured memory_bytes: 592
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const int mod = 1000000007;

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


//----------------------------------------------------------------


int main(){
int n;
cin>>n;
long long a[100010][3];
for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
    cin>>a[i][j];
    }
}
vector<vector<long long>>dp(100010,vector<long long>(3));
for(int i=0;i<100010;i++){
    for(int j=0;j<3;j++){
    dp[i][j]=-INF;
    }
}
for(int j=0;j<3;j++){
dp[0][j]=0;
}
for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
        for(int k=0;k<3;k++){
            if(j!=k){
    chmax(dp[i+1][j],dp[i][k]+a[i][j]);
            }
        }
}
}
long long ans=-INF;
for(int j=0;j<3;j++){
chmax(ans,dp[n][j]);
}
cout<<ans<<endl;
}









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

int gcd(int x,int y) {
    return y?gcd(y,x%y):x;
}

int main() {
    int k;
    cin>>k;
    int s = 0;
    for(int a=1;a<=k;a++) {
        for(int b=1;b<=k;b++) {
            for(int c=1;c<=k;c++) {
                s += gcd(a,gcd(b,c));
            }
        }
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void) {
  int i, j, k, n;
  scanf("%d", &n);
  int a[n][3], ans[n];
  for(i = 0; i < n; ++i) for(j = 0; j < 3; ++j) scanf("%d", &a[i][j]);
  for(i = 0; i < n; ++i) ans[i] = 0;
  for(i = 0; i < 3; ++i) {
    int f[200];
    for(j = 0; j < 200; ++j) f[j] = 0;
    for(j = 0; j < n; ++j) f[a[j][i]]++;
    for(j = 0; j < n; ++j) if(f[a[j][i]] == 1) ans[j] += a[j][i];
  }
  for(i = 0; i < n; ++i) printf("%d\n", ans[i]);
  return 0;
}


Measured memory_bytes: 2696
#include <stdio.h>

void swap (int *x, int *y);
int partition (int array[], int left, int right);
void quick_sort (int array[], int left, int right);

int main(void){
  int i;
  int n;
  double t;
  double ans=0;
  scanf("%d", &n);
  int v[n];

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

  quick_sort(v, 0, n-1);

  if(v[0]==v[n-1]){
    printf("%d\n", v[0]);
  }else{
    t=((double)(v[0]+v[1]))/2;
    for(i=2; i<=n-1; i++){
        //小さい二つをくっつける
        t=((double)(t+v[i]))/2;
    }
    ans=t;
    printf("%lf\n", ans);
  }

  return 0;
}

/* 値を入れ替える関数 */
void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define N 200005
ll mod=998244353;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
ll gcd(ll a,ll b){while(a&&b)a>b?a%=b:b%=a;return a+b;}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
int main()
{
    fast;   
    ll a,b,c;
    cin>>a>>b>>c;
    ll x=b/a;
    cout<<min(x,c)<<endl;

    return 0;
}


Measured memory_bytes: 256
a=input()
b=input()
d=a.split()
N=int(d[0])
K=int(d[1])
c=b.split()
s=0
max=0
for f in range(K):
    s=s+int(c[f])
max=s
for i in range(N-K):
    if(K+i<N):
      s=s+int(c[K+i])-int(c[i])
      if(s>max):
          max=s
    else: break
print(float((max+K)/2))

Measured memory_bytes: 19364
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int row_H = Integer.parseInt(scan.next());
        int col_W = Integer.parseInt(scan.next());


        String[] a = new String[row_H];
        for (int i = 0; i < row_H; i++) {
            a[i] = scan.next();
        }


        boolean[] row = new boolean[row_H];
        Arrays.fill(row, false);
        boolean[] col = new boolean[col_W];
        Arrays.fill(col, false);

        for (int i = 0; i < row_H; i++) {
            for (int j = 0; j < col_W; j++) {
                if (a[i].charAt(j) == '#') {
                    row[i] = true;
                    col[j] = true;
                }
            }
        }

        for (int i = 0; i < row_H; i++) {
            if (row[i]) {
                for (int j = 0; j < col_W; j++) {
                    if (col[j]) {
                        System.out.print(a[i].charAt(j));
                    }
                }
                System.out.println();
            }
        }
    }
}

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

bool isEvenAll(vector<int> vec) {
    for (int i = 0; i < vec.size(); ++i) {
        if (vec.at(i) % 2 == 1) {
            return false;
        }
    }
    return true;
}

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

    vector<int> vec(N);
    for (int i = 0; i < N; ++i) {
        cin >> vec.at(i);
    }

    int counter = 0;
    while (isEvenAll(vec)) {
        ++counter;
        for (int i = 0; i < vec.size(); ++i) {
            vec.at(i) /= 2;
        }
    }

    cout << counter << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cassert>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

class UnionFind
{
public:
    UnionFind(){};
    ~UnionFind(){};

    void Init(int num_entries) {
        num_entries_ = num_entries;
        par_.resize(num_entries_);
        rank_.resize(num_entries_, 0);
        for (int i = 0; i < num_entries_; ++i)
        {
            par_[i] = i;
        }
    }
    int Find(int x) {
        if (par_[x] == x)
        {
            return x;
        }
        else
        {
            return par_[x] = Find(par_[x]);
        }
    }
    
    void Unite(int x, int y) {
        x = Find(x);
        y = Find(y);
        if (x == y) return;

        if (rank_[x] < rank_[y])
        {
            par_[x] = y;
        }
        else
        {
            par_[y] = x;
            if (rank_[x] == rank_[y])
            {
                rank_[x]++;
            }
        }
    }
    bool Same(int x, int y) {
        return Find(x) == Find(y);
    }

private:
    int num_entries_;
    std::vector<int> par_;
    std::vector<int> rank_;
};

int main(){
    int N, Q;
    cin >> N >> Q;
    
    UnionFind uf;
    uf.Init(N);
    
    REP(q, Q) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0) {
            uf.Unite(x, y);
        }
        else {
            cout << uf.Same(x, y) << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1276
#include	<iostream>
#include	<cstdio>
#include	<cmath>

using namespace std;

int main(void) {
	while(1) {
		int w, n;
		int lin[30][2] = { 0 };
		int ans[30];
		int now;
		
		cin >> w;
		if( cin.eof() )		break;
		cin >> n;
		for(int i = 0; i < n; i++) {
			scanf("%d,%d", &lin[i][0], &lin[i][1]);
		}
		for(int i = 1; i <= w; i++) {
			now = i;
			for(int j = 0; j < n; j++) {
				if(now == lin[j][0]) {
					now = lin[j][1];
				} else if(now == lin[j][1]) {
					now = lin[j][0];
				}
			}
			ans[now - 1] = i;
		}
		for(int i = 0; i < w; i++) {
			cout << ans[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG




int main() {
  ll L, R, d, ans;
  cin >> L >> R >> d;
  //vector<ll> a(N);
  //vector<vector<int>> data(3, vector<int>(4));

  ans = 0;

  for (ll i=L; i<=R; i++){
    if(i % d ==0){
      ans ++;
    }
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <cstring>
#include <stdio.h>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <bitset>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
using namespace std;
typedef long long LL;
const LL mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const double e = exp(1);
const double eps = 1e-9;
const int MAX_N = 100000 + 100;

int m, n;

int main()
{
#ifdef ANONYM
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
#endif

    ios::sync_with_stdio(false);
    cin >> m >> n;
    cout << (m-1)*(n-1) << endl;
    return 0;
}


Measured memory_bytes: 256