akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		String s = sc.next();
		
		// 計算
		long result = 0;
		int cnt = 0;
		for(int i = 0; i < n; i++){
		    if(s.charAt(i) == 'I'){
		        cnt++; 
		    }else{
		        cnt--;
		    }
		    result = max(result, cnt);
		}
		
		// 出力
		System.out.println(result);
	}

	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


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

using Vec=vector<int>;
using Mat=vector<vector<int>>;
int n,l;
Mat E(){
    Mat res(n,Vec(n));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            res[i][j]=i*n+j;
        }
    }
    return res;
}
Mat merge(Mat lhs,Mat rhs){
    Mat res(n,Vec(n));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            int row=rhs[i][j]/n;
            int col=rhs[i][j]%n;
            res[i][j]=lhs[row][col];
        }
    }
    return res;
}
int getNum(int &p,string s){
    int res=0;
    while(p<s.size() && isdigit(s[p])){
        res*=10;
        res+=s[p]-'0';
        p++;
    }
    return res;
}
Mat powM(Mat mat,int k){
    Mat res=E();
    while(k){
        if(k&1) res=merge(res,mat);
        k>>=1;
        mat=merge(mat,mat);
    }
    return res;
}
Mat prim(int &p,string s){
    if(s[p]=='L' || s[p]=='R'){
        char op=s[p++];
        Mat res=E();
        int k=getNum(p,s);
        k--;
        int diff=(op=='L' ? n-1 : 1);
        for(int j=0;j<n;j++) res[k][(j+diff)%n]=k*n+j%n;
        return res;
    }
    if(s[p]=='U' || s[p]=='D'){
        char op=s[p++];
        Mat res=E();
        int k=getNum(p,s);
        k--;
        int diff=(op=='U' ? n-1 : 1);
        for(int i=0;i<n;i++) res[(i+diff)%n][k]=i*n+k;
        return res;
    }
    assert(false);
}

Mat seq(int &p,string s){
    Mat res=E();
    while(p<s.size() && s[p]!=')'){
        Mat ret;
        if(s[p]=='('){
            p++;
            ret=seq(p,s);
            assert(s[p++]==')');
            int num=getNum(p,s);
            ret=powM(ret,num);
        }
        else{
            ret=prim(p,s);
        }
        res=merge(res,ret);
    }
    return res;
}

void output(Mat mat,ostream& out){
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            out<<mat[i][j]+1<<(j+1==n ? "\n" : " ");
        }
    }
}
int main(){
    cin>>n>>l;
    string s;
    cin>>s;
    int p=0;
    Mat res=seq(p,s);
    output(res,cout);
    return 0;
}



Measured memory_bytes: 17932
n = int(input())
l = list(map(int,input().split()))
ans = 0
now = l[0]
count = 0
for i in range(1,n):
    if now >= l[i]:
        now = l[i]
        count += 1
        ans = max(ans,count)
    else:
        count = 0
        now = l[i]
print(max(ans,count))

Measured memory_bytes: 20364
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

void solve() {
  int n, k;
  cin >> n >> k;
  vector<pii> v, v2;
  rep(i, n) rep(j, i) {
    if (j == 0) v2.eb(j + 1, i + 1);
    else v.eb(j + 1, i + 1);
  }
  if (k > n * (n - 1) / 2 - (n - 1)) {
    cout << -1 << endl;
    return;
  }
  rep(i, k) {
    v.pop_back();
  }
  v.insert(v.end(), all(v2));
  cout << sz(v) << endl;
  rep(i, sz(v)) cout << v[i] << endl;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(){
    
    int n;
    
    cin >> n;
    int num=n;
    int dig,sum=0;
    
    while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
    }
    if(n%sum==0) cout << "Yes";
    else cout << "No";

    
    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <iostream>
#include <queue>
#include <set>
#define ll long long
#define sf(a) scanf("%lld",&a)
#define pf(b) printf("%lld",b)
#define sp printf(" ")
#define nw printf("\n")
#define mp make_pair
#define pi pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define fast ios_base::sync_with_stdio(false)
using namespace std;


int main()
{ 
  ll n,ans=0,sum=0,m=1000000007ll;
  sf(n);
  ll ar[n+1];
  for(ll i=1;i<=n;i++)
  {
   sf(ar[i]);
   ans=(ans+(sum*ar[i])%m)%m;
   sum+=ar[i];
   sum%=m;
  }
  pf(ans);
}



Measured memory_bytes: 4792
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    int h,w;
    cin>>w>>h;
    vector<vi> v(w,vi(h,0));
    rep(i,n){
      int x,y;
      cin>>x>>y;
      v[x-1][y-1]++;
    }
    int s,t,k,l;
    cin>>s>>t;
    int ans=0;
    rep(i,w-s+1)rep(j,h-t+1){
      int tmp=0;
      rep(k,s)rep(l,t)if(v[i+k][j+l])tmp++;
      ans=max(ans,tmp);
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3060
# coding: utf-8

def F_0n(n): # F(0, n)を求める
    if n % 2 == 0:
        return (int(n / 2) % 2) ^ n
    else:
        return int((n + 1) / 2) % 2

def F(a, b):
    return F_0n(a - 1) ^ F_0n(b)

A, B = [int(i) for i in input().split()]

print(F(A, B))

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

int main(){
	int N,sum=0;
	cin>>N;
	vector <int> s(N);
	for(int i=1;i<=N;i++){
		cin>>s[i];
		sum+=s[i];
	}

	sort(s.begin(),s.end());

	if(sum%10==0){
	for(int i=1;i<=N;i++){
		if(s[i]%10!=0) {
			sum-=s[i];
			break;
		}
		
		if(i==N)sum=0;
	}
}
	
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string s;cin>>s;
	vector<int> a(3,0);
	for(int i = 0; i < s.size(); i++) {
		a[s[i] - 'a']++;
	}
	if (abs(a[0] - a[1] <= 1 && abs(a[0] - a[2]) <= 1 && abs(a[1] - a[2]) <= 1)){
		cout << "YES" << endl;
		return 0;
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int n, a, b, c, ans = 1000000000;
vector<int> l(10);
void solve(int now, int s1, int s2, int s3, int cnt){
    if(now == n){
        if(s1 == 0 || s2 == 0 || s3 == 0)return;
        cnt += abs(a-s1) + abs(b-s2) + abs(c-s3);
        chmin(ans, cnt);
    }else{
        solve(now+1, s1, s2, s3, cnt);
        solve(now+1, s1+l[now], s2, s3, cnt + 10 * (s1 != 0));
        solve(now+1, s1, s2+l[now], s3, cnt + 10 * (s2 != 0));
        solve(now+1, s1, s2, s3+l[now], cnt + 10 * (s3 != 0)); 
    }
}

int main() {
    cin >> n >> a >> b >> c;
    rep(i, n)cin >> l[i];
    solve(0, 0, 0, 0, 0);
    cout << ans << endl;
}


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

int main(){
	int n;
	cin>>n;
	
	int a,b;
	int ma;
	int mb;
	int mia;
	int mib;
	cin>>ma>>mb;
	mia=ma;
	mib=mb;
	for(int i=1;i<n;i++){
		cin>>a>>b;
		if(a<ma){
			ma=a;
			mb=b;
		}
		if(a>mia){
			mia=a;
			mib=b;
		}
	}
	
	cout<<mia+mib<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);
// int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
// int a[12][12];



void solve() {
  int a,b,c; cin >> a >> b >> c;

  int mx=max({a,b,c}),mn=min({a,b,c}),md=a+b+c-mn-mx;
  cout << mn*md/2 << endl;
}

int main() {
  solve();
  return 0;
}





Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        if(a + b == 3){
            System.out.println(3);
        }
        else if (a + b == 5){
            System.out.println(1);
        }
        else {
            System.out.println(2);
        }
    }
}


Measured memory_bytes: 21204
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#define ll long long
using namespace std;

int main()
{
	char test[10];
	vector<int>al(26, 0);
	cin >> test;

	for (int i = 0; i < 4; i++) {
		al[(int)(test[i] - 'A')] ++;
	}

	for (int i = 0; i < 26; i++) {
		if (al[i] != 0 && al[i] != 2) {
			printf("No");
			return 0;
		}
	}

	printf("Yes");

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  string s;cin>>s;
  s[5]=' ';
  s[13]=' ';
  REP(i,19){
    cout<<s[i];
  }
  cout<<"\n";
  return 0;
}


Measured memory_bytes: 256
#include <stack>
#include <queue>
#include <cmath>
#include <bitset>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1

const int INF = 0x3f3f3f3f;
const int maxn = 1e5 + 7;
const int mod = 1e9 + 7;

int n;
struct node {
    int val;
    int id;
}a[maxn],b[maxn];

bool cmp(node aa,node bb) {
    return aa.val < bb.val;
}

int p[maxn];

int main() {
    while(~scanf("%d",&n)) {
        for(int i = 0 ; i < n ; i++) {
            scanf("%d",&a[i].val);
            a[i].id = i;
        }
        for(int i = 0 ; i < n ; i++) {
            scanf("%d",&b[i].val);
            b[i].id = i;
        }
        sort(a,a+n,cmp);
        sort(b,b+n,cmp);
        bool flag = false;
        for(int i = 0 ; i < n ; i++) {
            if(a[i].val > b[i].val) {
                flag = true;
                break;
            }
        }
        if(flag) printf("No\n");
        else {
            for(int i = 0 ; i < n - 1 ; i++) {
//                cout << a[i+1].val << " " << b[i].val << endl;
                if(a[i+1].val <= b[i].val) {
                    flag = true;
                    break;
                }
            }
//            cout << flag << endl;
            if(flag) printf("Yes\n");
            else {
                memset(p,0,sizeof(p));
                for(int i = 0 ; i < n ; i++) {
                    p[a[i].id] = b[i].id;
                }
                int x = p[0] , len = 1;
                while(x != 0) {
                    x = p[x];
                    len++;
                }
                if(len == n) printf("No\n");
                else printf("Yes\n");
            }
        }
    }
    return 0;
}


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

typedef long long ll;
const int MAX_N = 100030;    // Change as necessary
const ll  MODD = 1000000009; //

int A[MAX_N],B[MAX_N];
int C[MAX_N];

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  int n; cin >> n;
  for(int i=0;i<=n;i++){
    A[i] = i;
    B[n-i] = i;
  }
  
  for(int i=0;i<n;i++){
    int x; cin >> x;
    
    for(int j=x+1;j<=n;j++) A[j]+=n-i+1;
    for(int j=x-1;j>=0;j--) B[j]+=n-i+1;
  }
  
  int off = *min_element(A,A+n+1);
  off = min(off,*min_element(B,B+n+1));
  off = 1-off;
  for(int i=1;i<=n;i++)
    cout << (i == 1 ? "" : " ") << A[i]+off;
  cout << endl;
  
  for(int i=1;i<=n;i++)
    cout << (i == 1 ? "" : " ") << B[i]+off;
  cout << endl;
  
  
  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll x;
    cin >> x;
    cout << 1 - x << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 3608
import * as fs from 'fs';


namespace AtCoder.abc125 {
    export class Program {
        // in
        // 4
        // 13 21 6 19
        // 11 30 6 15
        // out
        // 6
        static main(inp: string) {
            const n: number = parseInt(inp.split('\n')[0]);
            const v: number[] = inp.split('\n')[1].split(' ').map(Number);
            const c: number[] = inp.split('\n')[2].split(' ').map(Number);

            let ans: number = 0;
            v.forEach((val: number, idx: number) => {
                if (val > c[idx]) {
                    ans += (val - c[idx]);
                }
            });

            console.log(ans);
        }
    }
}

AtCoder.abc125.Program.main(fs.readFileSync('/dev/stdin', 'utf8').trim());

Measured memory_bytes: 7372
#define tst(a, b) for (int i = 1; i <= (b); i++) {cout << (a)[i] << " ";} cout << endl;
#define ll long long
#define lf long double
#define ch char
#define F(a) for (int i = 1; i <= (a); i++)
#define For(a, b) for (int (a) = 1; (a) <= (b); (a)++)
#define Rep(a, b, c) for (int (a) = (b); (a) <= (c); (a)++)
#define FD(a) for (int i = (a); i >= 1; i--)
#define ForD(a, b) for (int (a) = (b); (a) >= 1; (a)--)
#define RepD(a, b, c) for (int (a) = (b); (a) >= (c); (a)--)
#define mp(a, b) make_pair((a), (b))
#define pb(a) push_back(a)
#define fi first
#define se second
#define il inline
#define reg register
#define ret return
#define opt operator
#define Mem0(a) memset((a), 0, sizeof(a))
#define MemInf(a) memset((a), 115, sizeof(a))
#define Mem(a, n) memset((a), (n), sizeof(a))
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
inline ll Rd() {
	ll C = getchar();
	ll V = 0;
	ll Sign = 0;
	while (C > '9' || C < '0') {
		Sign |= (C == '-');
		C = getchar();
	}

	while (C <= '9' && C >= '0') {
		V = (V << 1) + (V << 3) + (C ^ '0');
		C = getchar();
	}
	Sign && (V = -V);
	return V;
}

ll N;

int main()
{
	cin >> N;
	cout << N + N * N + N * N * N << endl;
	return 0;
}


Measured memory_bytes: 3632
// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
    "3 1 4" => "3",
    "3 3 33" => "2"
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        v: [u8; 3],
    }

    let mut v = v;
    v.sort();
    v.dedup();
    v.len().to_string()
}

Measured memory_bytes: 4352
//atcoder 176 a
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,t;
    cin>>n>>x>>t;
    if(n%x==0)
    cout<<t*(n/x);
    else
    {
        cout<<t*((n/x)+1)<<endl;
    }
    
}

Measured memory_bytes: 3568
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

A.sort(reverse=1)
B.sort(reverse=1)
C.sort(reverse=1)

ans = 0
before_b = 0
before_c = 0
mem = 0

for a in range(N):
    ans += mem
    for b in range(before_b, N):
        if A[a] < B[b]:
            for c in range(before_c, N):
                if B[b] >= C[c]:
                    before_c = c
                    c -= 1
                    break
                before_c = N

            ans += c + 1
            mem += c + 1
        else:
            before_b = b
            break
        before_b = b + 1


print(ans)

Measured memory_bytes: 23200
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double 
#define foi(a,n) for(int i = a; i < n; i++)
#define ee 1000000007
#define pb push_back

ll fast(ll n,ll k,ll mod){
    ll res = 1;
    n = n%mod;
    while(k > 0){
        if ((k&1) == 1)
            res = ((res%mod) * (n%mod))%mod;
        k = k>>1;
        n = (n * n)%mod;
    }
    return res%mod;
}

ll ncr(ll n, ll k){ 
    ll res = 1; 
    if (k > n - k)k = n - k; 
    for (int i = 0; i < k; ++i) { 
        res = (res%ee * (n-i)%ee)%ee;
        res = (res%ee * fast(i+1, ee-2, ee))%ee; 
    }
    return res; 
}
void solve() {
    ll n;
    cin >> n;
    ll x = 1, i = 1;
    ll sum = 0;
    if(n < 3) {
		cout << 0;
		return;
	}
    while(n >= x*3){
		i = n - (x)*3;
		//~ cerr << "->" << i << " " << x << " " << ncr(i+1, x-1)<<'\n';
		sum = (sum + ncr(i+x-1, x-1))%ee;
		sum %= ee;
		x++;
	}
	cout << sum;
}

int main() {
	
    int t = 1;
    //~ cin >> t;
    while(t--){
		solve();
		cout << '\n';
	}
}


Measured memory_bytes: 3572
#include<iostream>
#include<cstdio>
using namespace std;
const int N=200005;
const int MOD=1000000007;
int n;
int A,B,c;
long long ksm(long long a,long long b)
{
	long long res=1;
	while(b)
	{
		if(b&1) res=res*a%MOD;
		a=a*a%MOD,b>>=1;
	}
	return res;
}
long long fac[N],inv[N];
void init(int n=200000)
{
	fac[0]=1;
	for(int i=1;i<=n;i++)
		fac[i]=fac[i-1]*i%MOD;
	inv[n]=ksm(fac[n],MOD-2);
	for(int i=n;i>=1;i--)
		inv[i-1]=inv[i]*i%MOD;
	return;
}
long long C(int n,int m)
{
	if(m>n) return 0;
	else return fac[n]*inv[m]%MOD*inv[n-m]%MOD;
}
int main()
{
	init();
	scanf("%d",&n);
	scanf("%d%d%d",&A,&B,&c);
	int a=1LL*A*ksm(A+B,MOD-2)%MOD,b=1LL*B*ksm(A+B,MOD-2)%MOD;
	long long ans=0;
	for(int i=n;i<n*2;i++)
	{
		long long res=(ksm(a,n)*ksm(b,i-n)%MOD*C(i-1,n-1)%MOD+ksm(b,n)*ksm(a,i-n)%MOD*C(i-1,n-1)%MOD)%MOD*i%MOD;
		ans=(ans+res)%MOD;
	}
	ans=ans*100%MOD*ksm(A+B,MOD-2)%MOD;
	printf("%lld",ans);
	return 0;
}

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

public class Main {

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

		while ((line = br.readLine()) != null) {
			char c;
			int n;
			for (int i = 0; i < line.length(); i++) {
				c = line.charAt(i);
				if (c == '@') {
					n = line.charAt(++i) - '0';
					c = line.charAt(++i);
					for (int j = 0; j < n; j++) {
						System.out.print(c);
					}
				} else {
					System.out.print(line.charAt(i));
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 16872
import sys
readline = sys.stdin.readline

N = int(readline())
P3 = [pow(3, i) for i in range(N+1)]

St = [1 if s == 'R' else 0 for s in readline().strip()]
LS = len(St)
ans = [None]*P3[N]
arr = [None]*P3[N]
ans[0] = 0
arr[0] = St[:]
REV = (0, 2, 1)
for l in range(N):
    p3l = P3[l]
    for i in range(p3l):
        k0, k1, k2 = 0, 1, 2
        r0, r1, r2 = [], [], []
        for s in arr[i]:
            if s:
                k0 += 1
                k1 += 1
                k2 += 1
                if k0 == 3:
                    k0 = 0
                    r0.append(1)
                if k1 == 3:
                    k1 = 0
                    r1.append(1)
                if k2 == 3:
                    k2 = 0
                    r2.append(1)
            else:
                k0 = REV[k0]
                k1 = REV[k1]
                k2 = REV[k2]
                if r0 and r0[-1] == 0:
                    r0.pop()
                else:
                    r0.append(0)
                if r1 and r1[-1] == 0:
                    r1.pop()
                else:
                    r1.append(0)
                if r2 and r2[-1] == 0:
                    r2.pop()
                else:
                    r2.append(0)
        arr[2*p3l+i] = r2[:]
        arr[p3l+i] = r1[:]
        arr[i] = r0[:]
        a = ans[i]
        ans[2*p3l+i] = k2*p3l+a
        ans[p3l+i] = k1*p3l+a
        ans[i] = k0*p3l+a
                
print(*ans)

Measured memory_bytes: 194476
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
int dp[1009][1009];

int main(){
  int h,w;
  char mp[1009][1009];
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>mp[i][j];
    }
  }
  dp[0][1]=1;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(mp[i][j]!='#'){
	dp[i+1][j+1]=(dp[i][j+1]+dp[i+1][j])%mod;
      }
    }
  }
  cout<<dp[h][w]<<endl;
  return(0);
}


Measured memory_bytes: 5120
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;

int n;
bool vis[10];

int main(){
	while(~scanf("%d", &n)){
		int cnt = 0;
		for(int i = 1; i <= n; i++){
			int a;
			scanf("%d", &a);
			for(int i = 1; i <= 8; i++){
				if(a >= (i - 1) * 400 && a < i * 400){
					vis[i] = true;
					break;
				}
			}
			if(a >= 3200) cnt++;
		}
		int ans = 0;
		for(int i = 1; i <= 8; i++)
			if(vis[i]) ans++;
		int Min, Max;
		Min = ans;
		if(ans == 0) Min = 1;
		Max = ans + cnt;
		printf("%d %d\n", Min, Max);
		memset(vis, 0, sizeof(vis));
	}
	return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int[] c = new int[3];
        int A = sc.nextInt();
        c[0] = A;
        int B = sc.nextInt();
        c[1] = B;
        int C = sc.nextInt();
        c[2] = C;
        sc.close();
        Arrays.sort(c);

        if(A%2 == 0 || B%2 == 0 || C%2 == 0)
            System.out.println(0);
        else{
            System.out.println((long)c[0]*(long)c[1]);
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>

using namespace std;

long long int GCD(long long int a, long long int b) {
    if(a<b) swap(a, b);

    if(b==0) return a;
    
    return GCD(b, a%b);
}

int main() {
    long long int A, B, C, D;
    cin >> A >> B >> C >> D;
    
    long long int c, d, cd;
    c = B/C - (A-1)/C;
    d = B/D - (A-1)/D;
    cd = C/GCD(C, D)*D;
    cd = B/cd - (A-1)/cd;
    cout << (B-A+1)-(c+d-cd) << endl;


    return 0;
    
}

Measured memory_bytes: 256
#include <stdio.h>



 int main(){

  int n,x;
  int count;
  int i,j,k;

  while(1){
    count =0;
    scanf("%d %d",&n,&x);
    if(n==0 && x==0)break;

    for (i = 1; i <= n; i++){
      for (j = i+1; j<=n ;j++) {
        for(k = j+1;k<=n;k++){
          if(i+j+k==x && i<j && j<k){
            count = count+1;
          }
      }
    }
  }

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



}


return(0);
}

Measured memory_bytes: 600
let (n1, n2) = (3, 9)
(* let (n1, n2) = (4, 16) *)
let n_limit = 100
let mdt = Array.make_matrix n2 n2 0
let path = Array.make n_limit 0
let dx = [| 0; -1; 0; 1 |]
let dy = [| 1; 0; -1; 0 |]
let dir = [| "r"; "u"; "l"; "d" |]

type puzzle = { tbl : int array; space : int; md : int }

let dfs puzzle limit =
  let rec doit depth prev pzl =
    if pzl.md = 0 then true
    else if depth + pzl.md > limit then false
    else begin
      let rec move r =
        if r = 4 then false
        else
          let (sx, sy) = (pzl.space / n1, pzl.space mod n1) in
          let (tx, ty) = (sx + dx.(r), sy + dy.(r)) in
          if tx < 0 || ty < 0 || tx >= n1 || ty >= n1 then move (r + 1)
          else if max prev r - min prev r = 2 then move (r + 1)
          else begin
            let { tbl; space; md } = pzl in
            let (space, num) = (tx * n1 + ty, sx * n1 + sy) in
            let md = md - mdt.(space).(tbl.(space)-1) in
            let md = md + mdt.(num).(tbl.(space)-1) in
            let tbl = Array.copy tbl in
            let t = tbl.(space) in
            tbl.(space) <- tbl.(num);
            tbl.(num) <- t;
            if doit (depth + 1) r { tbl; space; md } then begin
              path.(depth) <- r;
              true
            end else move (r + 1)
          end in
      move 0
    end in
  doit 0 (-n_limit) puzzle

let idastar tbl space =
  let (_, md) =
    Array.fold_left (fun (i, sum) e ->
      (i + 1, if e = n2 then sum else sum + mdt.(i).(e-1)))
      (0, 0) tbl in
  let pzl = { tbl; space; md } in
  let rec doit limit =
    if limit > n_limit then assert false
    else if dfs pzl limit then begin
      let str = ref "" in
      for i = 0 to limit - 1 do
        str := !str ^ dir.(path.(i));
      done;
      !str
    end else doit (limit + 1) in
  doit pzl.md

let () =
  for i = 0 to n2 - 1 do
    for j = 0 to n2 - 1 do
      mdt.(i).(j) <- abs (i / n1 - j / n1) + abs (i mod n1 - j mod n1)
    done
  done;
  let tbl = Array.make n2 0 in
  let rec doit i space =
    if i = n2 then space
    else begin
      let x = Scanf.scanf "%d " (fun i -> i) in
      let (x, space) = if x = 0 then (n2, i) else (x, space) in
      tbl.(i) <- x;
      doit (i + 1) space
    end in
  doit 0 0 |> idastar tbl |> String.length |> Printf.printf "%d\n"

Measured memory_bytes: 4548
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector< vector<long long>
#define mi map<int,int>
#define pi pair<int,int>

#define Fori(i,a,b) for(int i=a; i<b; i++)
#define Ford(i, a, b) for(int i=a; i>=b; i--)

#define pb push_back
#define mp make_pair

#define read(a, n) for(int i=0; i<n; i++) cin >> a[i];
#define print(x) cout << "X: == " << x << endl;
#define printMap(a) for(auto it=a.begin() ; it!= a.end() ; it++) {cout << it->first << "  " << it->second << endl; }
#define printVector(a) for(auto it = a.begin() ; it!= a.end() ;it++) {cout << *it << endl;}

using namespace std;
int main() {
    IOS
    int n;
    cin >> n;
    vi a(n);
    read(a, n);
    vi dp(n);
    Fori(i, 1, n) {
        if(i == 1) {
            dp[i] = dp[i-1] + abs(a[i] - a[i-1]);
        } else {
            dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]), dp[i-2] + abs(a[i] - a[i-2]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 3956
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

int main(void){
    Cin(int, a);
    Cin(int, b);
    Cin(int, c);
    Cin(int, d);
    Cout(2*b-a);
}

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

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer n = Integer.parseInt(scanner.next());
        Integer l = Integer.parseInt(scanner.next());


        Integer[] taste = new Integer[n];
        for(int i = 1; i <= n; i++) {
            taste[i-1] = l + i - 1;
        }


        int max = Math.abs(taste[0]);
        int min = Math.abs(taste[1]);
        for(int i = 0; i < taste.length; i++) {
            int v = Math.abs(taste[i]);
            if (v > max) {
                max = v;
            }
            if (v < min) {
                min = v;
            }
        }

        int sum = Stream.of(taste).mapToInt(Integer::intValue).sum();

        if( sum < 0) {
            System.out.println(sum + min);
        } else {
            System.out.println(sum - min);
        }

    }
}


Measured memory_bytes: 28624
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
        int tate,yoko;
        for(int x=0;x<=10000;x++){
        cin>>tate>>yoko;
        if(tate==0&&yoko==0)
            break;
        for(int i=1;i<=tate;i++){
            for(int j=1;j<=yoko;j++){
                if(i==1||i==tate||j==1||j==yoko){
                    cout<<"#";
                }else{
                    cout<<".";
                }
                }cout<<endl;
            }cout<<endl;
        }
}


Measured memory_bytes: 3096
// ABC170
function main(input) {
  var inputs = input.trim().split('\n');
  var X = inputs[0].split(' ')[0];
  var N = inputs[0].split(' ')[1];
  var P = typeof(inputs[1]) !== 'undefined' ? inputs[1].split(' ').map(n => parseInt(n, 10)) : [];

  var checker = [];
  for (var i = 0; i <= 100; i++) {
    checker.push(false);
  }

  for (var n = 0; n < N; n++) {
    checker[P[n]] = true;
  }

  var exists = false;
  var larger = 0;
  for (i = X; i <= 100; i++) {
    if (checker[i] === false) {
      larger = i;
      exists = true;
      break;
    }
  }
  if (!exists) larger = 101;

  exists = false;
  var smaller = 0;
  for (i = X; 0 <= i; i--) {
    if (checker[i] === false) {
      smaller = i;
      exists = true;
      break;
    }
  }
  if (!exists) smaller = -1;

  if (Math.abs(X - larger) < Math.abs(X - smaller)) {
    console.log(larger);
  } else {
    console.log(smaller);
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29636
#include<stdio.h>
int MAX(int a, int b){return a>b?a:b;}

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

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

    int ans;
    int max = -1;
    for(int i=0; i<n; i++){
        ans = 0;
        for(int j=0; j<=i; j++){
            ans += a[0][j];
        }
        for(int j=i; j<n; j++){
            ans += a[1][j];
        }
        max = MAX(max, ans);
    }

    printf("%d\n", max);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int c[100];
int G[100][100];
int a[100],b[100],n,m;
void dfs(int u,int p,int co)
{
	c[u]=co;
	for(int i=0;i<n;i++)
	{
		if(i==p)continue;
		if(G[u][i]&&c[i]!=co)dfs(i,u,co);
	}
}
main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		cin>>a[i]>>b[i];
		a[i]--,b[i]--;
	}
	int cnt=0;
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<n;j++)for(int k=0;k<n;k++)G[j][k]=0;
		for(int j=0;j<m;j++)
		{
			if(i==j)continue;
			G[a[j]][b[j]]=G[b[j]][a[j]]=1;
		}
		dfs(0,-1,i+1);
		bool flag=true;
		for(int j=0;j<n;j++)flag&=c[j]==i+1;
		cnt+=!flag;
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define ALL(c) (c).begin(), (c).end()
#define dump(a) cerr << #a << "=" << (a) << endl

using namespace std;

int main() {
	int N,M;
	bool is_open=false;
	vector<string> ids;
	string id;

	cin >> N;
	rep(i,N) {
		cin >> id;
		ids.push_back(id);
	}

	cin >> M;
	bool is_id = false;
	rep(i,M) {
		cin >> id;
		is_id = false;
		rep(j,ids.size()) {
			if (ids[j] == id) {
				is_id = true;
				is_open = !is_open;
				break;
			}
		}

		if (is_id) { //IDがあるとき
			if (is_open) {
				cout << "Opened by " + id << endl;
			}
			else {
				cout << "Closed by " + id << endl;
			}
		}
		else {
			cout << "Unknown " + id << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,A,B;
    cin >> N >> A >> B;
    if((B-A-1)%2){
        cout << "Alice" << endl;
    }else{
        cout << "Borys" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long ans,k;
queue<long long>q;
int main()
{
    cin>>k;
    for(long long i=1;i<=9;i++)
    {
    	q.push(i);
	}
	while(k--)
	{
		ans=q.front();
		q.pop();
		if(ans%10!=0) q.push(ans*10+ans%10-1);
		q.push(ans*10+ans%10);
		if(ans%10!=9) q.push(ans*10+ans%10+1);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5092
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var a1, a2, a3 []int
	var n int

	if sc.Scan() {
		a1 = splitToInt(sc.Text())
	}
	if sc.Scan() {
		a2 = splitToInt(sc.Text())
	}

	if sc.Scan() {
		a3 = splitToInt(sc.Text())
	}

	if sc.Scan() {
		n, _ = strconv.Atoi(sc.Text())
	}

	readBcount := 0
	bArr := make([]int, n)

	for readBcount < n {
		if sc.Scan() {
			b, _ := strconv.Atoi(sc.Text())
			bArr = append(bArr, b)
			readBcount++
		}
	}

	// あたりの組み合わせ8つ
	row1 := a1
	if isBingo(bArr, row1) {
		fmt.Print("Yes")
		return
	}

	row2 := a2
	if isBingo(bArr, row2) {
		fmt.Print("Yes")
		return
	}

	row3 := a3
	if isBingo(bArr, row3) {
		fmt.Print("Yes")
		return
	}

	col1 := []int{a1[0], a2[0], a3[0]}
	if isBingo(bArr, col1) {
		fmt.Print("Yes")
		return
	}

	col2 := []int{a1[1], a2[1], a3[1]}
	if isBingo(bArr, col2) {
		fmt.Print("Yes")
		return
	}

	col3 := []int{a1[2], a2[2], a3[2]}
	if isBingo(bArr, col3) {
		fmt.Print("Yes")
		return
	}

	dia1 := []int{a1[0], a2[1], a3[2]}
	if isBingo(bArr, dia1) {
		fmt.Print("Yes")
		return
	}

	dia2 := []int{a1[2], a2[1], a3[0]}
	if isBingo(bArr, dia2) {
		fmt.Print("Yes")
		return
	}
	fmt.Print("No")
}

func splitToInt(s string) (intArr []int) {
	arr := strings.Split(s, " ")

	for _, v := range arr {
		intV, _ := strconv.Atoi(v)
		intArr = append(intArr, intV)
	}
	return
}

func contains(arr []int, val int) bool {
	for _, v := range arr {
		if v == val {
			return true
		}
	}
	return false
}

func isBingo(base, target []int) bool {
	hit := 0
	for _, v := range target {
		if contains(base, v) {
			hit++
		}
	}

	return hit == 3
}


Measured memory_bytes: 640
#include <stdio.h>

int main (void)


{


int a,b,c,i,x;
x=0;

scanf("%d %d %d",&a,&b,&c);


for(i=a;i<=b;i++)


{


if(c%i==0)


{


x=x+1;


}


}


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


return 0;


}

Measured memory_bytes: 596
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#define N 100006
#define ll long long
#define dd double
#define esp 1e-10
using namespace std;

int n,m;
int num[N];

int main(){
	ll ans=0;
	int t1,t2;
	memset(num,0,sizeof(num));
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&t1);
		ans+=t1;
		++num[t1];
	}
	scanf("%d",&m);
	for(int i=1;i<=m;++i){
		scanf("%d%d",&t1,&t2);
		num[t2]+=num[t1];
		ans+=(t2-t1)*num[t1];
		num[t1]=0;
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast")
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
inline int read() {
    int s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch>'9') { if (ch == '-')w = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
    return s * w;
}
#define f(i, l, r) for (int i = l; i <= r; ++i)
#define rf(i, r, l) for (int i = r; i >= l; --i)
#define all(x) (x).begin(), (x).end()
#define l l
#define r r
#define lch (o << 1)
#define rch (o << 1 | 1)
#define mid ((l + r) >> 1)
#define mem(x, y) memset(x, y, sizeof(x))
#define mod1(x) ((x >= mod) && (x -= mod))
#define mod2(x) ((x < 0) && (x += mod))

const int inf = 2e9 + 7;
//const ll INF = INT64_MAX;
double eps = 1e-6;
const int mod = 1e9+7;
const int N = 1e6 + 10;
const double pi = acos(-1.0);
ll power(ll a, ll b) { ll res = 1; while (b) { if (b & 1)res = res * a % mod; a = a * a % mod; b >>= 1; }return res; }
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
void add(ll& a, ll b) { a += b; mod1(a); mod2(a); }
/*int len, C[N], clen;
int id(int v) { return lower_bound(C + 1, C + len, v) - C; }
void initC() { sort(C + 1, C + clen); len = unique(C + 1, C + 1 + clen) - C - 1; }*/

int a[N];
int vis[N];

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifdef local
    //freopen("in.txt", "r", stdin);
    int start = clock();
#endif
    int n; cin >> n;
    f(i, 1, n)cin >> a[i];
    bool ok = 1;
    f(i, 1, n) {
        if (a[i] == 1)continue;

        int up = sqrt(a[i]);
        f(j, 2, up)if (a[i] % j == 0) {
            if (vis[j]) {
                ok = 0; break;
            }
            if (j * j != a[i]) {
                if (vis[a[i] / j]) {
                    ok = 0; break;
                }
            }
            vis[a[i] / j] = 1;
            vis[j] = 1;
        }
        if (vis[a[i]]) {
            ok = 0;
        }
        vis[a[i]] = 1;
        if (!ok)break;
    }
    if (ok) {
        cout << "pairwise coprime";
    }
    else {
        int now = a[1];
        f(i, 2, n) {
            now = gcd(now, a[i]); if (now == 1)break;
        }
        if (now == 1) {
            cout << "setwise coprime";
        }
        else cout << "not coprime";
    }

#ifdef local
    int end = clock();
    //cout << '\n' << end - start << "ms";
#endif* /
}

Measured memory_bytes: 7912
#include<iostream>
#include<vector>
using namespace std;
vector<vector<int>>dat;
vector<int>dp;
int m(int d){
    if(dp[d]!=-1)return dp[d];
    dp[d]=0;
    for(auto k:dat[d]){
        dp[d]=max(dp[d],m(k)+1);
    }
    return dp[d];
}
int main(){
    int a,b,c,d;
    cin>>a>>b;
    dat.resize(a+1);
    dp=vector<int>(a+1,-1);
    for(int i=0;i<b;i++){
        cin>>c>>d;
        dat[0].push_back(c);
        dat[c].push_back(d);
    }
    int best=0;
    for(auto d:dat[0]){
        best=max(best,m(d));
    }
    cout<<best<<endl;

    return 0;
}


Measured memory_bytes: 12012
#include<iostream>

using namespace std;

int main(){
	int a[4], b[4];

	while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]){
		//hit
		int hit = 0;
		for (int i = 0; i < 4; i++)
			hit += (a[i] == b[i]);


		//blow
		int blow = 0;
		for (int i = 0; i < 4; i++)
			blow += ((a[i] == b[0]) || (a[i] == b[1]) || (a[i] == b[2]) || (a[i] == b[3]));

		cout << hit << " " << blow - hit << endl;
	}

	return 0;

}

Measured memory_bytes: 1160
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
ll MOD = 1000000007;
#define INF (1e9)

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


int main()
{
    string s;
    cin >> s;
    if (s[0] == s[1] & s[1] == s[2]) {
        cout << "Yes" << endl;
    } else if (s[1] == s[2] & s[2] == s[3]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
int MOD=1000000007;
struct Nums{
    long long n;
    vector<long long> kaijo;
    Nums(int N){
        n=N;
        kaijo.push_back(1);
        for(long long i=1;i<=n;i++){
            kaijo.push_back((kaijo[i-1]*i)%MOD);
        }
    }
    long myPow(long x, long n, long m){
        if(n == 0)
            return 1;
        if(n % 2 == 0)
            return myPow(x * x % m, n / 2, m);
        else
            return x * myPow(x, n - 1, m) % m;
    }
    long long modinv(long long a, long long m) {
        long long b = m, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        u %= m;
        if (u < 0) u += m;
        return u;
    }
    long long comb(long long N,long long K,long long rest){
        long long res=kaijo[N]*modinv(kaijo[K],rest)%rest;
        res*=modinv(kaijo[N-K],rest);
        res%=rest;
        return res;
    }
    long long perm(int N,int K,int rest){
        long long res=kaijo[N]*modinv(kaijo[N-K],rest)%rest;
        return res;
    }
};

signed main(){
    int n,m;cin>>n>>m;
    Nums lib(m+5);
    int res=lib.perm(m,n,MOD);
    int buf=lib.perm(m,n,MOD);
    int sub=0;
    //cout<<res<<"\n";
    rep1(i,n){
        int hoge=lib.comb(n,i,MOD);
        hoge*=lib.perm(m-i,n-i,MOD);hoge%=MOD;
        if(i&1)sub+=hoge;
        else sub+=MOD-hoge;
        sub%=MOD;
    }
    buf=buf+MOD-sub;buf%=MOD;
    res*=buf;res%=MOD;
    cout<<res<<"\n";
    return 0;
}

Measured memory_bytes: 7468
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

ll ni(ll a,ll b){
    if(b==0) return 1;
    else if(b%2==0) return ni(a,b/2)*ni(a,b/2);
    else return ni(a,b-1)*a;
}

int main(){
    int n; cin >> n;
    map<int,int> p;
    for(int i=2; i<=n; i++){
        int now=i;
        for(int j=2; j<=sqrt(i); j++){
            while(now%j==0){
                p[j]++;
                now/=j;
            }
        }
        if(now!=1) p[now]++;
    }
    int num4=0;
    int num2=0;
    int num24=0;
    int num14=0;
    int num74=0;
    for(auto x : p){
        if(x.second>=4) num4++;
        if(x.second>=2) num2++;
        if(x.second>=14) num14++;
        if(x.second>=24) num24++;
        if(x.second>=74) num74++;
    }
    int ans=(num4*(num4-1)/2)*(num2-2);
    ans+=num14*(num4-1);
    ans+=num24*(num2-1);
    ans+=num74;
    cout << ans << endl;
    return 0;
}


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

int main()
{
  int n;
  cin >> n;
  string a, b, ans;
  cin >> a >> b;
  int aa = a.size();
  for(int i = 0; i < aa; i++)
  {
    ans += a[i];
    ans += b[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256