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

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

#define int long long
#define range(i,x,y) i=(x);i<(y);i++
#define rep(i,n) for(int i=0,i##_len=n;i<i##_len;i++)
#define all(x) begin(x),end(x)
#define lim(x,r,l) (r<=x&&x<l)
typedef long long ll;
typedef long double ld;

signed main(){
  int n, m; cin >> n >> m;
  UnionFind uf(n);
  vector<vector<int>> merged(m, vector<int>());

  rep(i,n){
    int k; cin >> k;
    rep(j, k){
      int l; cin >> l;
      merged[l-1].push_back(i);
    }
  }

  rep(l, m){
    for(int i = 0; i < (signed) merged[l].size() - 1ll; i++){
      uf.unionSet(merged[l][i], merged[l][i+1]);
    }
  }

  if(uf.size(0) == n){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

ll dp[100100][2];

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    dp[0][0] = 0;
    dp[0][1] = -INF; // はじめの値より1つ前の値を反転させることになるが、できない
    for(int i=0;i<n-1;i++){
        dp[i+1][0] = max(dp[i][0] + a[i],dp[i][1] - a[i]);
        dp[i+1][1] = max(dp[i][0] - a[i],dp[i][1] + a[i]);
        //cout << 0 << ":" << dp[i+1][0] << " " << 1 << ":" << dp[i+1][1] << endl;
    }
    //cout << "last" << endl;
    ll ans;
    ans = max(dp[n-1][0] + a[n-1],dp[n-1][1] - a[n-1]);
    //cout << 0 << ":" << dp[n-1][0] << " " << 1 << ":" << dp[n-1][1] << endl;
    cout << ans << endl;
}

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

using namespace std;

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

#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back
#define newl '\n'
#define gcd __gcd
#define fo(i,k,n) for(ll i=k;i<n;i++)
#define rev(i,k,n) for(ll i=k;i>n;i--)
#define MOD 1000000007 //10^9 + 7
#define deb(x) cout<<x<<" "<<#x<<newl
#define all(x) x.begin(),x.end()
#define print(x) for(auto i=x.begin();i!=x.end();i++)cout<<*i<<' ';cout<<endl;

ll INF = 1000000000000000005LL;

ll power(ll x, ll y, ll p=MOD){ //positive y
    ll res = 1;
    x = x % p; 
    while (y > 0) { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res; 
} 

ll inverse(ll a,ll m=MOD){
    return power(a,m-2,m);
}

vvll matmul(const vvll &a,const vvll &b,ll M=MOD){
    ll n=a.size(),m=a[0].size(),l=b[0].size();
    assert(m==b.size());
    vvll c(n,vll(l,0));
    fo(i,0,n)
    fo(j,0,l)
    fo(k,0,m)
    {
        c[i][j]=(c[i][j]+a[i][k]*b[k][j])%M;
    }
    return c;
}

vvll matpow(vvll a,ll p,ll M=MOD){
    assert(a.size()==a[0].size());
    ll n=a.size();
    vvll res(n,vll(n,0));
    fo(i,0,n)   res[i][i]=1;
    while(p>0)
    {
        if(p&1) res=matmul(res,a,M);
        a=matmul(a,a,M);
        p>>=1;
    }
    return res;
}

void solve(){
    ll k;
    cin>>k;


    ll curr = 0;

    fo(i,1,1e8){
        curr = 10*curr + 7;
        curr %= k;
        if(curr%k == 0){
            cout<<i;
            return;
        }
    }

    cout<<"-1";
}

int main() {
    
    // fast io
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    
    //Number of Test cases
    ll T=1; 
    //cin>>T;
    
    while(T--){
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int max_cnt=0;
vector<list<int>>v(200005);
vector<int> isvisited(200005);
int n,m;
int dfs(int i)
{
    isvisited[i]=1;
    int ans=1;
    for(auto x:v[i])
    {
        if(!isvisited[x])
        ans += dfs(x);
    }
    return ans;
}
int main() {
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for(int i=1;i<=n;i++)
    {
        if(!isvisited[i])
        max_cnt = max(max_cnt,dfs(i));
    }
    cout<<max_cnt;
}


Measured memory_bytes: 27516
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repn(i,a,b)   for(ll i=a;i>=b;i--)
#define F first
#define S second
#define qi queue<ll>
#define pii pair<ll,ll>
#define vi vector<ll>
#define si set<ll>
#define vii vector<pii>
#define mi multiset<ll>
#define mii multiset<pii>
#define MI map<ll,ll>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define mod 998244353
#define mod2 998244353

// size_t f= str.find(string s,0); find s in str from start
// if found then (f != string::npos)
// m.insert({x,y}); m[x]=y;

int fexp(int a, int b){int ans = 1;while(b){if(b&1) ans = ans*a%mod2; b/=2;a=a*a%mod2;}return ans;}
int inverse(int a, int p){return fexp(a, p-2);}

signed main(){
    IOS
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	string s;
	cin>>s;
	ll a = s.size();
  	rep(i,0,a){
      	if(s[i]=='?'){
          	cout<<"D";
        }
      	else cout<<s[i];
    }
    return 0;
}

Measured memory_bytes: 3792
#include <iostream>
#include<algorithm>
using namespace std;
const int P=1000000007;
int main() {
  int n;
  cin>>n;
  
  int a[n];
  for(int i=0;i<n;i++){
  	cin>>a[i];
  }
  sort(a,a+n);
  if(n%2==0){
  	int x=1;
  	for(int i=0;i<n;i+=2)
    {
  	  if(a[i]==i+1 and a[i+1]==i+1)
      {
  	  	x*=2;
  	  	x%=P;
  	  }
      else
      {
  	  	x=0;
  	  	break;
  	  }
  	}
  	cout<<x<<endl;
  }
  else
  {
  	int x=1;
  	if(a[0]!=0)
    {
  	  cout<<0<<endl;
  	}
    else
    {
	  	for(int i=1;i<n;i+=2)
        {
	  	  if(a[i]==i+1 and a[i+1]==i+1)
          {
	  	  	x*=2;
	  	  	x%=P;
	  	  }
          else
          {
	  	  	x=0;
	  	  	break;
	  	  }
	  	}
	  	cout<<x<<endl;  		
  	}
  	
  }
}

Measured memory_bytes: 640
import sys,os
import math
from fractions import Fraction 
from collections import defaultdict
from random import randint

# sys.stderr=open('err.txt','w')
# sys.stdout=open('output.txt','w')
# sys.stdin=open('input.txt','r')

def linput():
    return list(minput())

def minput():
    return map(int, sys.stdin.readline().strip().split())

###############################################################

def make_set(a):
    parent[a]=a
    sizen[a]=1

def find_set(a):
    if parent[a]==a:
        return a
    parent[a]=find_set(parent[a])
    return parent[a]

def union_set(a,b):
    x=find_set(a)
    y=find_set(b)
    if x==y:
        return
    else:
        if sizen[x]>sizen[y]:
            parent[y]=x
            sizen[x]+=sizen[y]
        else:
            parent[x]=y
            sizen[y]+=sizen[x]

n,m=minput()
parent=[0]*n
sizen=[0]*n
for i in range(n):
    make_set(i)
ans=0
for i in range(m):
    x,y=minput()
    if x>y:
        x,y=y,x
    x=x-1
    y=y-1
    union_set(x,y)
# print(parent)
di = defaultdict(int)
# for i in parent:
#     di[i]+=1
# print(di)

for v in sizen:
    ans=max(ans,v)
print(ans)


Measured memory_bytes: 19728
#!/usr/bin/env python3
import sys

input = sys.stdin.readline


def S():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


n, x, t = MI()

q, r = divmod(n, x)
if r == 0:
    print(q * t)
else:
    print(q * t + t)


Measured memory_bytes: 9160
package main

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

// Data :
type Data struct {
	X int
	H int
}

// Datas :
type Datas []Data

func (p Datas) Len() int {
	return len(p)
}

func (p Datas) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Datas) Less(i, j int) bool {
	return p[i].X < p[j].X
}

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

type queue struct {
	pos int
	dmg int
}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	D := getInt()
	A := getInt()
	m := make(Datas, N)
	for i := 0; i < N; i++ {
		m[i].X = getInt()
		m[i].H = getInt()
	}

	sort.Sort(m)

	q := make([]queue, 0, N)

	ans := 0
	D = 2 * D
	T := 0
	for i := 0; i < N; i++ {
		pos := m[i].X
		//		out("pos", pos, len(q))
		for len(q) != 0 && q[0].pos < pos {
			//			out("del", q[0], "qpos", q[0].pos, "pos", pos)
			T -= q[0].dmg
			q = q[1:]
		}
		x := m[i].H
		x -= T
		//		out("attack", m[i].X, m[i].H, T, pos, x)

		if x > 0 {
			num := (x + A - 1) / A
			ans += num
			dmg := num * A
			T += dmg
			q = append(q, queue{pos + D, dmg})
			//			out(q)
		}

	}
	fmt.Println(ans)
}


Measured memory_bytes: 10880
from collections import deque
from itertools import repeat

MOD = 10**9 + 7

N,M = map(int,input().split())
S = tuple(map(int,input().split()))
T = tuple(map(int,input().split()))

if N < M:
    N,M = M,N
    S,T = T,S

dp = deque(repeat(1, M+1), M+2)


for s in S:
    dp.append(1)
    for t in T:
        if s == t:
            dp.append(dp[1]+dp[-1])
        else:
            dp.append(dp[1]-dp[0]+dp[-1])

print(dp[-1]%MOD)

Measured memory_bytes: 125020
n=int(input())
h=list(map(int,input().split()))

yn=""
for i in  range(n-2,-1,-1):
    if h[i]<=h[i+1]:
        continue
    elif h[i]==h[i+1]+1:
        h[i]-=1
        continue
    else:
        yn="No"
        break
    
if yn=="No":
    print("No")
else:
    print("Yes")
        

Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
int eh[N][N], dp[N][N], ev[N][N];
int g[N][N];
int n, m;

int main() {

//	freopen("readin.txt", "r", stdin);

	int n, m, q;
	char ch;
	scanf("%d%d%d", &n, &m, &q);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			scanf(" %c", &ch);
			g[i][j] = ch == '1';
			if (g[i][j] == 1 && g[i][j - 1] == 1) eh[i][j]++;
			if (g[i][j] == 1 && g[i - 1][j] == 1) ev[i][j]++;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			dp[i][j] = g[i][j] + dp[i][j - 1] + dp[i - 1][j] - dp[i - 1][j - 1];
			ev[i][j] += ev[i][j - 1] + ev[i - 1][j] - ev[i - 1][j - 1];
			eh[i][j] += eh[i][j - 1] + eh[i - 1][j] - eh[i - 1][j - 1];
		}
	}

	while (q--) {

		int x1, y1, x2, y2;
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		int n = dp[x2][y2] - dp[x1 - 1][y2] - dp[x2][y1 - 1]
				+ dp[x1 - 1][y1 - 1];
		int e = eh[x2][y2] - eh[x1 - 1][y2] - eh[x2][y1] + eh[x1 - 1][y1]
				+ ev[x2][y2] - ev[x1][y2] - ev[x2][y1 - 1] + ev[x1][y1 - 1];
		printf("%d\n", n - e);
	}

	return 0;
}


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

// #define int            long long int 
#define vi             vector<int>
#define mod            1000000007
#define MAX            INT_MIN
#define MIN            INT_MAX
#define ff             first
#define ss             second
#define pb             push_back
#define bs             binary_search    // binary_search(a,a+n,x);
#define lb             lower_bound      // lower_bound(a,a+n,x) - a; => For Index
#define up             upper_bound      // upper_bound(a,a+n,x) - a; => For Index       
#define mp             make_pair
#define pii            pair<int,int>
#define pqb            priority_queue<int>
#define floop(x,n)       for(int i=x;i<n;i++)
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define ps(x,y)        fixed<<setprecision(y)<<x         
#define FIO            ios_base::sync_with_stdio(false); cin.tie(NULL);
                  
void c_p_c()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif   

}


void solution()
{
    int n,x,t;
    cin>>n>>x>>t;

    int ans = 0;
    

    while(n)
    {
        if(n>x)
        {
            n=n-x;
        }
        else
        {
            n=0;
        }
        ans+=t;
    }

    cout<<ans<<endl;
}

int32_t main()
{
	c_p_c();

	// int t;
	// cin>>t;

	// while(t--)
	// {
		solution();
	//}

	return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
	
	char input[10];
	int a, b;
	
	fgets(input, sizeof(input), stdin);
	a = atoi(strtok(input, " "));
	b = atoi(strtok(NULL, " "));
	
	if (a > b){
		printf("a > b\n");
	}else if(a < b){
		printf("a < b\n");
	}else{
		printf("a == b\n");
	}
	
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#include <boost/math/common_factor.hpp>
using namespace std;
using boost::math::lcm;

int main() {
  int N;
  cin >> N;
  int64_t acc = 1;
  for (int i = 1; i <= N; ++i) {
    int64_t T;
    cin >> T;
    acc = lcm(acc, T);
  }
  cout << acc << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int a = sc.nextInt();
			int b = sc.nextInt();

			if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
				System.out.println("Possible");
			} else {
				System.out.println("Impossible");
			}
		}
	}
}


Measured memory_bytes: 24020
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
constexpr int inf=1e9+7;
constexpr ll longinf=1LL<<60 ;
constexpr ll mod=998244353 ;


ll dp[333][333][333];
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    vector<int> a;
    int c=0,sum=0;
    rep(i,s.size()){
        if(s[i]=='0'){
            a.push_back(c);
            c=0;
        }
        else {
            c++;
            sum++;
        }
    }
    a.push_back(c);
    dp[0][0][0]=1;
    int m=a.size();
    rep(i,m)rep(j,301)rep(k,301){
        dp[i][j][k]%=mod;
        if(dp[i][j][k]==0)continue;
        rep(l,301){
            if(k+l-a[i]>=300)break;
            if(k+l>=a[i])dp[i+1][j+max(0,l-a[i])][k+l-a[i]]+=dp[i][j][k];
        }
    }
    int k;
    cin>>k;
    ll ans=0;
    rep(i,min(k+1,301))ans+=dp[m][i][0]%mod;
    cout<<ans%mod<<endl;;
    return 0;
}

Measured memory_bytes: 240404
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1193&lang=jp
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    ans = []
    while True:
        H = int(readline())
        if H == 0:
            break

        c = [[int(i) for i in readline().split()] for _ in range(H)]
        seq = [[1] for _ in range(H)]
        ans_tmp = [0]
        
        score = 0
        while True:
            # 消す
            for i, line in enumerate(c):
                for j in range(1,5):
                    if line[j] == line[j-1]:
                        seq[i][-1] += 1
                    else:
                        seq[i].append(1)
            
                acc = -1
                for s in seq[i]:
                    acc += s
                    if s >= 3:
                        score += s * line[acc]
                        for j in range(acc - s + 1, acc + 1):
                            line[j] = 0
                seq[i] = [1]

            for i in reversed(range(H)):
                for j in range(5):
                    if c[i][j] == 0:
                        for h in reversed(range(i)):
                            if c[h][j] != 0:
                                c[h][j], c[i][j] = c[i][j], c[h][j]
                                break

            ans_tmp.append(score)
            if ans_tmp[-1] == ans_tmp[-2]:
                ans.append(ans_tmp[-1])
                break

    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 5644
if __name__ == "__main__":
    a,b = map(int, input().split())
    if a >= 3 and a % 3 == 0:
        print ("Possible")
        exit()
    if b >= 3 and b % 3 == 0:
        print ("Possible")
        exit()
    if (a + b) >= 3 and (a + b) % 3 == 0:
        print ("Possible")
        exit()
    print ("Impossible")


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <map>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef long long ll;

int main()
{
    int n;
    while(cin >> n && n) {

        vector<pair<double,string> > v;
        map<double,vector<string> > ma;
        rep(i,n) {
            string l;
            int p,a,b,c,d,e,f,s,m;
            cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;

            double sum = a + b + c + d + e;
            sum += (m-1) * (d + e);
            int num = f*s*m - p;

            v.push_back(make_pair(num/sum,l));
            ma[num/sum].push_back(l);
        }

        vector<string> ans;
        map<double,vector<string> >::iterator ite;
        for(ite = ma.begin();ite != ma.end();ite++) {
            sort(ite->second.begin(),ite->second.end(),greater<string>());
            rep(i,ite->second.size()) {
                ans.push_back(ite->second[i]);
                // cout << ite->first << " " << ite->second[i] << endl;
            }
        }

        reverse(ans.begin(),ans.end());
        rep(i,ans.size()) cout << ans[i] << endl;

        cout << "#" << endl;

    }

    return 0;
}

Measured memory_bytes: 1228
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A), b(B);
  int min_a = 1e9, min_b = 1e9;
  for (int i = 0; i < A; ++i) {
    cin >> a[i];
    min_a = min(min_a, a[i]);
  }
  for (int i = 0; i < B; ++i) {
    cin >> b[i];
    min_b = min(min_b, b[i]);
  }
  int ans = min_a + min_b;
  for (int i = 0; i < M; ++i) {
    int x, y, c;
    cin >> x >> y >> c;
    x--, y--;
    ans = min(ans, a[x] + b[y] - c);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main()
 {
    int n,max=0,h[101]={0};
    while(cin>>n)
   {
        h[n]++;
        if(h[n]>max)max=h[n];
    }
    for(int i=1;i<=100;++i)
    if(h[i]==max)
    cout<<i<<"\n";
    return 0;
 }

Measured memory_bytes: 1160
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;
import java.util.SortedSet;
import java.util.TreeSet;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int l = Integer.parseInt(sc.next());
    int r = Integer.parseInt(sc.next());
    SortedSet<Integer> mods = new TreeSet<>();
    int min = Integer.MAX_VALUE;
    for (int i = l; i <= r; i++) {
      int mod = i % 2019;
      if (mod == 0) {
        pw.println(0);
        return;
      }
      int calc = mods.stream().mapToInt(m -> (m * mod) % 2019).min().orElse(Integer.MAX_VALUE);
      min = Math.min(calc, min);
      mods.add(mod);
    }
    pw.println(min);
  }
}


Measured memory_bytes: 27604
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
  int N;
  int t[100001];
  int x[100001];
  int y[100001];
  int dt;
  int dist;
  cin >> N;
  t[0] = 0, x[0] = 0, y[0] = 0;
  for (int i = 1; i < N+1; ++i)
    cin >> t[i] >> x[i] >> y[i];

  for (int i = 0; i < N; ++i) {
    dt = t[i+1] - t[i];
    dist = abs(x[i+1]-x[i]) + abs(y[i+1] - y[i]);
    if(dt < dist) {
      cout << "No" << endl;
      return 0;
    }
    else if(dt % 2 != dist % 2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}



Measured memory_bytes: 1408
INF = 10 ** 18
n, m, r = map(int, input().split())
d = [INF] * n
d[r] = 0
p = [False] * n
p[r] = True
e = [None] * m
for i in range(m):
    e[i] = tuple(map(int, input().split()))
for _ in range(n):
    flg = 1
    for s, t, da in e:
        if p[s] == True and d[t] > d[s] + da:
            d[t] = d[s] + da
            p[t] = True
            flg = 0
    if flg:
        break
else:
    print('NEGATIVE CYCLE')
    exit(0)
for x in d:
    if x >= 10 ** 10:
        print('INF')
    else:
        print(x)



Measured memory_bytes: 6140
n=int(input())
s=list(map(int,input().split()))
ans1=0
ans=0
for i in range(1,n):
  if s[i]<=s[i-1]:
    ans1+=1
  else:
    ans=max(ans,ans1)
    ans1=0
    
print(max(ans,ans1))

  

Measured memory_bytes: 14224
#include<cstdio>
#include<vector>
#include<algorithm>

#define	EPS		1e-9
#define	pb(a)	push_back(a);

#define	ID_CCW	0
#define	ID_CW	1
#define	ID_GO	2
#define	ID_BACK	3

using namespace std;

class Point{
public:
	double x,y;
	Point(){}
	Point(double xx,double yy) : x(xx),y(yy){}
};

class Polygon : public vector<Point>{};

Point &operator -=(Point &a,const Point &b)
{
	a.x-=b.x;
	a.y-=b.y;
	return a;
}

bool operator <(const Point &a,const Point &b)
{
	return (a.x==b.x)?(a.y<b.y):(a.x<b.x);
}

double dot(const Point &a,const Point &b)
{
	return a.x*b.x+a.y*b.y;
}

double cross(const Point &a,const Point &b)
{
	return a.x*b.y-a.y*b.x;
}

int ccw(const Point &a,Point b,Point c)
{
	b-=a;
	c-=a;
	double rotdir=cross(b,c);
	if(rotdir>EPS)		return ID_CCW;
	if(rotdir<-EPS)		return ID_CW;
	if(dot(b,c)>EPS)	return ID_GO;
	return ID_BACK;
}

Polygon ConvexHull(vector<Point> ps)
{
	Polygon ch;
	int n=ps.size();
	sort(ps.begin(),ps.end());

	vector<Point> ch_u(n);
	int n_u=0;
	for(int i=n-1;i>=0;i--){
		ch_u[n_u++]=ps[i];
		while(n_u>=3 && ccw(ch_u[n_u-3],ch_u[n_u-2],ch_u[n_u-1])!=ID_CCW){
			ch_u[n_u-2]=ch_u[n_u-1];
			n_u--;
		}
	}

	vector<Point> ch_l(n);
	int n_l=0;
	for(int i=0;i<n;i++){
		ch_l[n_l++]=ps[i];
		while(n_l>=3 && ccw(ch_l[n_l-3],ch_l[n_l-2],ch_l[n_l-1])!=ID_CCW){
			ch_l[n_l-2]=ch_l[n_l-1];
			n_l--;
		}
	}

	for(int i=0;i<n_u-1;i++)	ch.pb(ch_u[i]);
	for(int i=0;i<n_l-1;i++)	ch.pb(ch_l[i]);
	return ch;
}

int main()
{
	for(int n;scanf("%d",&n),n;){
		vector<Point> p(n);
		for(int i=0;i<n;i++)	scanf("%lf,%lf",&p[i].x,&p[i].y);
		printf("%d\n",n-ConvexHull(p).size());
	}

	return 0;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(char, a);
  out(islower(a) ? 'a' : 'A');
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
set<ll>v;
int main()
{
    ll n, k;
    cin >> n >> k;
    for(ll i = k; i < k + n; i ++)
    {
        v.insert(i);
    }
    for(ll i = k; i > k - n; i --)
    {
        v.insert(i);
    }
    for(auto c : v)
    {
        cout << c << " ";
    }
}


Measured memory_bytes: 256
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/



int main() {
int N;
cin>>N;
string S1,S2;
cin>>S1>>S2;
ll dp[N];
if(S1[0]==S2[0]){
dp[0]=3;

rep2(i,1,N){
    
    if((i!=1)&&(S1[i-1]==S1[i-2])){
        if(S1[i]==S2[i]){
            dp[i]=dp[i-1];
        }
        else{
            dp[i]=3*dp[i-1];
            dp[i]%=MOD;
            dp[i+1]=dp[i];
            i++;
        }

    }
    else{
        if(S1[i]==S2[i]){
            dp[i]=2*dp[i-1];
            dp[i]%=MOD;
        }
        else{
            dp[i]=2*dp[i-1];
            dp[i]%=MOD;
            dp[i+1]=dp[i];
            i++;
        }
        
    }

}
}
else{
    dp[1]=6;
    rep2(i,2,N){
    
    if(S1[i-1]==S1[i-2]){
        if(S1[i]==S2[i]){
            dp[i]=dp[i-1];
        }
        else{
            dp[i]=3*dp[i-1];
            dp[i]%=MOD;
            dp[i+1]=dp[i];
            i++;
        }

    }
    else{
        if(S1[i]==S2[i]){
            dp[i]=2*dp[i-1];
            dp[i]%=MOD;
        }
        else{
            dp[i]=2*dp[i-1];
            dp[i]%=MOD;
            dp[i+1]=dp[i];
            i++;
        }
        
    }

}

}
cout<<dp[N-1]<<endl;
return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace _0095
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] fish = new int[n];
            for (int i = 0; i < n; i++)
            {
                string s = Console.ReadLine();
                if (s[s.Length - 1] == ' ') s = s.Substring(0, s.Length - 1);
                int[] x = s.Split().Select(int.Parse).ToArray();
                fish[i] = (100 - x[0]) + x[1] * 1000;
            }
            Console.WriteLine(100 - (fish.Max() % 1000) + " " + fish.Max() / 1000);
        }
    }
}

Measured memory_bytes: 9452
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Solution();
	}

}

class Solution {

	private int n, k;

	public Solution() {
		this.setScanner();
		this.run();
	}

	private void setScanner() {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		k = sc.nextInt();
		sc.close();
	}

	private void run() {
		int out = (n % k != 0) ? 1 : 0;
		System.out.println(out);
	}

}

Measured memory_bytes: 35616
#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>;

signed main() {

  string s;
  cin >> s;

  auto it = s.rbegin();

  while (true) {

    bool flag = true;
    if (it + 5 > s.rend()) { flag = false; }

    if (!flag) {
      cout << "NO" << endl;
      return 0;
    }

    switch (*it) {
    case 'm':
      if (*(it + 1) == 'a' && *(it + 2) == 'e' && *(it + 3) == 'r' && *(it + 4) == 'd') {
        it += 5;
      } else {
        flag = false;
      }
      break;
    case 'e':
      if (*(it + 1) == 's' && *(it + 2) == 'a' && *(it + 3) == 'r' && *(it + 4) == 'e') {
        it += 5;
      } else {
        flag = false;
      }
      break;
    case 'r':
      if (*(it + 1) == 'e') {
        if (it + 6 > s.rend()) {
          flag = false;
        } else if (*(it + 2) == 's' && *(it + 3) == 'a' && *(it + 4) == 'r' && *(it + 5) == 'e') {
          it += 6;
        } else if (it + 7 > s.rend()) {
          flag = false;
        } else if (*(it + 2) == 'm' && *(it + 3) == 'a' && *(it + 4) == 'e' && *(it + 5) == 'r' && *(it + 6) == 'd') {
          it += 7;
        } else {
          flag = false;
        }
      } else {
        flag = false;
      }
      break;
    default: flag = false; break;
    }

    if (!flag) {
      cout << "NO" << endl;
      return 0;
    }
    if (it == s.rend()) {
      cout << "YES" << endl;
      return 0;
    }
  }

  // int p = 0;
  // int l = s.length();
  // vector<char> v(l);

  // for (int i = 0; i < l; ++i) { v[i] = s[i]; }

  // bool flag = true;
  // while (true) {
  //   if (p + 5 > l) {
  //     flag = false;
  //     break;
  //   }
  //   if (v[p + 0] == 'd' && v[p + 1] == 'r' && v[p + 2] == 'e' && v[p + 3] == 'a' && v[p + 4] == 'm') {

  //   } else if (v[p + 0] == 'e' && v[p + 1] == 'r' && v[p + 2] == 'a' && v[p + 3] == 's' && v[p + 4] == 'e') {

  //   } else {
  //   }
  // }

  // auto it = s.rbegin();

  // string s;
  // cin >> s;
  // string _s = s;

  // bool flag = true;
  // while (s != "") {
  //   vector<string> v = {"dreamer", "eraser", "dream", "erase"};
  //   for (int i = 0; i < 4; ++i) {
  //     auto l = v[i].size();
  //     if (s.size() < l) continue;
  //     string t = s.substr(s.size() - l, l);
  //     if (t == v[i]) {
  //       s = s.substr(0, s.size() - l);
  //       break;
  //     }
  //   }
  //   if (s == _s) {
  //     flag = false;
  //     break;
  //   }
  //   _s == s;
  // }

  // if (flag) {
  //   cout << "YES" << endl;
  // } else {
  //   cout << "NO" << endl;
  // }

  // return 0;
}


Measured memory_bytes: 3744
str=input()
q=int(input())
i=0
while i<q:
    ord=list(input().split())
    if ord[0]=="print":
        print(str[int(ord[1]):int(ord[2])+1])
    if ord[0]=="reverse":
        str_i = str[:int(ord[1])]
        str_re = str[int(ord[1]):int(ord[2])+1]
        str_re = str_re[::-1]
        str_f = str[int(ord[2])+1:]
        str=str_i+str_re+str_f
    if ord[0]=="replace":
        str_i = str[:int(ord[1])]
        str_f = str[int(ord[2])+1:]
        str=str_i+ord[3]+str_f
    i+=1



Measured memory_bytes: 5620
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

const int M = 1e9+7;

using namespace std;

main()
{
    fast;
    int a,b;
    cin>>a>>b;
    if (a==1 && b==1)
        cout<<"Draw\n";
    else if (a==b)
        cout<<"Draw\n";
    else if (a==1 && b!=1)
        cout<<"Alice\n";
    else if (a!=1 && b==1)
        cout<<"Bob\n";
    else if (a>b)
        cout<<"Alice\n";
    else if (a<b)
        cout<<"Bob\n";
}


Measured memory_bytes: 256
n, y = list(map(int, input().split()))

answer = [-1, -1, -1]
for y10000 in range(0, n+1):
    for y5000 in range(0, n+1-y10000):
        y1000 = n - y5000 - y10000
        if y1000 * 1000 + y5000*5000+y10000*10000 == y:
            answer = [y10000, y5000, y1000]
            break


print(" ".join(map(str, answer)))


Measured memory_bytes: 3060
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let a: usize = read();
    println!("{}", if n % 500 <= a { "Yes" } else { "No" });
}

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

using namespace std;
struct unin{
    vector<int>pr,sz;
    unin(int n){
        pr.resize(n+1);
        sz=pr;
        for(int i=0;i<=n;i++){
            sz[i]=1;
            pr[i]=i;
        }
    }

    int getrt(int x){
        if(pr[x]==x)
            return x;
        return getrt(pr[x]);
    }
    int cnct(int x,int y){
        x=getrt(x); y=getrt(y);
        if(x==y){
            return 0;
        }
        if(sz[x]>sz[y]){
            pr[y]=x;
            sz[x]+=sz[y];
            return sz[x];
        }else if(sz[x]<sz[y]){
            pr[x]=y;
            sz[y]+=sz[x];
            return sz[y];
        }else{
            pr[x]=y;
            sz[y]+=sz[x];
            return sz[y];
        }
    }
};
int main()
{
    ///{}
    int n,m;
    cin>>n>>m;
    unin u(n);
    int mx=1;
    while(m--){
        int x,y;
        cin>>x>>y;
        mx=max(mx,u.cnct(x,y));
    }
    cout<<mx<<'\n';
    return 0;
}


Measured memory_bytes: 4836
#include<stdio.h>
#include<algorithm>
using namespace std;
const int maxn=100010;  //100010
int n;
struct s{
	int i,ai;
	s(){
		this->ai=this->i=0;
	} 
}a[maxn];
bool cmp(const s &a,const s &b)
{
	//if(a.b==b.b) return a.a<b.a;
	return a.ai<b.ai; 
}
int main()
{
	scanf("%d",&n);
	for(int j=0;j<n;j++)
	{
			scanf("%d",&a[j].ai);
			a[j].i=j;
	}
	 sort(a,a+n,cmp);
	 for(int j=0;j<n;j++)
	 	printf("%d ",a[j].i+1);
	return 0;
 } 

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  int C[N], S[N], F[N];
  for (int i=1; i<=N; i++) cin >> C[i] >> S[i] >> F[i];
  for (int st=1; st<=N; st++) {
    int time = 0;
    for (int i=st; i<=N-1; i++) {
      time = max(time, S[i]);
      if (time%F[i]!=0) time += F[i] - time%F[i];
      time += C[i];
    }
    cout << time << endl;
  }
  return 0;
}

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

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (a > 0 && c > 0)
    {
        c -= b;
        if (c <= 0)
            break;
        a -= d;
    }
    if (a <= 0)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include<algorithm>
#include <vector>
#include <iomanip>

int main()
{
    long long W,H,x,y;
    std::cin >> W >> H >> x >> y;
    if(W%2==0 && H%2==0 && x==W/2 && y==H/2){
        long long S=W*H;
        double S2=S/2.0;
        std::cout << std::fixed << S2  << " " << 1<< std::endl; 
    }else{
        long long S=W*H;
        double S2=S/2.0;
        std::cout << std::fixed << S2 << " " << 0<< std::endl; 
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	int n, i=0;
	cin>>n;
	vector<string>v(n);
	for(int i=0;i<n;++i){
		cin>>v[i];
	}
	sort(v.begin(),v.end());
	for(int j=1;j<n;++j){
		if(equal(v[i].begin(),v[i].end(),v[j].begin(),v[j].end()) != true){
			i++;
			v[i] = v[j];
		}
	}
	cout<<++i<<endl;
	return 0;
}

Measured memory_bytes: 9588
/* ***********************************************
Author        :taciturnity
Created Time  :2020/2/21 8:23:51
File Name     :TEST.cpp
************************************************ */

#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define ll long long
#define INF 0x3f3f3f3f
#define rep(i,x,y) for(int i = x;i <= y;++i)
#define fori(i,x,y) for(int i = x;i >= y; -- i)
#define bug puts("--------------")
const int N = 2e5+10;
const double eps = 0.00000001;
const ll mod = 1e9 + 7 ;
using namespace std;
ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int main(){
	ll n,a,b;
	n = read();a = read();b = read();
	ll d = n/(b+a);
	cout << d*a+min(a,n-d*(b+a));
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


n = I()
li = [a*b for a in range(1,10) for b in range(1, 10)]
if n in li:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38512
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s,d;
    cin >> s >> d;
    int cnt=0;
    rep(i,3){
        if(s[i]==d[i]) ++cnt;
    }
    cout << cnt;

    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
        long long N,M;
        cin >> N >> M;
        long long n=min(N,M),m=max(N,M);
        if(n==1 && m==1)
                cout << 1 << endl;
        else if(n==1)
                cout << m-2 << endl;
        else
                cout << (n-2)*(m-2) << endl;
        return 0;
}

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

ll A[3];

int main(void){
    rep(i,3)cin >> A[i];
    if(A[0]+A[1]+A[2]>=22)cout << "bust" << endl;
    else cout <<"win" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
	cin>>n;
	ll sum=0;
	for(int i=1;i<=n;i++){
		if(i%3&&i%5){
			sum+=i;
		}
	}
	cout<<sum;
	return 0;
} 

Measured memory_bytes: 3596
n = int(input())
a = list(map(int, input().split()))

dic = {}

ans = sum(a)
for i in range(n):
  dic.setdefault(a[i], 0)
  dic[a[i]] += 1

q = int(input())

for i in range(q):
  b,c = map(int, input().split())
  
  dic.setdefault(c,0)
  dic.setdefault(b,0)
  
  tmp = dic.pop(b)
  dic[c] += tmp
  
  ans += (c-b) * tmp
  print(ans)


Measured memory_bytes: 89276
#include<bits/stdc++.h>
#define reg register
#define ll long long
#define inf 0x3f3f3f3f3f3f3f3f
using namespace std;
int n;
double d,x,ans;
int main()
{
    cin>>n>>d>>x;
    for(reg int i=n;i;i--)
    {
        ans+=d+i*x-0.5*x;
        d=((i*2+2)*d+x*5)/i/2;
        x=(i*2+4)*x/i/2;
    }
    cout<<fixed<<setprecision(9)<<ans;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, K, L, PQ, RS):
    ans = 0
    gr = defaultdict(list)
    for p, q in PQ:
        gr[p].append(q)
        gr[q].append(p)

    gt = defaultdict(list)
    for r, s in RS:
        gt[r].append(s)
        gt[s].append(r)

    ccr = {}
    unused = set(gr.keys())
    while unused:
        q = [unused.pop()]
        con = set([])
        while q:
            v = q.pop()
            con.add(v)
            for u in gr[v]:
                if u in unused:
                    q.append(u)
                    unused.remove(u)
        for v in con:
            ccr[v] = con

    cct = {}
    unused = set(gt.keys())
    while unused:
        q = [unused.pop()]
        con = set([])
        while q:
            v = q.pop()
            con.add(v)
            for u in gt[v]:
                if u in unused:
                    q.append(u)
                    unused.remove(u)
        for v in con:
            cct[v] = con

    cache = {}

    def cc(t, r):
        k = (id(t), id(r))
        if k not in cache:
            cache[k] = len(t & r)
        return cache[k]

    ans = []
    for i in range(1, N+1):
        if i in cct and i in ccr:
            a = cc(cct[i], ccr[i])
        else:
            a = 1
        ans.append(a)
    return " ".join(map(str, ans))


def main():
    N, K, L = read_int_n()
    PQ = [read_int_n() for _ in range(K)]
    RS = [read_int_n() for _ in range(L)]

    print(slv(N, K, L, PQ, RS))


if __name__ == '__main__':
    main()


Measured memory_bytes: 153556
n = int(input())
s = [str(input()) for i in range(n)]
m = int(input())
t = [str(input()) for j in range(m)]
words = list(set(s + t))
print(max([max(s.count(words[i]) - t.count(words[i]) for i in range(len(words))), 0]))

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <tuple>
#include <queue>
#include <bitset>
#include <unordered_map>
#include <tuple>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sys/time.h>

using namespace std;

void solve(long long N, long long K, string S){
  string ans = "";
  for (int i = 0; i < N; i++) {
    if (i+1 == K) {
      ans.push_back(tolower(S[i]));
    } else {
      ans.push_back(S[i]);
    }
  }
  std::cout << ans << std::endl;
}

int main(){
  string S;
  long long K;
  long long N;
  scanf("%lld",&N);
  scanf("%lld",&K);
  cin >> S;
  solve(N, K, S);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;

ll y[10000005];

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    rep(i,n){
        if(a[i]%2 != 0){
            cout << "first" << endl;
            return 0;
        }
    }
    cout << "second" << endl;
}


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

int main() {
  int a[5];

  for(int i=0; i<5; i++) {
    cin >> a[i];
  }
  sort(a, a+5, greater<int>());
  for(int i=0; i<5; i++) {
    if(i!=0) cout << " ";
    cout << a[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 1180
fun main(args: Array<String>) {
    readLine()
    val hl = readLine()!!.split(" ").map { it.toLong() }

    var count = -1
    var pre = Long.MAX_VALUE
    var max = 0
    hl.forEach { cur ->
        if (cur <= pre) {
            count++
        } else {
            if (count > max) {
                max = count
            }
            count = 0
        }
        pre = cur
    }
    if (count > max) {
        max = count
    }

    print(max)
}


Measured memory_bytes: 59684
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int n, m;
    cin>>n>>m;
    int ans = n*(n-1)/2 + m*(m-1)/2;
    cout<<ans<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long uLL;
typedef long double ldb;
typedef pair<int,int> pii;

int A[100];

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin>>n;
    for(int i = 0; i < n; ++i)
        cin>>A[i];
    sort(A, A+n);
    int ans = A[n-1] - A[0];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256