akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{
	public static String solve(List<Integer> n, List<String> ans){
		if( n.size() == 2 ){
			if( n.get(0) + n.get(1) == 10 ){
				return "(" + ans.get(0) + " + " + ans.get(1) + ")";
			} else if( n.get(0) - n.get(1) == 10 ){
				return "(" + ans.get(0) + " - " + ans.get(1) + ")";
			} else if( n.get(1) - n.get(0) == 10 ){
				return "(" + ans.get(1) + " - " + ans.get(0) + ")";
			} else if( n.get(0) * n.get(1) == 10 ){
				return "(" + ans.get(0) + " * " + ans.get(1) + ")";
			}else {
				return "0";
			}
		}
		String result = new String();
		for(int i = 0; i < n.size(); i++){
			for(int j = i+1; j < n.size(); j++){
				if( i == j ){
					continue;
				}
				List<String> temp = new ArrayList<String>();
				List<Integer> sum = new ArrayList<Integer>();
				sum.add(n.get(i)+n.get(j));
				temp.add("(" + ans.get(i) + " + " + ans.get(j) + ")");
				for(int k = 0; k < n.size(); k++){
					if( k != i && k != j ){
						sum.add(n.get(k));
						temp.add(ans.get(k));
					}
				}
				String x = solve(sum, temp);
				if( !x.equals("0") ){
					return x;
				}
				sum.set(0, n.get(i)-n.get(j));
				temp.set(0, "(" + ans.get(i) + " - " + ans.get(j) + ")");
				x = new String(solve(sum, temp));
				if( !x.equals("0") ){
					return x;
				}
				sum.set(0, n.get(j)-n.get(i));
				temp.set(0, "(" + ans.get(j) + " - " + ans.get(i) + ")");
				x = new String(solve(sum, temp));
				if( !x.equals("0") ){
					return x;
				}
				sum.set(0, n.get(i)*n.get(j));
				temp.set(0, "(" + ans.get(i) + " * " + ans.get(j) + ")");
				x = new String(solve(sum, temp));
				if( !x.equals("0") ){
					return x;
				}
			}
		}
		return "0";
	}
	
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		List<Integer> n = new ArrayList<Integer>();
		List<String> ans = new ArrayList<String>();
		for(int i = 0; i < 4; i++){
			int a = stdIn.nextInt();
			n.add(a);
			ans.add(Integer.toString(a));
		}
		while( n.get(0) != 0 || n.get(1) != 0 || n.get(2) != 0 || n.get(3) != 0 ){
			System.out.println(solve(n, ans));
			n = new ArrayList<Integer>();
			ans = new ArrayList<String>();
			for(int i = 0; i < 4; i++){
				int a = stdIn.nextInt();
				n.add(a);
				ans.add(Integer.toString(a));
			}
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0;i < n;i++)
const long long INF = 1LL << 60;

int MOD = 1000000007;

int main(){
    std::ios_base::sync_with_stdio(false);

    ll a,b; cin >> a >> b;

    ll num_one = 0LL;

    ll b_sum = 0LL;
    ll a_sum = 0LL;

    // 0 1 2 3 4
    num_one=(b+1)/2;
    if(b%2==0) b_sum = b^(num_one%2);
    else b_sum = num_one%2;

    // 0 1 2 3 4
    num_one=a/2;
    if((a-1)%2==0) a_sum = (a-1)^(num_one%2);
    else a_sum = num_one%2;

    ll ans = b_sum^a_sum;

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<sstream>
using namespace std;
#define maxn 2050
int V;                 
vector<int> G[maxn];  
int match[maxn];  
bool used[maxn];
#define  MAX_N 100
#define  MAX_L 1000
#define  INF 0x3f3f3f3f
int dis[MAX_N][MAX_N];
int p[MAX_L], t[MAX_L];  
void add_edge(int u, int v){
	G[u].push_back(v);
	G[v].push_back(u);
}
 
// 通?DFS?找?广路
bool dfs(int v){
	used[v] = true;
	for (vector<int>::iterator it = G[v].begin(); it != G[v].end(); ++it)
	{
		int u = *it, w = match[u];
		if (w < 0 || !used[w] && dfs(w))
		{
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
 
	return false;
}
int bipartite_matching(){
	int res = 0;
	memset(match, -1, sizeof(match));
	for (int v = 0; v < V; ++v)
	{
		if (match[v] < 0)
		{
			memset(used, 0, sizeof(used));
			if (dfs(v))
			{
				++res;
			}
		}
	}
 
	return res;
}
 
void clear(){
	for (int i = 0; i < V; ++i){
		G[i].clear();
	}
}	
int main(){
	int N, M, L;
	int i,j,k;
	while (~scanf("%d%d%d", &N, &M, &L)){
		if(N==0&&M==0&&L==0) break;
		V = L * 2;
		clear();
		memset(dis, INF, sizeof(dis));
 
		for (i= 0; i< M; ++i){
			int u, v, d;
			scanf("%d%d%d", &u, &v, &d);
			dis[u][v] = dis[v][u] = d;
		}
 
		for (i = 0; i < L; ++i)
		{
			scanf("%d%d", p + i, t + i);
		}
 
		for (k = 0; k < N; ++k) {
			dis[k][k] = 0;
			for (i = 0; i < N; ++i) {
				for (j = 0; j < N; ++j) {
					dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
				}
			}
		}
 
		for (i = 0; i < L; ++i) {
			for (j = 0; j < L; ++j)  {
				if (i != j && t[i] + dis[p[i]][p[j]] <= t[j]){
					add_edge(2 * i, 2 * j + 1);	
				}
			}
		}
		printf("%d\n", L - bipartite_matching());
	}
	return 0;
}

Measured memory_bytes: 11528
#include <stdio.h>
#include <algorithm>
using namespace std;
int A[210000];
int main(){
	int N;scanf("%d",&N);
		for(int i=0;i<N;i++)scanf("%d",A+i);
		std::sort(A,A+N);
		for(int i=0;i<N-1;i++){
		 if(A[i]==A[i+1]){
			printf("NO\n");return 0;
		}
	}
	printf("YES\n");
 }


Measured memory_bytes: 896
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int n;
    cin>>n;
    priority_queue<int> hoge;
    
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        hoge.push(a);
    }
    
    string ans="No";
    
    int maxl=hoge.top();
    int otherl=0;
    hoge.pop();
    
    while(!hoge.empty()){
        otherl+=hoge.top();
        hoge.pop();
        if(maxl<otherl){
            ans="Yes";
            break;
        }
    }
    
    cout<<ans<<endl;
    
    return 0;
}

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

uint64_t gcd(uint64_t a,uint64_t b); 
uint64_t gcd3(uint64_t a,uint64_t b,uint64_t c); 
int main(void) {
    char buf[8];
    char *p;
    int N;
    int i,j,k,cnt = 0;
    uint64_t sum=0;

    p = fgets(buf, 8, stdin);
    N = atoi(buf);

    for(i=1;i<=N;i++){
        for(j=1;j<=N;j++){
            for(k=1;k<=N;k++){
                sum += gcd3(i,j,k);
            }
        }
    }

    printf("%lu\n", sum);

    return 0;
}

uint64_t gcd3(uint64_t a,uint64_t b,uint64_t c) {
    uint64_t ggg;
    if(a == 1 || b == 1 || c == 1){
    ggg = 1;
    } else {

    ggg= gcd(a,gcd(b,c));
    }

//    printf("%lu,%lu,%lu => %lu\n", a,b,c,ggg);
    return ggg;
}

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

    if(b > a) {
        return gcd(a, b%a);
    } else {
        return gcd(b, a%b);
    }
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define ll long long
#define ld long double
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)

#define xx first
#define yy second
#define mp make_pair
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define pdd pair<double,double>
#define ALL(v) (v).begin(), (v).end()

const ll MOD=1e9+7; ;
const ll inf=1e18;

#define MODSET(d) if ((d) >= MOD) d %= MOD;
#define MODNEGSET(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD;
#define put(x) cout<<#x<<" = "<<x<<endl;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

ll power(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a);
        n>>=1;
        a=(a*a);
    }
    return ans;
}


ll powerMod(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%MOD;
        n/=2;
        a=(a*a)%MOD;
    }
    return ans;
}

ll powerMod1(ll a,ll n,ll mod){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%mod;
        n>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

ll lcm(ll a,ll b){
    return a*(b/__gcd(a,b));
}

ll sumdigit(ll n){
    ll sum=0;
    while(n){
        sum+=n%10;
        n=n/10;
    }
    return sum;
}

ll countSetBit(ll a){
    return __builtin_popcount(a);
}
ll countBit(ll a){
    ll sum=0;
    while(a){
        sum++;
        a>>=1;
    }
    return sum;
}

ll length(ll a){
    ll ans=0;
    while(a){
        ans++;
        a=a/10;
    }
    return ans;
}

bool isVowel(char c){
	if(c=='a' or c=='e' or c=='i' or c=='o' or c=='u')
		return true;
	return false;
}

int main()
{
    fast;
    ll t;
    //cin>>t;
    t=1;
    while(t--){
          string a,b;
          cin>>a>>b;
          map<string,ll> m;
          ll aa,bb;
          cin>>aa>>bb;
          m[a]=aa;
          m[b]=bb;
          string temp;
          cin>>temp;
          m[temp]--;
          cout<<m[a]<<" "<<m[b];
    }
    return 0;
}


Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict
from sys import exit
import math


def main():
    n, m = getList()
    if n % 2 == 0:
        mx = (n-2) // 2
    else:
        mx = n // 2

    a,b,c,d = 1, 1+mx-1, n - mx, n
    diff = 0
    cnt = 0
    while(True):
        print(c+diff, d-diff)
        cnt += 1
        if cnt == m:
            return
        print(a+diff, b-diff)
        cnt += 1
        if cnt == m:
            return
        diff += 1
    # for i in range(m):
    #     print(i+1, n-i)

if __name__ == "__main__":
    main()

Measured memory_bytes: 69740
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int num[] = new int[100];
		for (int i = 0; i < 100; i++)
		{
			try
			{
				num[sc.nextInt()]++;
			}
			catch (Exception e)
			{
				break;
			}
		}
		int max = 0;
		for (int i = 0; i < 100; i++)
		{
			max = Math.max(max, num[i]);
		}
		for (int i = 0; i < 100; i++)
		{
			if (max == num[i])
				System.out.println(i);
		}
	}
}

Measured memory_bytes: 12000
{-# LANGUAGE BangPatterns #-}
 
module Main
  ( main
  )
where
 
import           Control.Applicative
import           Control.Monad
import           Control.Monad.ST
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import           Data.Ord
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import qualified Data.Vector.Unboxed           as UV

parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine

main = do
  [a, b, c] <- sort <$> readIntList
  putStrLn $ if (a == b && b /= c) || (a /= b && b == c) then "Yes" else "No"


Measured memory_bytes: 380
#include <iostream>
#include <algorithm>
#include <map>

int main() {

  int N;
  std::string s;
  std::map<std::string,int> mp;
  std::cin >> N;
  for (int i = 0; i<N; i++) {
    std::cin >> s;
    //    std::cout << i << "  " << s << std::endl;                                                                                                                                                                
    std::sort(s.begin(),s.end());
    //    std::cout << i << "  " << s << std::endl;                                                                                                                                                                
    mp[s]++;
  }

  static long long int ans = 0;
  for (auto& p: mp) {
    //    std::cout << p.first << " " << p.second << std::endl;                                                                                                                                                    
    ans += (long long int)p.second*(p.second-1)/2;
  }

  std::cout << ans << std::endl;

}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for(ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
 
 
 
ll power(ll b,ll e,ll m)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
}


void solve()
{
  ll n;
  cin>>n;
  vpi v;
  rep(i,0,n)
  {
    ll a,b;
    cin>>a>>b;
    v.pb({a,b});
  }
  ll x=v[0].fr,y=v[0].sc;
  rep(i,1,n)
  {
    ll a=v[i].fr;
    ll b=v[i].sc;
    if(a>=x and b>=y)
    {
      x=a;
      y=b;
    }
    else
    {
      ll p=x/a;
      if(x%a) p++;
      ll q=y/b;
      if(y%b) q++;
      ll mx=max(p,q);
      x=a*mx;
      y=b*mx;
    }
    // cout<<x<<" "y<<"\n";
  }
  cout<<x+y;
}

int main()
{
  ll tt=1;
  // cin>>tt;
  while(tt--)
  {
    solve();
    cout<<"\n";
  }
}

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

namespace AOJV0
{
    public class P0001
    {
        public static void Main()
        {
            foreach(var i in Enumerable.Range(0,10)
                                       .Select(_ => Console.ReadLine())
                                       .Select(int.Parse)
                                       .OrderByDescending(x => x)
                                       .Take(3))
                Console.WriteLine(i);
        }
    }
}

Measured memory_bytes: 6404
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long ll;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
using namespace std;
int main(int argc, char const *argv[]) {
  int n,x=0,cnt=0,a,t=0,m;
  	cin>>n>>x;
  	m=x;
  	REP(i,n){
  		cin>>a;
  		t+=a;
  		m=min(a,m);
  	}
  	x-=t;
  	cnt=x/m;
  	cnt=n+cnt;
  	cout<<cnt;
  return 0;
}


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

#define Rep(j,n) for(int j=0;j<(int)(n);++j)

#define int long long

using namespace std;

signed main()
{
int x=0,y=0,z=0,w=0,i=0,j=0,n=0,L=0,W=0;
std::cin >> x>>y;
string xyz ="";
std::cout  <<((x%(y*2+1)==0)?x/(y*2+1):x/(y*2+1)+1)<< '\n';

}


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

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

  int a, b, c;
  cin >> a >> b >> c;

  cout << max({a,b,c})-min({a,b,c});
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int sum = 0;
  for(int i = 100000000; i >= 1; i /= 10) {
    sum += N / i % 10;
  }
  
  if(N % sum == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <deque>
#include <valarray>
#include <unordered_map>
#include <unordered_set>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define PB push_back
#define MP make_pair
#define PF first
#define PS second
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
#define OUT(x) cout << x << endl;
#define OUTD(x) cout << fixed << x << endl;
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 1000000007;
const ll INF = 10e9;
const ld PI = 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};

unsigned GetDigit(unsigned num){
    return std::to_string(num).length();
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  IN(ll,A);
  IN(ll,B);
  cout << A*B << " " << 2*A + 2*B << endl;
}


Measured memory_bytes: 3120
#include <iostream>
#include<algorithm>
#include<vector> //動的配列
#include<string> 
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <cmath>



typedef long long ll;


using namespace std;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}


int n;

int main(){
    cin>>n;
    if (n%2==1){
        cout<<(n-1)*(n-1)/2<<endl;
        for (int i=1;i<n;i++){
            for (int j=i+1;j<n+1;j++){
                if (j!=n-i){
                    cout<<i<<" "<<j<<endl;
                }
            }
        }
    } else {
        cout<<n*(n-2)/2<<endl;
        for (int i=1;i<n;i++){
            for (int j=i+1;j<=n;j++){
            if (j!=n+1-i){
                cout<<i<<" "<<j<<endl;
                }
            }
        }
    }
}

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

using namespace std;

#define ll unsigned long long

void solve(){

    int n; cin >> n;
    ll xr = 0;
    ll arr[n];
    for(int i = 0; i < n; ++i){
        cin >> arr[i];
        xr ^= arr[i];
    }
    for(int i = 0; i < n; ++i) cout << (xr ^ arr[i]) << " ";

}


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

	return 0;
}



Measured memory_bytes: 5184
#include<bits/stdc++.h>
using namespace std;
#define LL long long
int N;
int main(){
	cin>>N;
	LL ans = 0;
	for (int i=1; i<=N; i++) ans += 1LL*i*(N-i+1); 
	for (int i=1; i<=N-1; i++){
		int u,v; cin>>u>>v;
		if (u>v) swap(u,v);
		ans -= 1LL*u*(N-v+1);
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 3728
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function () { return this.index < this.max },
        "next": function () { if (!this.hasNext()) { throw "ArrayIndexOutOfBoundsException"; } else { return this.list[this.index++]; } }
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let s = next()
    let cnt1 = 0
    let cnt0 = 0
    for(let i = 0; i<s.length;i++){
        if(s[i] == '0') cnt0++
        if(s[i]== '1') cnt1++
    }
    console.log(2*Math.min(cnt1, cnt0))
}
Main()



Measured memory_bytes: 32412
#include <bits/stdc++.h>
using namespace std;
#define int long long 
using ldb = long double;
using pa = pair < int, int >;
#define F  first
#define S  second
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7, N = 5e5 + 10;
const int LINF = LLONG_MAX;

int a,b,c,sum;
string s1,s2,s;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> s;
    if(s[2] == s[3] and s[4]==s[5]){
        cout << "Yes\n";
    }
    else
        cout << "No\n";
    return 0;
}
 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define rep(i, n)for(int i=0; i<n; i++)
using ll = long long int;
using namespace std;

int main(){
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i, s.size()){
        if(s[i]!=t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3856
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

int N;
vector<long long> A;
int main() {
    while (cin >> N) {
        A.resize(N); for (int i = 0; i < N; ++i) cin >> A[i];
        int res = 0;
        int updown = 0;
        for (int i = 1; i < N; ++i) {
            if (updown == 1) { if (A[i] < A[i-1]) ++res, updown = 0; }
            else if (updown == -1) { if (A[i] > A[i-1]) ++res, updown = 0; }
            else {
                if (A[i] > A[i-1]) updown = 1;
                else if (A[i] < A[i-1]) updown = -1;
            }
        }
        cout << res+1 << endl;
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
//cout << fixed << setprecision(20) << *** << endl;
#define rep(i,N) for(int i=0;i<(int)N;++i)
typedef long long ll;
using namespace std;
int main()
{
	ll N=0,S=0,E=0,W=0;
	string s;
	cin>>s;
	rep(i,s.size()){
		if(s[i]=='N')N=1;
		if(s[i]=='S')S=1;
		if(s[i]=='E')E=1;
		if(s[i]=='W')W=1;
	}
	if((N==1&&S==0)||(N==0&&S==1)){
		cout<<"No"<<endl;
		return 0;
	}
	if((E==1&&W==0)||(E==0&&W==1)){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using Pa = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

class UnionFind{
private:
    vector<int> p,s;
	int cnt;
public:
	UnionFind(){}
	UnionFind(int N):cnt(N),s(N,1),p(N){
        iota(p.begin(),p.end(),0);
	}
	int find(int x){
		if(p[x]==x) return x;
		else return p[x] = find(p[x]);
	}
	void unite(int x,int y){
		x = find(x); y = find(y);
		if(x==y) return;
		if(s[x]>s[y]) swap(x,y);
		p[x] = y;
		s[y] += s[x];
		cnt--;
	}
	bool is_same_set(int x,int y) {return find(x)==find(y);}
	int size(int x) {return s[find(x)];}
	int compnents_number(){return cnt;}
};

int N,K,L,p,q,r,s;
int main(){
    cin >> N >> K >> L;
    UnionFind uf1(N),uf2(N);
    for(int i=0;i<K;i++){
        cin >> p >> q;
		p--; q--;
        uf1.unite(p,q);
    }
    for(int i=0;i<L;i++){
        cin >> r >> s;
		r--; s--;
        uf2.unite(r,s);
    }
    map<pair<int,int>,int> m;
    for(int i=0;i<N;i++){
        m[{uf1.find(i),uf2.find(i)}]++;
    }
    for(int i=0;i<N;i++){
        cout << m[{uf1.find(i),uf2.find(i)}] << (i!=N? " ":"\n");
    }
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall
	
	ini(n);
	vi morty;
	FOR(i,0,n){
		ini(x);
		morty.push_back(x);
	}
	sort(all(morty));
	int pos = 0;
	FOR(i,0,n-1){
		if(abs(morty[n-1]-2*morty[i])<abs(morty[n-1]-2*morty[pos]))pos = i;
	}
	out(morty[n-1],morty[pos]);













	return 0;
}

Measured memory_bytes: 1400
ABC = []
for i in range(3):
    ABC.append(input())
pl_list = {0: 'A', 1: 'B', 2: 'C'}

pl = 0
while True:
    if ABC[pl] == '':
        print(pl_list[pl])
        exit()
    plcard = ABC[pl][0]
    string = ABC[pl]
    string = list(string)
    string = string[1:]
    string = ''.join(string)
    ABC[pl] = string

    if plcard == 'a':
        pl = 0
    elif plcard == 'b':
        pl = 1
    else:
        pl = 2


Measured memory_bytes: 3064
h, w = map(int, input().split())

if h == 1 or w == 1:
    ans = 1
elif w % 2 == 0:
    ans = w // 2 * h
else:
    if h % 2 == 0:
        ans = h//2 * w
    else:
        ans = (h//2 + 1)*(w//2 + 1) + (h//2)*(w//2)

print(ans)


Measured memory_bytes: 38384
import java.lang.Math.max
import java.util.*

fun <T> T.also(func:T.() -> Unit):T {
    this.func()
    return this
}
fun main(args:Array<String>):Unit {
    val (_, _, n) = readLine()!!.split(' ').map(String::toInt)
    val enemies = Stack<Enemy>().also{
        push(Enemy(0, 0))
        repeat(n){
            val (x, y) = readLine()!!.split(' ').map(String::toInt)
            push(Enemy(x, y))
        }
    }.sortedBy(Enemy::x).toTypedArray()
    val maxY = Array(n + 1){0}
    for (i in (n - 1) downTo 0){
        maxY[i] = max(maxY[i + 1], enemies[i + 1].y)
    }
    println(enemies.mapIndexed{index, enemy -> enemy.x + maxY[index]}.min())
}
data class Enemy(val x:Int, val y:Int)


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

int main(void)
{
	char s[3];
	scanf("%s",s);
	int i,sum=700;
	for(i=0;i<=2;i++)
		{if(s[i]=='o'){sum+=100;}}
	printf("%d",sum);

	return 0;
}


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

int main() {
  int A;
  cin >> A;
  int B;
  cin >> B;
  int C;
  int D = B;
  for(int i = 0;i < A - 2;i++){
    cin >> C;
    D = D + min(B, C);
    B = C;
  }
  cout << B + D << endl;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> vec(3);
    REP(i,3)cin >> vec.at(i);
    sort(vec.begin(),vec.end());
    cout << vec[0] <<" " << vec[1]<<" "<<vec[2];
    cout << endl;
    }


Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef vector<int> vec;
//配列の添字ズレに注意
int main(){
  string a,b,c; cin>>a>>b;
  int n=a.length();
  c=b.substr(0,n);
  
  cout<< (a==c?"Yes":"No")<<endl;
}


Measured memory_bytes: 3604
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(n)-1,i##_len=(int)(s);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	int al = 1, ar = n;

	REP(i, m) {
		int l, r;
		scanf("%d%d", &l,&r);

		al = Max(al, l);
		ar = Min(ar, r);
	}

	if (al <= ar) {
		PRINTD(ar - al + 1);
	}
	else {
		PRINTD(0);
	}
}


Measured memory_bytes: 128
def primes(max_number):
    if max_number <= 2:
        raise StopIteration
    yield 2
    is_prime = [1] * max_number
    square_root_of_max = max_number ** 0.5
    for number in range(3, max_number, 2):
        if is_prime[number] is 0:
            continue
        yield number
        if number <= square_root_of_max:
            for multiple in range(number * 2, max_number, number):
                is_prime[multiple] = 0


P = list(primes(100000))
A = [0]*100002
for p in P:
    if (p+1)//2 in P:
        A[p] += 1
from itertools import accumulate as acc
A = list(acc(A))

q = int(input())
Q = [list(map(int,input().split())) for _ in range(q)]
for i in range(q):
    print(A[Q[i][1]]-A[Q[i][0]-1])


Measured memory_bytes: 31632
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define loope(i,a,b) for(ll i=a;i<=b;i++)
#define test() ull t;cin>>t;while(t--)
#define f first
#define s second
#define pb push_back
#define mkp make_pair
#define ins insert
#define nl cout<<endl
#define P 1000000007
#define MOD(x) ((x%P)+P)%P
#define NMAX 100100

#define INF 100000000
int mod=1e9;

int main() 
{


    string a,b;
    cin>>a>>b;

    int l1 = a.length();
    int l2 = b.length();


    int dp[l1+1][l2+1];

    string s="";
    for(int i=0;i<=l1;i++)
    {
        for(int j=0;j<=l2;j++)
        {

            if(i ==0 || j==0)
                dp[i][j] = 0;
            else if(a[i-1] == b[j-1])
            {
                dp[i][j] = max(1+dp[i-1][j-1],max(dp[i-1][j],dp[i][j-1]));
                
            }
            else
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);

            //cout<<dp[i][j]<<" ";
        }
        //cout<<endl;
    }

    int i =l1,j=l2;

    while(i>0 && j>0)
    {
        if(a[i-1] == b[j-1])
        {
            s = a[i-1] + s;
            i--;
            j--;
        }
        else if(dp[i][j] == dp[i][j-1])
            j--;
        else
            i--;
    }

    cout<<s;

	return 0;
    	
}

















Measured memory_bytes: 35456
N = int(input())
a_list = list(map(int, input().split()))

result = [0] * N
for i in range(N):
    result[0] += a_list[i] * (1 if i % 2 == 0 else -1)

for i in range(1, N):
    result[i] = 2 * a_list[i-1] - result[i-1]

print(' '.join(map(str, result)))


Measured memory_bytes: 19096
#include <bits/stdc++.h>
using namespace std;
int main(){
    int H,W,i,j;
    cin>>H>>W;
    vector<string> M(H);
    for(i=0;i<H;i++) cin>>M.at(i);
    for(i=0;i<W;i++){
        for(j=0;j<H;j++)
            if(M.at(j).at(i)=='#') goto loop_1;
        for(j=0;j<H;j++)
            M.at(j).erase(i,1);
        W--;
        i--;
        loop_1:;
    }
    for(i=0;i<H;i++){
        for(j=0;j<W;j++)
            if(M.at(i).at(j)=='#') goto out;
        goto noout;
        out: cout<<M.at(i)<<endl;
        noout:;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(a) a.begin(),a.end()
int main()
{
    int A,B;
    cin >> A >> B;
    cout << (6-A-B) << endl;
    return 0;
}

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

int A[100005],DP[100005];
int main() {
	int n;
	cin>>n;
	for(int i=0; i<n; i++) cin>>A[i];
	DP[0]=0;
	DP[1]=abs(A[1]-A[0]);
	for(int i=2;i<n;i++){
		DP[i]= min(DP[i-2] + abs(A[i-2]-A[i]), DP[i-1] + abs(A[i-1]-A[i]) );
	}	
	cout<<DP[n-1];
		
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890
#define de(x) if(x==MODE && x!=0)

#define MODE 1

using namespace std;

int N;
LLI K;
LLI A[1000007];
LLI F[1000007];
LLI arr[1000007];

LLI bs( LLI L, LLI R)
{
//    printf("( %lld, %lld)\n", L, R);

    int i,j;

    if( L==R)
        return L;

    LLI M = (L+R)/2;

    for( i=0; i<N; i++)
        arr[i] = M/F[i];
    sort( arr, arr+N);
    LLI total = 0;
    for( i=0; i<N; i++)
    {
//        printf("%lld ", A[i]-arr[i]);
        total += max( 0LL, A[i]-arr[i]);
    }
//    printf("\n");

//    printf("M = %lld >>>%lld\n", M, total);
//    system("PAUSE");
    if( total <= K)
        return bs(   L, M);
    else
        return bs( M+1, R);
}

int main()
{
    int i,j;


    scanf("%d %lld", &N, &K);
    for( i=0; i<N; i++)
        scanf("%lld", &A[i]);
    for( i=0; i<N; i++)
        scanf("%lld", &F[i]);

    sort( A, A+N);
    sort( F, F+N);
//    de(1) printf("test\n");
    LLI ans = bs( 0, 1000000000000000);
    printf("%lld\n", ans);


    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

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

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    string x,y; cin >> x >> y;

    F0R(i, min(sz(x),sz(y))) {
        cout << x[i] << y[i];
    }

    if (sz(x) == sz(y)) return 0;

    if (sz(x) > sz(y)) {
        cout << x[sz(x)-1];
    } else {
        cout << y[sz(y)-1];
    }

}


Measured memory_bytes: 256
loop{
  input = gets
  n = input.chomp.to_i
  break if n == 0
  sumA = sumB = 0;
  n.times do
    a,b = gets.split(" ").map(&:to_i)
    a >= b ? a > b ? sumA += (a+b) : (sumA += a; sumB += b) : sumB += (a+b)
  end
  puts "#{sumA} #{sumB}"
}


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

int main() {
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ac = a*c;
    ll ad = a*d;
    ll bc = b*c;
    ll bd = b*d;
    vector<ll> all;
    all = {ac, ad, bc, bd};
    ll res = -1000000000000000000;
    rep(i,4) {
        if (all.at(i) > res) res = all.at(i);
    }
    cout << res << endl;
    return 0;
}

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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

int main() {

  int a , b ;
  string str ;
  cin >> a >> b ;
  cin >> str ;
  if( a + b + 1 != sz( str ) ){
    cout << "No\n" ;
    return 0 ;
  }

  vector < int > pos ;
  forn( int , i , 0 , sz( str ) ) {
    if( str[ i ] == '-' ) pos.pb( i ) ;
  }

  if( sz( pos ) == 1 && pos.back() + 1 == a + 1 ){
    cout << "Yes\n" ;
  } else cout << "No\n" ;

  return 0 ;;;;;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9+7;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n, m, r; cin >> n >> m >> r;
  vll rr(r);
  REP(i, r) cin >> rr.at(i);
  sort(rr.begin(), rr.end());
  vvll graph(n, vll(n, HIGHINF));
  REP(i, n) graph.at(i).at(i) = 0;
  REP(i, m) {
    ll a, b, c; cin >> a >> b >> c;
    graph.at(a-1).at(b-1) = c;
    graph.at(b-1).at(a-1) = c;
  }
  REP(k, n) REP(j, n) REP(i, n) {
    if (graph.at(i).at(j) > graph.at(i).at(k) + graph.at(k).at(j))
      graph.at(i).at(j) = graph.at(i).at(k) + graph.at(k).at(j);
  }
  ll ans = HIGHINF;
  do {
    ll tmp = 0;
    rep(i, 1, r) tmp += graph.at(rr.at(i-1)-1).at(rr.at(i)-1);
    ans = min(tmp, ans);
  } while(next_permutation(rr.begin(), rr.end()));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	vector<int>X(M);
	int ans = 0;
	for (int i = 0; i < M; i++)
	{
		cin >> X[i];
	}
	if (M == 1) {
		cout << 0 << endl;
		return 0;
	}
	else {
		sort(X.begin(), X.end());
		int tmp = X[M-1] - X[0];
		int M_diff = 0;
		vector<int>diff(M);
		for (int i = 1; i < M; i++)
		{
			diff[i] = X[i] - X[i - 1];
		}
		int diffsum = 0;
		sort(diff.rbegin(), diff.rend());
		for (int i = N - 1; i < M; i++)
		{
			diffsum += diff[i];
		}
		cout << diffsum << endl;
	}

	return 0;
}

Measured memory_bytes: 1024
import collections 

def main():
	cnt = collections.Counter()

	n, m = list(map(int,input().split()))
	xs = [0] + list(map(int,input().split()))
	#print(xs)
	cum = 0
	for x in xs:
		cum = (cum + x) % m 
		cnt[cum] += 1

	ans = 0
	for k in cnt:
		ans += cnt[k] * (cnt[k] - 1) / 2

	print(int(ans))	

if __name__ == '__main__':
	main()

Measured memory_bytes: 14920
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  ll x, y;
  cin >> s >> x >> y;
  s.push_back('T');
  vl a, b;
  ll cnt = 0;
  bool t = false;
  rep(i, s.size()) {
    if(s[i] == 'F')
      cnt++;
    else {
      if(t)
        b.push_back(cnt);
      else
        a.push_back(cnt);
      cnt = 0;
      t = !t;
    }
  }
  bool ans = true;
  ll geta = 8010;
  rep(q, 2) {
    ll n = a.size();
    bool dp[n + 1][16020] = {};
    rep(i, n + 1) rep(j, 16020) dp[i][j] = false;
    dp[0][geta] = true;
    rep(i, n) rep(j, 16020) {
      if(!dp[i][j]) continue;
      dp[i + 1][j + a[i]] = true;
      if(q == 1 || i != 0) dp[i + 1][j - a[i]] = true;
    }
    if(!dp[n][x + geta]) ans = false;
    swap(x, y);
    swap(a, b);
  }
  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 65804
#include <bits/stdc++.h>
using namespace std;
 
#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
 
#define ll long long
 
#define pq(name,type) priority_queue<type> name
#define vec(name,type,length,value) vector<type> name(length,value)
#define vec2(name,type,length,width,value) vector<vector<type>> name(length,vector<type>(width,value));
 
int main(){
	ll N;
  cin >> N;
  vector<ll> p(N);
  ll sum = 0,t = 0;
  froop1(0,N){
    cin >> p.at(i);
    t = t + p.at(i);
    if(i != 0) sum += ((t - p.at(i))%1000000007LL)*p.at(i);
    sum %= 1000000007LL;
  }
  cout << sum << endl;
    
return 0;
}

Measured memory_bytes: 4812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#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)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int D = in(),N = in();
    if(N == 100){
        cout << N+1;
        REP(i,D)cout << "00";
        cout << "\n";
    }else{
        cout << N;
        REP(i,D)cout << "00";
        cout << "\n";
    }
}

Measured memory_bytes: 256
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
li=[]
ans=[]
for i in range (n):
    ans.append(t-h[i] * 0.006)
    li.append(abs(ans[i]-a))
print(li.index(min(li))+1)

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

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

    // 入力
    string s;
    cin >> s;

    // 処理
    // 出力
    cout << (s[0] == '9' || s[1] == '9' ? "Yes " : "No") << endl;

    return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

ll gain(ll x) {
	return 4 - min(4LL,x);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll x, y;
	cin >> x >> y;

	ll res = gain(x) + gain(y);
	if (x == 1 && y == 1) res += 4;
	res *= 1e5;
	cout << res << endl;
}



Measured memory_bytes: 256
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl

int main(){
    int n,m,c;cin >> n >> m >> c;
    vector<int>b(m);
    rep(i,m)cin >> b[i];
    vector<vector<int>>a(n,vector<int>(m));
    rep(i,n){
        rep(j,m){
            cin >> a[i][j];
        }
    }
    int cnt=0;
    int ans=0;
    rep(i,n){
        ans=0;
        rep(j,m){
            ans+=a[i][j]*b[j];
        }
        ans+=c;
        if(ans>0)cnt++;
    }
    out(cnt);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	string S;
	cin >> N >> S;
	vector<int> id(2*N);
	int a = 0, id_cur = 0;
	for(int i = 0; i < 2*N; i++) if(S[i] == 'b') {
		while(S[a] == 'b') a++;
		id[i] = id[a] = id_cur;
		id_cur++;
		a++;
	}
	vector<int> p(2*N);
	for(int i = 0; i < 2*N; i++) for(int j = 0; j < i; j++) if(id[j] == id[i]) {
		p[i] = j;
		p[j] = i;
		break;
	}
	vector<string> ans(2*N+1, "");
	for(int i = 2*N-1; i >= 0; i--) {
		ans[i] = ans[i+1];
		if(p[i] < i) continue;
		if(S[i] == 'a') {
			ans[i] = max(ans[i], "ab" + ans[p[i]+1]);
			continue;
		}
		int cnt = 0, mina = 2*N;
		for(int j = i; j < mina; j++) if(p[j] >= i)
			if(S[j] == 'b') {
				cnt++;
				mina = min(mina, p[j]);
			}
		string s_cur = "";
		vector<int> used_id(N, 0);
		int maxa = 0;
		int curj = i;
		for(int j = i; j < 2*N; j++) if(S[j] == 'b' && p[j] >= i) {
			s_cur += 'b';
			used_id[id[j]] = 1;
			cnt--;
			maxa = p[j];
			curj = j+1;
			if(cnt == 0) break;
		}
		for(int j = i; j < curj; j++) if(S[j] == 'a' && used_id[id[j]])
			s_cur += S[j];
		while(curj <= maxa) {
			if(p[curj] < i) {
				curj++;
				continue;
			}
			if(used_id[id[curj]]) { // 'a'
				s_cur += S[curj];
				curj++;
				continue;
			}
			// 'b'
			s_cur += S[curj];
			used_id[id[curj]] = 1;
			maxa = max(maxa, p[curj]);
			curj++;
		}
		ans[i] = max(ans[i], s_cur + ans[curj]);
	}
	cout << ans[0] << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 14464