akhauriyash/Code-Regression huggingface dataset:
import sys

def L(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI():return list(map(int,sys.stdin.readline().rstrip().split()))
def LS():return list(sys.stdin.readline().rstrip().split())

import collections

def solver(S,T):

    ans = 0
    for i, c in enumerate(S):
        if c != T[i]:
            ans +=1
    print(ans)



def main():
    S = L()
    T = L()

    solver(S,T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 68668
a,b=map(int,input().split())
ad=[]
bd=[]
cd=[]
ifa=a
ifb=b
for i in range(40):
    ad+=[a%2]
    a=a//2
for i in range(40):
    bd+=[b%2]
    b=b//2
a=ifa
b=ifb
z=1
for i in range(40):
    z=z*2
    ak=0
    bk=0
    if(ad[i]!=0):
        ak=z-a%z
    if(bd[i]!=0):
        bk=b%z+1-z//2
    cd+=[(ak+bk)%2]
if((a-b+1)%2==0):
    cd[0]=((b-a+1)//2)%2
else:
    cd[0]=(((b-a+1)//2)%2+ad[0])%2
ans=0
z=1
for i in range(40):
    ans+=cd[i]*z
    z=z*2
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int n,m,d,x,y,a[101010][2],ans[100100],q;
int main()
{
	scanf("%d%d%d",&n,&m,&d);
	for(int i=1;i<=n;i++)
	 for(int j=1;j<=m;j++)
	 {
	 	scanf("%d",&x);
	 	a[x][0]=i;
	 	a[x][1]=j;
	 }
	for(int i=1;i<=d;i++)
	 	for(int j=i+d;j<=n*m;j+=d)
		ans[j]=ans[j-d]+abs(a[j][0]-a[j-d][0])+abs(a[j][1]-a[j-d][1]);
	scanf("%d",&q);
	for(int i=1;i<=q;i++)
	{
		scanf("%d%d",&x,&y);
		printf("%d\n",ans[y]-ans[x]);
	}
	return 0;
}


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

#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define ll long long 

int main(){
        IOS;
        ll n;
        cin>> n;
        ll a[n];
        for(ll i=0;i<n;i++) cin>>a[i];
        ll ans=0;
        for(ll i=0;i<n;i++){
                for(ll j=i+1;j<n;j++){
                        for(ll k=j+1;k<n;k++){
                                ll x=a[i],y=a[j],z=a[k];
                                ll b[3]={x,y,z};
                                sort(b,b+3);
                                if(b[0]+b[1]>b[2] && b[0]!=b[1] && b[1]!=b[2]) {
                                        ans++;
                                }
                        }
                }
        }
        cout<<ans<<"\n";
}


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

signed main(){
	int N; cin>>N;
	int ans=0;
	for(int i=0;i<=N;i++){
		if(i%3!=0 and i%5!=0)ans+=i;
	}
	cout<<ans<<endl;
}

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

int main() {
  string S,T;
  cin >> S >> T;
  bool a = true;
  for (int i=0; i<S.size(); i++) {
    if (S[i] != T[i]) {
      a = false;
    }
  }
  if (a) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int const MOD = 1e9+7;

int main() {
  int N; cin >> N;
  string S; cin >> S;
  vector<int> c(26);
  ll sum = 0;
  rep(i, N) {
    const int sel_idx = S[i] - 'a';
    c[sel_idx]++;
    ll s = 1;
    rep(k, 26) if (k != sel_idx) {
      (s *= c[k] + 1) %= MOD;
    }
    (sum += s) %= MOD;
  }
  cout << sum << endl;
}


Measured memory_bytes: 512
import java.io.*;import java.util.*;class Main{public static void main(String[] args) throws IOException{BufferedReader br=new BufferedReader(new InputStreamReader(System.in));int[] k=new int[10];for(int i=0;i<10;i++)k[i]=Integer.parseInt(br.readLine());Arrays.sort(k);for(int i=0;i<3;i++)System.out.println(k[9-i]);}}

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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        char[] s = sc.next().toCharArray();

        if (s[2] == s[3] && s[4] == s[5])
            System.out.println("Yes");
        else
            System.out.println("No");
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 22996
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.*;


public class Main{
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		ArrayList<Pair> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			list.add(new Pair(sc.nextLong(), sc.nextLong()));
		}
		Collections.sort(list, new ComparatorByKey());
		int remove = 0;
		for (int i = 0; i < list.size() - 1; i++) {
			Pair a = list.get(i);
			Pair b = list.get(i + 1);
			if (a.key + a.value > b.key - b.value) {
				if (a.key + a.value > b.key + b.value) {
					list.remove(i);
					remove++;
				} else {
					list.remove(i + 1);
					remove++;
				}
				i--;
			}
		}
		System.out.println(n - remove);
	}
}

class Pair {
	public long key;
	public long value;
	public Pair(long key, long value) {
		this.key = key;
		this.value = value;
	}
}

class ComparatorByValue implements Comparator<Pair> {
	@Override
	public int compare(Pair sort1, Pair sort2) {
		if (sort1.value == sort2.value) {
			return 0;
		} else if (sort1.value > sort2.value) {
			return 1;
		} else {
			return -1;
		}
	}
}

class ComparatorByKey implements Comparator<Pair> {
	@Override
	public int compare(Pair sort1, Pair sort2) {
		if (sort1.key == sort2.key) {
			return 0;
		} else if (sort1.key > sort2.key) {
			return 1;
		} else {
			return -1;
		}
	}
}



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


Measured memory_bytes: 28032
#include <stdio.h>

int main(void) {
  int n, v;
  int a[1000];
  int i, j, k;

  scanf("%d", &n);

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

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

    v = a[i];
    j = i - 1;
    while (j >= 0 && a[j] > v) {
      a[j + 1] = a[j];
      j--;
    }
    a[j + 1] = v;
  }

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

Measured memory_bytes: 604
n = int(input())
aSum = 0
abSum = 0
bMin = float('inf')

for i in range(n):
    a, b = list(map(int, input().split()))

    abSum += a
    if a > b:
        bMin = min(bMin, b)
    else:
        aSum += a

if aSum == abSum:
    print(0)
else:
    print(abSum - bMin)


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

using namespace std;
struct ura
{
    int t,x,y;
};
ura v[100001];
int main()
{
    int n,x0=0,y0=0,t0=0,z,ok=0,i;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>v[i].t>>v[i].x>>v[i].y;
        z=abs(v[i].x-x0)+abs(v[i].y-y0);
        if((v[i].t-t0)%2!=z%2||z>v[i].t-t0)
        {
            ok=1;
            i=n+1;
        }
        x0=v[i].x;y0=v[i].y;t0=v[i].t;
    }
    if(ok==1)
    {
        cout<<"No";
    }
    else
        cout<<"Yes";
    return 0;
}


Measured memory_bytes: 1408
def resolve():
    (N, M) = list(map(int,input().split(" ")))
    cities = [list(map(int, input().split(" "))) + [i] for i in range(M)]
    sorted_cities = sorted(cities, key=lambda x: (x[0], x[1]))

    pref = 0
    cnt = 0
    for city in sorted_cities:
        if pref != city[0]:
            pref = city[0]
            cnt = 0
        cnt = cnt + 1
        city.append("{:06d}{:06d}".format(pref, cnt))
    
    sorted_cities = sorted(cities, key=lambda x: x[2])
    for city in sorted_cities:
        print(city[3])
        

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 36036
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
	int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

const int MAXN = 1e5;
int n, a[MAXN + 5], b[MAXN + 5];

int main() {
	read(n);
	for (int i = 1; i <= n; ++i) {
		read(a[i]);
		b[a[i]] = i;
	}
	for (int i = 1; i <= n; ++i) {
		write(b[i]);
		putchar(' ');
	}
	putchar('\n');
	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
    string s;
    cin >> s;
    int i;
    bool ch[26]={false};
    for(i=0;i<s.size();i++){
        ch[s[i]-'a']=true;
    }
    bool ch1=true;
    char c='a';
    for(i=0;i<26;i++){
        if(ch[i]==false){
            c+=i;
            cout << c << endl;
            ch1=false;
            break;
        }
    }
    if(ch1){
        cout << "None" << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

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

    string s;
    string a = "abcdefghijklmnopqrstuvwxyz";
    getline(cin, s);
    for (auto &c: a) {
        auto p = s.find(c);
        if (p == basic_string<string>::npos) {
            cout << c << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        ll c=0;
        while(a[i]%2==0)
        {
            c++;
            a[i]/=2;
        }    
        ans+=c;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

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

        final String s = sc.next();
        final char[] c = s.toCharArray();

        if (c[2] == c[3] && c[4] == c[5]) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23892
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, W: int, w: "List[int]", v: "List[int]"):
    dp = [[0] * (W + 1) for _ in range(N + 1)]

    for i, (cw, cv) in enumerate(zip(w, v)):
        for j in range(W + 1):
            dp[i+1][j] = dp[i][j]
            if 0 <= j - cw :
                dp[i+1][j] = max(dp[i+1][j], dp[i][j - cw] + cv)
    return max(dp[-1])


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    w = [int()] * (N)  # type: "List[int]"
    v = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        w[i] = int(next(tokens))
        v[i] = int(next(tokens))
    result = solve(N, W, w, v)
    print(result)

if __name__ == '__main__':
    main()

Measured memory_bytes: 124540
#include<iostream>
using namespace std;
typedef long long ll;
ll p,q,a,n,an;

void dfs(ll d,ll s,ll t,ll k,ll j){
  if(d>n||s*q>p*k)return;
  if(s*q==p*k){an++;return;}
  for(int i=j;t*i<=a;i++){
    dfs(d+1,s*i+k,t*i,k*i,i);
  }
}

int main(){
  while(cin>>p>>q>>a>>n&&n){
    an=0;
    dfs(0,0,1,1,1);
    cout<<an<<endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int sum_of_digits(int n)
{
    int sum = 0;
    while(n)
    {
        sum += n%10;
        n /= 10;
    }
    return sum;
}

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

    int sum = 0;
    for(int i=1; i<=n; i++)
    {
        int temp = sum_of_digits(i);
        if(temp >= l && temp <= r)
            sum += i;
    }

    printf("%d", sum);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    int sum=0;
    REP(i,n){
        cin >> a[i];
        sum+=a[i];
    }
    sort(RALL(a));
    double t=(double)sum/4/(double)m;
    REP(i,m){
        if(a[i]<t){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";

    return 0;
}

Measured memory_bytes: 3592
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int A,B,C,X,Y;
    scanf("%d %d %d %d %d",&A,&B,&C,&X,&Y);

    int sum=0;
    if(A+B<2*C){
        sum=A*X+B*Y;
    }
    else{
        if(X<=Y){
            sum=2*C*X;
            if(B<2*C){
                sum+=(Y-X)*B;
            }
            else{
                sum+=2*(Y-X)*C;
            }
        }
        else{
            sum=2*C*Y;
            if(A<2*C){
                sum+=(X-Y)*A;
            }
            else{
                sum+=2*(Y-X)*C;
            }
        }
    }

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

    return 0;
}

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

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


int main(){
  string a,b;
  cin >> a >> b ;
  if(a==b)cout << "H" << endl;
  else cout << "D" << endl;
}


Measured memory_bytes: 256
s = int(input())
t = [s]
count = 1
while t.count(s)<2 :
  if s%2==0:
    s = s/2
    t.append(s)
    count += 1
  else:
    s = 3*s+1
    t.append(s)
    count += 1
else:
  print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll h,n;
  cin>>h>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  ll k=0;
  rep(i,n){
    k+=a[i];
  }
  if(k>=h){
    COUT("Yes");
  }
  else COUT("No");
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();

        int sumn = 0;
        int i;
        for (i = 0; i < n; i++ ){
            sumn += i;
        }

        int summ = 0;
        int j;
        for (j = 0; j < m; j++){
            summ += j;
        }
        System.out.println(sumn + summ);
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

int main()
{

    int x, a;
    cin >> x >> a;
    int ans;
    (x < a) ? ans = 0 : ans = 10;
    cout << ans << endl;
}


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

#define rep(i, j, n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define Puts(x) puts(x? "Yes":"No")
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(int n, int m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(int n, int m) {return (n / gcd(n, m) * m);}
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[] = {1, 0, -1, 0, 1, -1, 1, -1};

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

  int n, m, q;
  cin >> n >> m >> q;

  vvt<int> imos(n + 1, vt<int>(n + 1, 0));
  rep(i, 0, m) {
    int l, r;
    cin >> l >> r;
    rep(j, 1, l + 1) imos[j][r]++;
  }

  rep(i, 1, n + 1) {
    rep(j, 1, n + 1) {
      imos[i][j] += imos[i][j - 1];
    }
  }

  rep(i, 0, q) {
    int l, r;
    cin >> l >> r;
    cout << imos[l][r] << endl;
  }
}


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;

int main(){
    deque<char> d;
    string s;
    cin >> s;
    int q;
    cin >> q;
    for(char c: s){
        d.push_back(c);
    }
    int sgn = 1;
    for(int i = 0; i < q; i++){
        int t;
        cin >> t;
        if(t==1){
            sgn *= -1;
        }else{
            int f;
            char c;
            cin >> f >> c;
            if(f==2){ f= -1;}
            if(sgn*f==1){
                d.push_front(c);
            }else{
                d.push_back(c);
            }
        }
    }
    if(sgn == 1){
        while(!d.empty()){
            cout << d.front();
            d.pop_front();
        }
    }else{
        while(!d.empty()){
            cout << d.back();
            d.pop_back();
        } 
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 960
if __name__ == '__main__':
    N = int(input().strip())
    lines = [input().split() for _ in range(N)]
    ab = [(int(line[0]), int(line[1])) for line in lines]
    lines = [input().split() for _ in range(N)]
    cd = [(int(line[0]), int(line[1])) for line in lines]

    candidates = []
    count = 0

    points = sorted(ab + cd, key=lambda x: x[0])
    for p in points:
        if p in ab:
            candidates.append(p)
            candidates = sorted(candidates, key=lambda x: x[1], reverse=True)
        else:
            # all candidates.x are smaller than p.x
            # so the best pair is the candidate which has the smallest y
            # in the all candidates.
            for i, cand in enumerate(candidates):
                if cand[1] < p[1]:
                    count += 1
                    candidates.pop(i)
                    break

    print(count)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,pair<int,int> > P;
typedef unsigned long long int ull;
const ll MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e9;

int V,E;
struct edge{
    int to,cost;
};
struct pnt{
    int id,x,y;
};
bool cmpx(pnt p1,pnt p2){
    return p1.x<p2.x;
}
bool cmpy(pnt p1,pnt p2){
    return p1.y<p2.y;
}
int n;
vector<vector<edge> > G(MAXN);
vector<bool> used(MAXN,false);
vector<pnt> p(MAXN);

ll prim(){
    priority_queue<ii,vector<ii>,greater<ii> > que;
    que.push(ii(0,0));
    ll res=0;
    while(!que.empty()){
        int cnt=que.top().first;
        int v=que.top().second;
        que.pop();
        if(used[v]) continue;
        used[v]=true;
        res+=cnt;
        for(auto e:G[v]){
            que.push(ii(e.cost,e.to));
        }
    }
    return res;
}

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        int x,y;cin>>x>>y;
        p[i]=pnt{i,x,y};
    }
    sort(p.begin(),p.begin()+n,cmpx);
    for(int i=0;i<n-1;i++){
        G[p[i].id].push_back({p[i+1].id,min(abs(p[i+1].x-p[i].x),abs(p[i+1].y-p[i].y))});
        G[p[i+1].id].push_back({p[i].id,min(abs(p[i+1].x-p[i].x),abs(p[i+1].y-p[i].y))});
    }
    sort(p.begin(),p.begin()+n,cmpy);
    for(int i=0;i<n-1;i++){
        G[p[i].id].push_back({p[i+1].id,min(abs(p[i+1].x-p[i].x),abs(p[i+1].y-p[i].y))});
        G[p[i+1].id].push_back({p[i].id,min(abs(p[i+1].x-p[i].x),abs(p[i+1].y-p[i].y))});
    }
    ll ans=prim();
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 14468
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
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 chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  vector<int> A(N),B(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  for(int i=0; i<N; i++){
    cin >> B[i];
  }
  vector<int> SA(N+1,0),SB(N+1,0);
  for(int i=0; i<N; i++){
    SA[i+1] = SA[i] + A[i];
  }
  for(int i=0; i<N; i++){
    SB[i+1] = SB[i] + B[i];
  }
  int ans=0;
  for(int i=0; i<N; i++){
    int temp=0;
    temp += SA[i+1];
    temp += SB[N] - SB[i];
    chmax(ans,temp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;


int main(void){
  string s;
  cin >> s;
  int n = s.size();
  ll hoge = 3;


  vector<ll> dp(s.size() + 2, 1);

  dp[1] = (s[s.size() - 1] == '1' ? 3 : 1);

  for (int i = 2; i <= n; i++){
    if (s[s.size() - i] == '1'){
      dp[i] = (2*dp[i-1] + hoge) % MOD;
    }
    else {
      dp[i] = (dp[i-1]) % MOD;
    }
    hoge = 3 * hoge % MOD;
  }

  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 1280
//imit
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
using ll = long long;
int n;
vector<int> a,b,c;
int main(void){
    cin >> n;
    for(int i = 0;i < 3;i++){
        for(int j = 0;j < n;j++){
            int t;
            cin >> t;
            if(i == 0){
                a.push_back(t);
            }else if(i == 1){
                b.push_back(t);
            }else{
                c.push_back(t);
            }
        }
    }
    sort(a.begin(),a.end());
    sort(c.begin(),c.end());
    ll ans = 0;
    for(int i = 0;i < n;i++){
        ans += (lower_bound(a.begin(),a.end(),b[i]) - a.begin()) * (c.end() - upper_bound(c.begin(),c.end(),b[i]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define fo(i,a,n) for (i = a; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;


void solve(){
    int a[3][3], n, k;
    f(i,3)f(j,3)cin>>a[i][j];
    cin>>n;
    while(n--){
        cin>>k;
        f(i,3)f(j,3)if(a[i][j] == k)a[i][j] = 0;
    }
    f(i,3){
        int cnt = 0;
        f(j,3)cnt += a[i][j];
        if(cnt == 0){cout<<"Yes";return ;}
    }
    f(i,3){
        int cnt = 0;
        f(j,3)cnt += a[j][i];
        if(cnt == 0){cout<<"Yes";return ;}
    }
    if(a[0][0] + a[1][1] + a[2][2] == 0){cout<<"Yes";return ;}
    if(a[0][2] + a[1][1] + a[2][0] == 0){cout<<"Yes";return ;}
    cout<<"No";
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = [0] * n
    b = [0] * n
    c = [0] * n
    for i in range(n):
        av, bv, cv = list(map(int, readline().split()))
        if i == 0:
            a[i] = av
            b[i] = bv
            c[i] = cv
        else:
            a[i] = max(b[i-1] + av, c[i-1] + av)
            b[i] = max(a[i-1] + bv, c[i-1] + bv)
            c[i] = max(a[i-1] + cv, b[i-1] + cv)
    print(max(a[-1], b[-1], c[-1]))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 45420
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

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; }

ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

template <typename T>
T median(std::vector<T>& c)
{
    size_t n = c.size();
    std::nth_element(c.begin(), c.begin() + n, c.end());
    return c[(n+1)/2];
}

int MAX_N=200000;

int main(){
    ios::sync_with_stdio(false);
    ll n;
    vector<ll> x(MAX_N+5);
    ll y[MAX_N+5];
    cin >> n;
    rep(i,n){
        cin >> x[i];
    }
    rep(i,n){
        y[i] = 2*x[i];
    }
    sort(y,y+n);
    ll m = (y[(n/2)-1]+y[n/2])/2; 
    rep(i,n){
        if(2*x[i] <= m) cout << y[n/2]/2 << endl;
        else cout << y[n/2-1]/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 6388
import java.util.ArrayList;
import java.util.Scanner;
import java.util.function.Function;

/**
 * Created by btk on 2017/10/13.
 */
public class Main {
   public static void main(String[] args){
       Scanner sc=new Scanner(System.in);
       int a=sc.nextInt();
       int b=sc.nextInt();
       int c=sc.nextInt();
       System.out.println(a^b^c);
       sc.close();
   }
}


Measured memory_bytes: 23632
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
#define M 1000000007

int main(void){
	int a,b,c,ans=1;cin>>a>>b>>c;
	if(c==0){
		cout<<b<<endl;
		return 0;
	}
	c--;
	ans+=b;
	ans+=min(b,c);
	c-=b;
	if(c>0)ans+=min(a,c);
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int B;
long long	answer;
string S;
int main(){
 cin >> S;
 for(int i = 0; i < S.size(); i++){
	if(S[i] == 'B') B++;
	else answer += B;
 }
 cout << answer << endl;
 return 0; 
};


Measured memory_bytes: 640
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
----
local N = read.nl()
local S = read.l()
local count = 0
for _ in S:gmatch("ABC") do
    count = count + 1
end
print(count)

Measured memory_bytes: 760
import sys
input=sys.stdin.readline
n,m,v,p=map(int,input().split())
a=[int(i) for i in input().split()]
a.sort(reverse=True)
a=a[p-1:]
le=len(a)
l,r=0,le-1

def adopt(x):
    global a,n,m,v
    b=a[x]+m
    if b<a[0]:
        return False
    al=(v-(n-x))*m
    s=x*b-sum(a[:x])
    return al<=s

while l+1<r:
    k=(l+r)//2
    if adopt(k):
        l=k
    else:
        r=k

if adopt(r):
    print(p+r)
else:
    print(p+l)


Measured memory_bytes: 14168
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < n; i++ {
		scanner.Scan()
		input := strings.Split(scanner.Text(), ":")
		h, _ := strconv.Atoi(input[0])
		m, _ := strconv.Atoi(input[1])
		H, M := (30*h+(m/2))*2, (6*m)*2
		if m&1 == 1 {
			H++
		}
		a := H - M
		if a < 0 {
			a = -a
		}
		a2 := 720 - a
		if a2 < a {
			a = a2
		}
		if a < 60 {
			fmt.Println("alert")
		} else if a >= 180 && a <= 360 {
			fmt.Println("safe")
		} else {
			fmt.Println("warning")
		}
	}
}


Measured memory_bytes: 1100
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		//渡される定数
		int num = sc.nextInt();//整数の数
		int n[][][] = new int[4][3][10];//配列

		//指定回数ループ
		for (int g = 0; g < num; g++) {
			int b = sc.nextInt();//b棟
			int f = sc.nextInt();//f階
			int r = sc.nextInt();//r番目の部屋
			int v = sc.nextInt();//v人追加

			n[b - 1][f - 1][r - 1] += v;

			//			//該当の棟bの為にh回ループ
			//			for (int h = 0; h < n.length; h++) {
			//
			//				//該当の階層fの為にi回ループ
			//				for (int i = 0; i < n.length; i++) {
			//
			//					//該当の部屋rの為にj回ループ
			//					for (int j = 0; j < n.length; j++) {
			//
			//						//上記から特定した区画にv人格納
			//
			//						n[b - 1][f - 1][r - 1] += v;
			//
			//					}
			//				}
		}
		//			System.out.println(n.length);
		//			System.out.println(n[0].length);
		//			System.out.println(n[0][0].length);

		//該当の棟bの為にh回ループ
		for (int h = 0; h < n.length; h++) {

			//一番最初の棟の列は＃を出力しない
			if (h != 0) {
				System.out.println("####################");
			}

			//該当の階層fの為にi回ループ
			for (int i = 0; i < n[0].length; i++) {

				//該当の部屋rの為にj回ループ
				for (int j = 0; j < n[0][0].length; j++) {
					System.out.print(" " + n[h][i][j]);

				}
				System.out.println();

			}

		}

	}
}


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

int main(){
    int n,k;
    cin >> n >> k;
    int mod0=0,modk2=0;
    long long ans = 0;
    if(k%2 == 1){       
        for(int i=1;i<=n;i++){
            if(i%k==0){
                mod0 ++;
            }
        }
        ans += pow(mod0,3);
    }
    else{
        for(int i=1;i<=n;i++){
            if(i%k==0){
                mod0 ++;
            }
            if(i%k == k/2){
                modk2 ++;
            }
        }
        ans += pow(mod0,3) + pow(modk2,3);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

if __name__ == '__main__':
    a = [str(i) for i in input().split()]

    count = 0

    for  i in a[0]:
        if "2" == i:
            count +=1
    print(count)


Measured memory_bytes: 3828
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	int pn = 0;
	if (*ci == '-') {
		pn = 1;
		ci++;
	}
	ll tmp = *(ll*)ci;
	int dig = ((tmp & ma0) ^ ma0) ? 68 - __builtin_ctzll((tmp & ma0) ^ ma0) : 0;
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (64 - dig >> 3);
	while ((ct = *ci++) >= '0') tmp = tmp * 10 + ct - '0';
	if (pn) tmp = -tmp;
	return tmp;
}

ll A[200001];
void pakuri_sort(int N, ll A[]) {
	const int b = 8;
	ll tmp[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int N = getint();
	rep1(i, N) {
		A[i] = getint() + A[i - 1];
	}

	pakuri_sort(N + 1, A);

	ll kotae = 0;
	int kazu = 1;
	rep(i, N) {
		if (A[i + 1] != A[i]) kazu = 1;
		else kotae += kazu++;
	}

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

	Would you please return 0;
}

Measured memory_bytes: 6380
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdIn = new Scanner(System.in);
		
		String X = stdIn.next();
		String Y = stdIn.next();
		
		if(X.charAt(0) > Y.charAt(0))
		{
			System.out.println(">");
		}
		else if(X.charAt(0) < Y.charAt(0))
		{
			System.out.println("<");
		}
		else
		{
			System.out.println("=");
		}
		
		

	}

}


Measured memory_bytes: 35680
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <fstream>
#include <queue>
#include <cstdio>
#include <deque>
#define fol(i,n) for(int i=0;i<n;i++)
#define db(a) cout << a<< endl;
using namespace std;

int main(){
    int a,n,ans=0;
    cin >> n;
    vector<int> st;
    fol(i,2*n) {cin >> a;st.push_back(a);}
    sort(st.begin(),st.end());
    fol(i,n) ans+=st[2*i];
    cout << ans <<endl;
    return 0;
}


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

using namespace std;

int main(void)
{
    long long A, B;
    string op;

    cin >> A >> op >> B;

    if(op[0] == '+'){
        cout << A+B << endl;
    }
    else{
        cout << A-B << endl;
    }

    return 0;
}

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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int n,t[maxn];

int main() {
    read(n);
    for(int i=0;i<=20;i++) if((1<<i)==n) return puts("No"),0;
    puts("Yes");
    printf("%d %d\n",1,2);
    printf("%d %d\n",2,3);
    printf("%d %d\n",3,1+n);
    printf("%d %d\n",1+n,2+n);
    printf("%d %d\n",2+n,3+n);
    for(int i=4;i<=n-!(n&1);i++) printf("%d %d\n",1+n,i&1?i:i+n);
    for(int i=4;i<=n-!(n&1);i++) printf("%d %d\n",i&1?i:i+n,i&1?(i^1):(i^1)+n);
    if(!(n&1)) {
        for(int i=1;i<=n;i++) {
            if((n^1^i)<i) {
                int a=i,b=n^1^i;
                if(!(a&1)) a+=n;if(!(b&1)) b+=n;
                printf("%d %d\n",a,n);
                printf("%d %d\n",b,n<<1);
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2816
//
// Created by wulang on 10/23/16.
//

#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
    if (argc == 2) {
        freopen(argv[1], "r", stdin);
    }

    string s;
    while(cin>>s)  {
        int x=0, y=0;
        for(int i=0;i<s.size();i++) {
            if(s[i]=='C') x=1;
            if(s[i]=='F' && x==1) y=1;
        }
        if(x+y==2) puts("Yes");
        else puts("No");
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>//..1..2..3:Correct:Solved by F2tekkz:)
#define ll long long
#define str string
#define sonic ios_base::sync_with_stdio(0)
using namespace std;
int main(){
	sonic;
	ll a , b , c;
	cin >> a >> b >> c;
	if(a == c){
		cout << 0 << " " << b;
	}
	else if(a < c){
		cout << 0 << " ";
		if(b - (c - a) > 0){
			cout << b - (c - a);
		}
		else{
			cout << 0;
		}
	}
	else{
		cout << a - c << " " << b;
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());

        int tPrev = 0;
        int xPrev = 0;
        int yPrev = 0;
        for (int i = 0; i < n; i++) {
            String[] txy = scanner.nextLine().split(" ", 3);
            int t = Integer.parseInt(txy[0]);
            int x = Integer.parseInt(txy[1]);
            int y = Integer.parseInt(txy[2]);

            int tDiff = t - tPrev;
            int xDiff = Math.abs(x - xPrev);
            int yDiff = Math.abs(y - yPrev);

            int remainingTime = tDiff - xDiff - yDiff;
            if (remainingTime < 0 || remainingTime % 2 != 0) {
                System.out.println("No");
                return;
            }

            tPrev = t;
            xPrev = x;
            yPrev = y;
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 117560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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 (a>b) { a = b; return 1; } return 0; }
void rcmb(ll *x,ll s,ll r,function<void(ll *)>f){if(r==0){f(x);}else{if(s<0)return;rcmb(x,s-1,r,f);x[r-1]=s;rcmb(x,s-1,r-1,f);}}
void cmb(ll n,ll k,function<void(ll *)>f){ll x[k];rcmb(x,n-1,k,f);}
void prm(ll n,function<void(ll *)>f){ll x[n];for(ll i=0;i<n;i++)x[i]=i;do{f(x);}while(next_permutation(x,x+n));}
void prm(ll n,ll k,function<void(ll *)>f){cmb(n,k,[&](ll *c){prm(k,[&](ll *p){ll x[k];for(ll i=0;i<k;i++){x[i]=c[p[i]];}f(x);});});}
// prm(4, 2, [](ll *x){ cout << x[0] << "," << x[1] << "\n"; });


void solve(long long N, std::vector<long long> H){
	ll res = 1;
	FOR(i, 1, N) {
		bool can = true;
		REP(j, i) {
			if (H[j] > H[i]) can = false;
		}
		if (can) res++;
	}
	cout << res << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    solve(N, std::move(H));
    return 0;
}


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

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n;
    cin >> n;
    unordered_map<ll, ll> um;
    vector<ll> vec;
    for(ll i = 0; i < n; i++){
        ll x;
        cin >> x;
        vec.push_back(x);
        um[x]++;
    }
    unordered_map<ll, ll> cnt;
    ll total = 0;
    for(auto i:um){
        total += i.second*(i.second - 1)/2;
    }
    
    for(ll i = 0; i < n; i++){
        ll t = um[vec[i]];
        ll t1 = t*(t-1)/2;
        ll t2 = (t-1)*(t-2)/2;
        
        cout << total - t1 + t2 << '\n';
        
    }
    
}









Measured memory_bytes: 9148
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

int main(){
    init();
    ll N;cin>>N;
    string s,t,u;
    cin>>s>>t>>u;
    ll ans=0;
    for(int i=0;i<N;i++){
        set<char>set;
        set.insert(t[i]);
        set.insert(u[i]);
        set.insert(s[i]);
        ans+=(ll)set.size()-1;
    }
    cout<<ans<<endl;


}

Measured memory_bytes: 256
package main

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

const (
	defaultBufferSize = 1024
	maxBufferSize     = 1e6
	Mod               = 1e9 + 7
)

var sc = bufio.NewScanner(os.Stdin)

// sc.Buffer(make([]byte, defaultBufferSize), maxBufferSize)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func ModComb(n, k int) int {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := 1; i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int) int {
	return ModPow(x, Mod-2)
}

func ModPow(a, n int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % Mod
		}
		a = a * a % Mod
		n /= 2
	}
	return res
}

func pow(a, n int) int {
	if n == 0 {
		return 1
	}

	ans := 0
	if n%2 == 0 {
		ans = pow(a*a, n/2)
	} else {
		ans = a * pow(a*a, (n-1)/2)
	}
	return ans
}

func intSliceReverse(slice []int) []int {
	for i, j := 0, len(slice)-1; i < j; i, j = i+1, j-1 {
		slice[i], slice[j] = slice[j], slice[i]
	}
	return slice
}

func stringReverse(str string) string {
	runes := []rune(str)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func primeFactorization(x int) map[int]int {
	result := make(map[int]int, 0)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			result[i]++
			x /= i
		}
	}
	if x != 1 {
		result[x]++
	}
	return result
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	for i := 2; i*i <= x; i++ {
		if i == x {
			continue
		}
		if x%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	n := readInt()
	p := make([]int, n)
	for i := 0; i < n; i++ {
		p[i] = readInt()
	}

	pasc := make([]int, n)
	copy(pasc, p)
	sort.Ints(pasc)

	count := 0
	for i, _ := range p {
		if p[i] != pasc[i] {
			count++
		}
	}
	if count <= 2 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 640