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

int main(){
  string s;
  cin >> s;
  int n = s.size();
  reverse(s.begin(),s.end());
  int tot = 0;
  int x = 1;
  int m = 2019;
  int ans = 0;
  vector<int> cnt(m,0);
  for(int i = 0; i < n; i++){
    cnt.at(tot)++;
    tot += ((s.at(i) - '0') * x);
    tot %= m;
    ans += cnt.at(tot);
    x = x * 10 % m;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3732
if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    mount = [0] * n
    tmp = 0
    for i in range(n - 1):
        if i % 2 == 1:
            tmp += a[i] * 2
    mount[0] = sum(a) - tmp

    for i in range(1, n):
        mount[i] = a[i - 1] * 2 - mount[i - 1]

    mount = list(map(str, mount))
    print(' '.join(mount))

Measured memory_bytes: 18456
use std::env;
use std::io::*;
use std::str::*;
use std::mem;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
fn read_char() -> char {
    let c = read::<String>();
    let c = c.chars().collect::<Vec<char>>();
    c[0]
}
fn read_String_Vec() -> Vec<char> {
    let S = read::<String>();
    S.chars().collect::<Vec<char>>()
}

fn vecchar_to_String(Vs: Vec<char>) -> String {
    let mut S = String::new();
    for i in 0..Vs.len() {
        S.push(Vs[i]);
    }
    S
}

/*
A : 65
Z : 90
a : 97
z : 122
*/

/*
let N = read::<i32>();
let S = read::<String>();
let S = read_String_Vec();
let C = read_char();
*/

/*
 .to_string() : * -> String
 &*S          : String -> &str
*/

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let a = read::<i64>();
    let b = read::<i64>();
    let x = read::<i64>();

    /*
        5 12 3
        6, 9, 12
    */
    let upper = b / x;
    let bottom = {
        if a%x == 0 {
            a/x
        } else {
            a / x + 1
        }
    };
    println!("{}", upper - bottom+1);
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n % func(n) == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	static int func(int x) {
		int ret = 0;
		while(x > 0) {
			ret += x % 10;
			x /= 10;
		}
		return ret;
	}

}


Measured memory_bytes: 21844
#!/usr/bin/env python
# -*- coding: utf-8 -*-

str1 = input()
str2 = input()
c11, c12, c13 = [i for i in str1]
c21, c22, c23 = [i for i in str2]

if c11 == c23 and c12 == c22 and c13 == c21:
    print("YES")
else:
    print("NO")

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

typedef long long ll;
typedef pair<int, int> P;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<P> p;
  int a, b;
  for (int i = 0; i < N; i++) {
    cin >> a >> b;
    p.push_back(P(a, b));
  }
  sort(p.begin(), p.end());

  for (int i = 0; i < p.size(); i++) {
    if (K <= p[i].second) {
      cout << p[i].first << endl;
      break;
    }
    K -= p[i].second;
  }

  return 0;
}


Measured memory_bytes: 1400
n=int(input())
d,x=map(int,input().split())

mans=[]
for i in range(n):
    mans.append(int(input()))

#print(mans)
cho=[]

for j in mans:
    cnt=1
    y=1+j
    while True:
        if y<=d:
            y+=j
            cnt+=1
        else:
            break
            
    cho.append(cnt)
print(sum(cho)+x)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgramingStudying2
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = new int[n];
            var b = new int[n];
            var c = new int[n];

            for(int i = 0; i < n; i++)
            {
                var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
                a[i] = input[0];
                b[i] = input[1];
                c[i] = input[2];
            }

            var dp = new int[n, 3];
            dp[0, 0] = a[0];
            dp[0, 1] = b[0];
            dp[0, 2] = c[0];

            for(int i = 1; i < n; i++)
            {
                dp[i, 0] = Math.Max(dp[i - 1, 1] + a[i], dp[i - 1, 2] + a[i]);
                dp[i, 1] = Math.Max(dp[i - 1, 2] + b[i], dp[i - 1, 0] + b[i]);
                dp[i, 2] = Math.Max(dp[i - 1, 0] + c[i], dp[i - 1, 1] + c[i]);
            }
            Console.WriteLine(Math.Max(dp[n - 1, 0], Math.Max(dp[n - 1, 1], dp[n - 1, 2])));
        }
    }
}

Measured memory_bytes: 49008
#include <bits/stdc++.h>
//#define int long long
using namespace std;
int main() {
  int n;
  cin >> n;
  int n1 = n / 100;
  int n2 = n % 10;
  if (n1 == n2) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int S[11][11] = {};
    int k[10];
    rep(i, M) {
        cin >> k[i];
        rep(j, k[i]) {
            int s; cin >> s;
            S[i][s] = 1;
        }
    }
    // rep(i, M) {
    //     rep(j, 10) {
    //         cout << S[i][j + 1] << " ";
    //     }
    //     cout << endl;
    // }
    int P[11];
    rep(i, M) cin >> P[i];
    int sum = pow(2, N) + 0.5;
    int ans = 0;
    rep(i, sum) {
        bool ok = true;
        rep(j, M) {
            int bit = i;
            int cnt = 0;
            rep(l, 10) {
                if (bit % 2 && S[j][l + 1]) {
                    cnt++;
                }
                bit /= 2;
            }
            //cout << cnt << " " << P[j] << " " << i << endl;
            if (cnt % 2 != P[j]) ok = false;
        }
        if (ok) ans++;

    }
    cout << ans << endl;

    return 0;
}


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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}

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

    static int64_t dp[62][3];
    dp[61][0] = 1;
    for(int d=60; d>=0; d--) for(int a=0; a<3; a++) for(int b=0; b<3; b++){
        int c = min(2, 2*a + nth_bit(N, d) - b);
        if(c >= 0) add(dp[d][c], dp[d+1][a]);
    }
    int64_t ans = (dp[0][0] + dp[0][1] + dp[0][2]) % MOD;
    cout << ans << endl;
}


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

namespace ABC073A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;
            n = int.Parse(Console.ReadLine());

            if (n % 10 == 9 || n / 10 == 9)
                Console.WriteLine("Yes");

            else
                Console.WriteLine("No");

            Console.ReadKey();


        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std ;
#define ll         long long
#define IOS         ios_base::sync_with_stdio(false);   cin.tie(NULL);
#define FOR(i,n)     for(ll i=0;i<n;i++)
#define REP(i,k,n)  for(ll i=k;i<n;i++)
#define nl         "\n"
#define BUFFER         cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define SORT        sort(a,a+n);
#define mod         1000000007
#define pb          push_back

int main()
{
    ll a,b;
    cin>>a>>b;
    if(2*b>=a)
    cout<<0<<nl;
    else
    cout<<a-2*b<<nl;
     
return 0;
}


Measured memory_bytes: 256
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b = rs()
if a<b:
  print('<')
elif a==b:
  print('=')
else:
  print('>')

Measured memory_bytes: 27132
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int p, q, r;
	cin >> p >> q >> r;
	int s = max(p, max(q, r));
	if (s == p) {
		cout << q + r << endl;
	}
	else if (s == q) {
		cout << p + r << endl;
	}
	else {
		cout << p + q << endl;
	}
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var ar = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        Array.Sort(ar);
        WriteLine(ar.Where((va, index) => index % 2 == 0).Sum());
       
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
const ll longinf=1ll<<60;
const int inf=(1<<30)-1;

ll mod=1e9+7;

int main(){
      int n,a,b,c,d;
      cin>>n>>a>>b>>c>>d;
      --a,--b,--c,--d;
      string s;
      cin>>s;
      s.push_back('#');
      bool ok=true;
      bool ok2=true;
      if(c<d){
            for(int i=a;i<=d-1;i++){
                  if(s[i]=='#'&&s[i+1]=='#'){
                        ok=false;
                  }
            }
            if(ok){
                  cout<<"Yes"<<endl;
            }
            else{
                  cout<<"No"<<endl;
            }
      }
      if(c>d){
            for(int i=a;i<=c-1;i++){
                  if(s[i]=='#'&&s[i+1]=='#'){
                        ok=false;
                  }
            }
            ok2=false;
            for(int i=b-1;i<=d-1;i++){
                  if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.'){
                        ok2=true;
                  }
            }
            if(ok&&ok2){
                  cout<<"Yes"<<endl;
            }
            else{
                  cout<<"No"<<endl;
            }
      }
      return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
import java.util.LinkedList;
import java.util.Collections;

public class Main{
	
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		LinkedList<Integer> scores = new LinkedList<>();
		
		// input
		final int NUM = scan.nextInt();
		int sum = 0;
		for(int i = 0; i < NUM; i++){
			int temp = scan.nextInt();
			scores.add(temp);
			sum += temp;
		}
		
		// sort
		Collections.sort(scores);
		
		// search
		int count = 0;
		while(sum % 10 == 0 && scores.size() > 0){
			if((sum - scores.peek()) % 10 != 0){
				sum -= scores.poll();
			} else {
				scores.add(scores.poll());
			}
			count++;
			if(count == NUM){
				break;
			}
		}
		
		// answer
		if(sum % 10 == 0){
			System.out.println(sum % 10);
		} else {
			System.out.println(sum);
		}
		
	}
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
string to_str(ll x){string res; while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return res;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end

typedef pair<ll,ll> P;
void p_max(P& a,P b){
   if(a.first<b.first){a.second=max(a.first,b.second); a.first=b.first;}
   else chmax(a.second,b.first);
}

int main(){
   int n; scanf("%d",&n);
   vector<P> dp(1<<n);
   rep(i,0,1<<n){
      int tmp; scanf("%d",&tmp);
      dp[i]={tmp,-INF};
   }
   rep(i,0,n)rep(mask,0,1<<n)if(mask>>i&1){
      p_max(dp[mask],dp[mask&~(1<<i)]);
   }
   ll res=-INF;
   rep(mask,0,1<<n){
      chmax(res,dp[mask].first+dp[mask].second);
      if(mask)printf("%lld\n",res);
   }
   return 0;
}

Measured memory_bytes: 7168
#include<iostream>
#include<set>
using namespace std;

int main(){
    long N,temp,templ,tempu;
    long a[200002];
    long amap[200002];
    set <long> st{0,200001};
    long long int minsum=0;


    cin >> N;
    for(long i=1;i<=N;i++){
        cin >> temp;
        a[i]=temp;
        amap[temp]=i;
    }


    for(long i=1;i<=N;i++){
        st.insert(amap[i]);
        auto itr=st.find(amap[i]);
        itr--;
        if(*itr==0){
            templ = 0;
        }
        else{
            templ = *itr;
        }
        itr++;
        itr++;
        if(*itr==200001){
            tempu = N+1;
        }
        else{
            tempu = *itr;
        }
        minsum += (amap[i]-templ)*(tempu-amap[i])*i;
        //cout << "lower : " << templ << " upper : " << tempu << "\n";
    }

    cout << minsum << "\n";
    return 0;
}

Measured memory_bytes: 11136
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll A,B;
	string s;
	while(cin>>A>>B>>s) {
		ll ans=1;
		REP(i, s.size()) {
			if(i==A) ans&=s[i]=='-';
			else ans&=IN(s[i]-'0', 0, 10);
		}
		cout<<YN(ans)<<endl;
	}
	
	return 0;
}


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

int main(void){
    char str[100];
    scanf("%s",str);
    int slen =  strlen(str);
    int flag = 0;
    for(int i = 0;i < ((slen-1)/2+1)/2;i++)if(str[i] != str[(slen-1)/2-i-1] || str[i+(slen-1)/2+1] != str[(slen-1)/2-i-1+(slen-1)/2+1])flag = 1;
    for(int i = 0;i < (slen+1)/2;i++)if(str[i] != str[slen-1-i])flag =1;
    puts(flag?"No":"Yes");
    return 0;
}

Measured memory_bytes: 128
//Achen
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Rep(i,a,b) for(int i=(a);i>=(b);i--)
#define Formylove return 0
const int N=32777,p=1e9+7;
typedef long long LL;
typedef double db;
using namespace std;
int n,m,a[123],b[123],mp[20][20];
LL pr[123],c[N],f[N],to[N];
LL ans;

template<typename T> void read(T &x) {
    char ch=getchar(); x=0; T f=1;
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') f=-1,ch=getchar();
    for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0'; x*=f;
}

//#define ANS
int main() {
#ifdef ANS
    freopen("1.in","r",stdin);
    freopen("1.out","w",stdout);
#endif
	read(n); read(m);
	pr[0]=1;
	For(i,1,120) pr[i]=2LL*pr[i-1]%p;
	For(i,1,m) {
		read(a[i]); read(b[i]); 
		mp[a[i]][b[i]]++;
		mp[b[i]][a[i]]++;
		c[pr[a[i]-1]+pr[b[i]-1]]++;
	}
	For(i,1,n) {
		For(j,1,n) if(mp[i][j]) to[pr[i-1]]|=pr[j-1];
	}
	int up=pr[n]-1;
	For(i,0,n-1) For(s,1,up) {
		if(!(s&pr[i])) {
			c[s|pr[i]]+=c[s];
			to[s|pr[i]]|=to[s];
		}
	}
	//For(i,1,up) printf("%d : %d\n",i,to[i]);
	f[1]=f[2]=1;
	For(s,3,up) {
		LL t=0;
		for(int ss=((s-1)&s);ss;ss=((ss-1)&s)) {
			if((!(s&2)&&(s&1)&&!(ss&2)&&(ss&1))||(!(s&1)&&(s&2)&&!(ss&1)&&(ss&2))) 
				t=(t+f[ss]*pr[c[s^ss]]%p)%p;
		}
		if((!(s&2)&&(s&1))||(!(s&1)&&(s&2))) f[s]=(pr[c[s]]-t+p)%p;
	}
	For(s,1,up) if((s&1)&&!(s&2)) {
		int S=(up^s)-2;
		for(int ss=S;;ss=((ss-1)&S)) {
			if((s&to[up^s^ss])!=0||((up^s^ss)&to[s])!=0) {
				if(!ss) break; else continue;
			}
			ans=(ans+f[s]*f[up^s^ss]%p*pr[c[ss]]%p)%p;
			if(!ss) break;
		}
	}
	printf("%lld\n",(pr[m]-ans+p)%p);
    Formylove;
}

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

int main() {
    int A,B;
    cin >> A >> B;
  int K =(A+B)/2;
  
  if (A%2==B%2) {
    cout << K << endl;
  }
  else{
    cout << "IMPOSSIBLE" << endl;
  }
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
 		Scanner scanner = new Scanner(System.in);
 		int N = scanner.nextInt();
 		int count = 0;
 		if (N == 1) {
 			count += 1;
 		}
 		for (int i = 2; i <= 9; i++) {
 			int x = N % i;
 			if (x == 0) {
 				int y = N / i;
 				if (y <= 9) {
 					count += 1;
 					//System.out.println(i);
 					break;
 				}
 			}
 		}
 		if (count > 0) {
 			System.out.println("Yes");
 		} else {
 			System.out.println("No");
 		}
	}
}


Measured memory_bytes: 23764
import java.util.*;

class Main{
	static int mod=1000000007;

	public static void main(String[] $){
		System.err.println();
		Scanner s=new Scanner(System.in);

		int n=s.nextInt();
		int[]q=new int[n];
		Arrays.setAll(q,i->s.nextInt());

		boolean[] a=new boolean[n+1];
		int c=0;

		for(int i=n;i>0;--i) {
			boolean t=q[i-1]==1;
			for(int j=i*2;j<=n;j+=i)
				t^=a[j];
			a[i]=t;
			if(a[i])
				++c;
		}
		System.out.println(c);
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<=n;++i)
			if(a[i])
				sb.append(i).append("\n");
		System.out.println(sb);
	}
}


Measured memory_bytes: 75432
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <list>

#define maxv 100005

using namespace std;

int n, m;
int u, v;
int ans = 0;

int dp[maxv];

list<int> graph[maxv];

int DFS(int u)
{
	if (dp[u]) return dp[u];
	
	dp[u] = 1;

	for (int v : graph[u])
	{
		dp[u] = max(dp[u], DFS(v) + 1);
	}

	return dp[u];
}

int main()
{
	cin >> n >> m;

	for (int i = 1; i <= m; i++)
	{
		scanf("%d%d", &u, &v);
		graph[v].push_back(u);
	}

	for (int i = 1; i <= n; i++)
	{
		ans = max(ans, DFS(i));
	}

	printf("%d", ans - 1);

	return 0;
}

Measured memory_bytes: 8320
import collections

n,m = map(int, input().split())
h = list(map(int, input().split()))

gb = [1]*n;
for i in range(m):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    if h[a] == h[b]:
        gb[a] = 0
        gb[b] = 0

    elif h[a]<h[b]:
        gb[a] = 0
    else:
        gb[b] = 0

l = collections.Counter(gb)
print(l[1])


Measured memory_bytes: 20508
from bisect import bisect_left as bs
from collections import deque
N=int(input())
pallet=deque()
cnt=0
for _ in range(N):
    A=int(input())
    place=bs(pallet,A)
    if place==0:
        cnt+=1
        pallet.appendleft(A)
    else:
        pallet[place-1]=A
print(cnt)

Measured memory_bytes: 7284
#include <bits/stdc++.h>
#include <fstream>
#include <stdlib.h>
#include <ctime>
typedef long long ll;
typedef long double ld;

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(100);
  //  freopen("input.txt","r",stdin);
    ll n;
    cin>>n;
    cout<<n*(n-1)/2;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
signed main(){
  char s[200];
  int a=10000;
  cin>>s;
  for(int i=0;i<150;i++){
    if(s[i]=='C')
      a=i;
    if(s[i]=='F')
      if(a<i){
	cout<<"Yes"<<endl;
	return(0);
      }
  }
  cout<<"No"<<endl;
    return(0);
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 998244353
int n,m,k;
int jc[200005];
int ans=0;

int quickpow(int a,int b)
{
	int ans=1,base=a;
	while(b)
	{
		if(b&1) ans=1ll*base*ans%MOD;
		b>>=1;
		base=1ll*base*base%MOD;
	}
	return ans%MOD;
}

void gjc(int n)
{
	jc[0]=1;
	for(int i=1;i<=n;i++) jc[i]=1ll*jc[i-1]*i%MOD;
	return;
}

int inv(int a){return quickpow(a,MOD-2);}

int C(int n,int m){return 1ll*jc[n]*inv(1ll*jc[m]*jc[n-m]%MOD)%MOD;}

int main()
{
	scanf("%d%d%d",&n,&m,&k);
	gjc(n);
	for(int i=0;i<=k;i++)
	{
		ans=(ans+1ll*m*C(n-1,i)%MOD*quickpow(m-1,n-i-1)%MOD)%MOD;
	}
	printf("%d\n",ans%MOD);
	return 0;
}

Measured memory_bytes: 4556
#include<iostream>
#include<vector>
#include<string>
#include<math.h> 
#include<algorithm> 
#include<stdio.h> 
#include<sstream>
#include<fstream>  
using namespace std; 
typedef long long ll; 
typedef long double ld; 

int ceil(int a, int m){
    // division of a and m
    if(a % m == 0){
        return a/m; 
    }
    else{
        return a/m + 1; 
    }
}

char nl = '\n'; 
char bl = ' ';
const int MOD = 1e9 + 7; 

int main(){

ios_base::sync_with_stdio(false);
cin.tie(NULL); 
long long a,b,c,d;

cin >> a >> b >> c >> d;


// a*c, b*d, 

cout << max(max(max(a*c, b*d), a*d), b*c); 


}



Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>
int main(void)
{
	int n, a,b,c,d;
	int cnt;

	while( scanf("%d", &n) != EOF )
	{
		cnt=0;
		for(a=0; a<=9; a++)
		for(b=0; b<=9; b++)
		for(c=0; c<=9; c++)
		for(d=0; d<=9; d++)
		{
			if(a+b+c+d == n)
			{
				//printf("%d %d %d %d\n", a, b, c, d);
				cnt++;
			}
		}
		printf("%d\n", cnt);
	}
    return 0;
}

Measured memory_bytes: 596
N,W = map(int,input().split())
v = [0]*N
w = [0]*N
for i in range(N): v[i],w[i] = map(int,input().split())
dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(N):
    for j in range(W+1):
        if j - w[i] < 0: dp[i+1][j] = dp[i][j]
        else: dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i])
print(dp[N][W])


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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  map<string, int> m;
  int n;
  cin >> n;
  string s;
  rep(i, n){
    cin >> s;
    m[s]++;
  }
  priority_queue<pair<int, string>> q;
  for (auto mp : m){
    pair<int, string> p;
    p.first=mp.second;
    p.second=mp.first;
    q.push(p);
        //std::cout << key << " => " << value << "\n";
    }
  int maxnum=q.top().first;
  vector<string> v;
  while(!q.empty() && maxnum==q.top().first){
    pair<int, string> f=q.top();q.pop();
    v.push_back(f.second);
  }
  sort(v.begin(), v.end());
  rep(i, v.size()){
    cout << v[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 32880
#include<stdio.h>
#define min(a,b) ((a)<(b)?(a):(b))

int main(){
	int n,i,ans=0,ans2=0;
	char s[100001];
	scanf("%s",s);
	int g=0;
	for(i=0;s[i]!=0;i++);
	g=i;
	for(i=0;i<g;i++){
		if(i%2==0){
			if(s[i]!='0')ans++;
		}if(i%2==1){
			if(s[i]!='1')ans++;
		}
	}for(i=0;i<g;i++){
		if(i%2==0){
			if(s[i]!='1')ans2++;
		}if(i%2==1){
			if(s[i]!='0')ans2++;
		}
	}
	printf("%d\n",min(ans,ans2));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using pint = pair<int, int>;
bool cmp(pint a, pint b) { return a.second < b.second; }

int main()
{
  int N, M;
  vector<pint> A;
  cin >> N >> M;
  
  A.resize(M);
  for (int i = 0; i < M; i++) cin >> A[i].first >> A[i].second;
  sort(A.begin(), A.end(), cmp);

  int res = 0;
  int endtime = 0;
  for (int i = 0; i < M; i++) {
    if (A[i].first >= endtime) {
      endtime = A[i].second;
      res++;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1 << 28;

vector<int> G[100000];
int X[100000];
int l[100000];
int r[100000];

bool dfs1(int v, int p, int mod) {
	if(X[v] != INF && X[v] % 2 != mod) return false;
	for(auto c : G[v]) {
		if(c == p) continue;
		if(!dfs1(c, v, 1 - mod)) return false;
	}
	return true;
}

bool dfs2(int v, int p) {
	for(auto c : G[v]) {
		if(c == p) continue;
		if(!dfs2(c, v)) return false;
		l[v] = max(l[v], l[c] - 1);
		r[v] = min(r[v], r[c] + 1);
		if(l[v] > r[v]) return false;
	}
	return true;
}

void dfs3(int v, int p) {
	for(auto c : G[v]) {
		if(c == p) continue;
		if(l[c] <= X[v] + 1 && X[v] + 1 <= r[c]) X[c] = X[v] + 1;
		if(l[c] <= X[v] - 1 && X[v] - 1 <= r[c]) X[c] = X[v] - 1;
		assert(X[c] != INF);
		dfs3(c, v);
	}
}

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

	int N, K;
	cin >> N;
	for(int i = 0; i < N - 1; i++) {
		int A, B;
		cin >> A >> B;
		A--, B--;
		G[A].push_back(B);
		G[B].push_back(A);
	}
	cin >> K;
	fill(X, X + N, INF);
	fill(l, l + N, -INF);
	fill(r, r + N, INF);

	int root = -1;
	for(int i = 0; i < K; i++) {
		int V;
		cin >> V;
		V--;
		cin >> X[V];
		l[V] = r[V] = X[V];
		if(root == -1) root = V;
	}

	if(!dfs1(root, -1, X[root] % 2) || !dfs2(root, -1)) {
		cout << "No" << endl;
		return 0;
	}

	dfs3(root, -1);

	cout << "Yes" << endl;
	for(int i = 0; i < N; i++) {
		cout << X[i] << endl;
	}
}

Measured memory_bytes: 13824
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,t,a,ans,i,q;
	float v,o=2000000000.0;
	cin>>n>>t>>a;
	for(i=0;i<n;i++)
	{
		cin>>q;
		v=t-q*0.006;
		if(fabs(a-v)<o)
		{
			ans=i+1;
			o=fabs(a-v);
		}
	}
	cout<<ans;
	return 0;
}

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

int main(){
	string s, left = "", right = "";
	cin >> s;
	for(int i = 0 ; i < s.size() ; i++){
		if(i < (s.size()-1)/2) left += s[i];
		if(i > (s.size()-1)/2) right += s[i];
	}
	
	bool left_palindrome = true, right_palindrome = true;
	string left_rev = left;
	reverse(left_rev.begin(), left_rev.end());
	string right_rev = right;
	reverse(right_rev.begin(), right_rev.end());
	
	for(int i = 0 ; i < left.size() ; i++){
		if(left[i] != left_rev[i]) left_palindrome = false;
		if(right[i] != right_rev[i]) right_palindrome = false;
	}
	
	if(left == right && left_palindrome && right_palindrome) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

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

using namespace std;

long long burger(long long n, long long x){
  if(n == 0ll) return 1ll;
  else if(x == 1ll) return 0ll;
  else if(x <= (1ll << (n + 1ll)) - 2ll){
    return burger(n - 1ll, x - 1ll);
  }else if(x <= (1ll << (n + 1ll)) - 1ll){
    return 1ll << n;
  }else if(x <= (1ll << (n + 2ll)) - 4ll){
    return burger(n - 1ll, x - (1ll << (n + 1ll)) + 1ll) + (1ll << n);
  }else{
    return (1ll << (n + 1ll)) - 1ll;
  }
}

int main(){
  long long n, x;
  cin >> n >> x;
  
  cout << burger(n, x) << endl;
  
  return 0;
}


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

using std::cin;
using std::cout;
using std::endl;
using std::sort;

struct AB
{
  // A 日後、報酬 B
  int A, B;
};

static AB ab[100001];
static int index[100001];
static int side_a[100001];
static int side_b[100001];

// A 昇順, B 降順
struct Compare_AB
{
  bool
  operator()(int const &lhs, int const &rhs) const
  {
    return ab[lhs].A < ab[rhs].A || (ab[lhs].A == ab[rhs].A && ab[rhs].B < ab[lhs].B);
  }
};

int
main()
{
  int N, M;
  cin >> N >> M;
  for (int n = 0; n < N; n++)
  {
    cin >> ab[n].A >> ab[n].B;
    index[n] = n;
  }
  index[N + 1] = N + 1;
  sort(&index[0], &index[N], Compare_AB());

  int ans = 0;
  int top = 0;
  int bot = 0;
  int *src = side_a;
  int *dest = side_b;
  int data_top = 0;
  int data_bot = 0;
  for (int m = 1; m <= M; m++)
  {
    for (; bot < N && ab[index[bot]].A <= m; bot++)
    {
    }
    if (top < bot)
    {
      // merge
      int new_data_bot = 0;
      int b = ab[index[top]].B;
      int data_b = ab[src[data_top]].B;
      while (top < bot && data_top < data_bot)
      {
        if (b < data_b)
        {
          dest[new_data_bot++] = src[data_top++];
          data_b = ab[src[data_top]].B;
        }
        else
        {
          dest[new_data_bot++] = index[top++];
          b = ab[index[top]].B;
        }
      }
      while (data_top < data_bot)
      {
        dest[new_data_bot++] = src[data_top++];
      }
      while (top < bot)
      {
        dest[new_data_bot++] = index[top++];
      }

      // swap(src, dest)
      auto tem = src;
      src = dest;
      dest = tem;

      data_top = 0;
      data_bot = new_data_bot;
    }
    if (data_top < data_bot)
    {
      ans += ab[src[data_top]].B;
      data_top++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    string S,T,U;
    cin >> S >> T;
    int A,B;
    cin >> A >> B >> U;
    if (S==U)
    cout << A-1 << ' ' << B;
    else if (T==U)
    cout << A << ' ' << B-1;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <unordered_set>
using namespace std;

int dp[310][310];
int sum[610][310];
char A[1100], B[1100];
char S[310][310];
int n, m;
int ans;

int calc(char A[1100], char B[1100]) {
	// printf("%s %s\n", A + 1, B + 1);
	memset(sum, 0, sizeof sum);
	for (int diff = -n; diff <= n; diff++)
		for (int i = 1; i <= n; i++) {
			sum[diff + n][i] = sum[diff + n][i - 1];
			if (1 <= i + diff && i + diff <= n && A[i] == B[i + diff])
				sum[diff + n][i] += 1;
		}
	memset(dp, 1, sizeof dp);
	dp[n][n] = 0;
	for (int i = n; i >= 0; i--)
		for (int j = n; j >= 0; j--) {
			if (i == n && j == n) {
				// printf("?? %d\n", sum[j - i + n][i]);
			}
			if (i) {
				dp[i - 1][j] = min(dp[i - 1][j], dp[i][j] + sum[j - i + n][i]);
			}
			if (j) {
				dp[i][j - 1] = min(dp[i][j - 1], dp[i][j] + sum[j - i + n][i]);
			}
		}
	return dp[0][0];
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)
		scanf("%s", S[i] + 1);
	for (int i = 1; i < m; i++) {
		for (int j = 1; j <= n; j++)
			A[j] = S[j][i], B[j] = S[j][i + 1];
		ans += calc(A, B);
		// printf("%d\n", ans);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>

#include<queue>

using namespace std;

struct NODE
{

};

int main() {

	int A, B;
	cin >> A >> B;

	int result = 0;
	if (A >= 13)
	{
		result = B;
	}
	else if (A >= 6)
	{
		result = B / 2;
	}

	cout << result << endl;

	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int x,y;
  	cin>>x>>y;
  	if(y%2==1) cout<<"No";
  	else if(y>=2*x&&y<=4*x) 	cout<<"Yes";
  	else				cout<<"No";
  	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <cmath>
#define pi 3.14159265358979
using namespace std;
typedef long long ll;
static const int INF = (1 << 21);

int main(void){
  int n, m;
  cin >> n >> m;
  
  vector<int> edge[100005];
  
  for(int i=0; i<m; i++) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  
  queue<int> q;
  q.push(0);
  vector<int> dist(n, INF);
  vector<int> pre(n, -1);
  dist[0] = 0;
  while(!q.empty()) {
    int v = q.front(); q.pop();
    for(int u : edge[v]) {
      if(dist[u] != INF) continue;
      dist[u] = dist[v] + 1;
      pre[u] = v;
      q.push(u);
    }
  }
  
  cout << "Yes" << endl;
  for(int i=0; i<n; i++) {
    if(i==0) continue;
    int ans = pre[i];
    ++ans;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 10568
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
// #define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    ll n;
    cin>>n;
    if(n<=999) cout<<"ABC"<<endl;
    else cout<<"ABD"<<endl;
    
    return 0;
}


Measured memory_bytes: 256
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}



int main(){
	FIO
	
	list<int> lis[1500];
	int n, q;
	cin >> n >> q;
	while(q--){
		int op;
		cin >> op;
		if(op == 0){
			int t, x;
			cin >> t >> x;
			lis[t].push_back(x);
		}else if(op == 1){
			int t;
			cin >> t;
			auto it = lis[t].begin();
			if(it != lis[t].end()){
				cout << *it;
				it++;
				while(it != lis[t].end())cout << ' ' << *it, it++;
			}
			cout << '\n';
		}else{
			int s, t;
			cin >> s >> t;
			lis[t].splice(lis[t].end(), lis[s]);
		}
	}
	return 0;
}



Measured memory_bytes: 18788
N, M = map(int, input().split())
res=[]
sto, WAsto=[],[]
for i in range(M):
    res.append([x for x in input().split()])
for i in range(N):
    sto.append(0)
    WAsto.append(0)
#print(res)
#print(int(res[0][0]))
#print(sto)

for i in range(M):
    if res[i][1]=="AC" and sto[int(res[i][0])-1]!=-1:
        WAsto[int(res[i][0])-1]=sto[int(res[i][0])-1]
        sto[int(res[i][0])-1]=-1 
    elif sto[int(res[i][0])-1]!=-1:
        sto[int(res[i][0])-1]+=1        

#for i in range(M):
#    if sto[i]!=-1:
#        WAsto[i]+=sto[i]
WA=sum(WAsto)
#print(sto)
AC=sto.count(-1)

print(AC,WA)

Measured memory_bytes: 27640
import java.util.Scanner;

/**
 * Created by khrom on 2017/06/11.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in).useDelimiter("\\s");
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        if (a < b && b < c)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

Measured memory_bytes: 26248
def main
  n, m = gets.split(" ").map{|v| v.to_i}
  x = gets.split(" ").map{|v| v.to_i}
  y = gets.split(" ").map{|v| v.to_i}

  xsum = 0
  (x.length - 1).times do |i|
    xsum += ((x[i+1] - x[i]) * (i+1) * (x.length - 1 - i))
  end

  ysum = 0
  (y.length - 1).times do |i|
    ysum += ((y[i+1] - y[i]) * (i+1) * (y.length - 1 - i))
  end

  puts ((xsum * ysum) % (10**9 + 7))
end

main


Measured memory_bytes: 15508
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]
x,y =map(int,input().split())
if x in a and y in a:print("Yes")
elif x in b and y in b:print("Yes")
elif x in c and y in c:print("Yes")
else :print("No")

Measured memory_bytes: 9132
n = int(input())

names = [input()[0] for i in range(n)]
prefix = 'MARCH'
cnt = [names.count(c) for c in prefix]

ans = 0
for i in range(5):
  for j in range(i + 1, 5):
    for k in range(j + 1, 5):
      ans += cnt[i] * cnt[j] * cnt[k]
      
print(ans)

Measured memory_bytes: 3864
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  ui N, M; cin >> N >> M;
  int X, Y; cin >> X >> Y;
  pair<int, int> Z{X, Y};

  vector<int> a(N), b(M);
  for(auto& x : a) cin >> x;
  for(auto& y : b) cin >> y;

  auto res = std::max(Z.first, *boost::max_element(a)) < std::min(Z.second, *boost::min_element(b));

  cout << (res ? "No War" : "War") << CRLF;
  return;
}

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

  solve();

  return 0;
}


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

vector<int> d,kouho;
int digit[5];

void dfs(int n,int i,bool flag){
    if(!kouho.empty())return;
    if(i==5){
        int res=digit[0]*10000+digit[1]*1000+digit[2]*100+digit[3]*10+digit[4];
        if(res>=n)kouho.push_back(res);
        return;
    }
    if(flag){
        digit[i]=0;
        dfs(n,i+1,true);
    }
    for(auto it=d.begin(); it!=d.end(); it++){
        digit[i]=*it;
        dfs(n,i+1,false);
    }
}

int main(){
    int n,k;
    int a[10];fill(a,a+10,0);
    cin>>n>>k;
    for(int i=0; i<k; i++){
        int in;
        cin>>in;
        a[in]=1;
    }
    for(int i=0; i<10; i++){
        if(a[i]==0){
            d.push_back(i);
        }
    }
    sort(d.begin(),d.end());
    dfs(n,0,true);
    cout<<*min_element(kouho.begin(),kouho.end())<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int t = 0;
    int result = 0;
    if (a != b) {
      t = Math.max(a,b);
      result = t + t - 1;
    } else {
      result = a + b;
    }
    System.out.println(result);
  }
}

Measured memory_bytes: 22612
/*  HARD WORK FOREVER PAYS  */
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define turbo(){	\
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL); \
}
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
int main()
{
	turbo();
	int n,i,j,cnt=0;
	cin>>n;
	int ara[n],vis[n+100]={0};
	for(i=0;i<n;i++) cin>>ara[i];
	i=1;
	while(i!=2){
		vis[i]=1;
		i=ara[i-1];
		if(vis[i]){
			cout<<-1<<"\n";
			return 0;
		}
		cnt++;
	}
	cout<<cnt<<"\n";
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;

int main() {
    int H, W;
    while (cin >> H >> W, H | W) {
        string s(W, '#');
        string t = '#' + string(W - 2, '.') + '#';
        cout << s << endl;
        for (int i = 0; i < H - 2; i++) {
            cout << t << endl;
        }
        cout << s << endl;
        cout << endl;
    }
    return 0;
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    cin >> skipws;

    string left = "qwertasdfgzxcvb";
    string right = "yuiophjklnm";

    vector<int> side(128, 0);
    for (char c : left)
        side[c] = 1;
    for (char c : right)
        side[c] = 2;

    for (;;) {
        string s;
        cin >> s;
        if (s == "#")
            break;

        int ans = 0;
        rep(i, 0, s.size() - 1) if (side[s[i]] != side[s[i + 1]]) ans++;
        cout << ans << endl;
    }
}


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

typedef long long ll;

int main() {
	ll l,r,ans=2e9;
	cin >> l >> r;
	if (r-l+1 <= 2019) {
		for (ll i=l; i<r; i++) {
			for (ll j=i+1; j<=r; j++) {
				ans = min(ans, ((i%2019)*(j%2019))%2019);
			}
		}
		cout << ans << '\n';
	} else {
		cout << 0 << '\n';
	}
	return 0;
}


Measured memory_bytes: 3596
import java.util.Scanner;

public class Main{
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    for(int i=0; i < 10000; i++) {
      int x = scan.nextInt();
      if(x == 0) {break;}
      System.out.println("Case " + (i+1) + ": " + x);
    }
  }
}

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

using namespace std;

float D, T, S;

int main(void)
{
    cin >> D >> T >> S;
    float time = D / S;

    if (time > T)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3716
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main(){
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  if((abs(a-c)<=d)||((abs(a-b)<=d)&&(abs(b-c)<=d))){
    printf("Yes");
  }
     else{
       printf("No");
     }
     
  return 0;
}


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


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	vector<int> res;
	for (int i = 0; i < s.size();++i) {
		string t = s.substr(i, 3);
		int T = stoi(t);
		res.push_back(T);
	}
	int ans = 999;
	rep(i, res.size()) {
		ans = min(ans, abs(753 - res[i]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
S = input()
T = input()
k = 0
x = 0
for i in range(len(S)-len(T)+1):
    s = S[i:]
    for j in range(len(T)):
        if s[j] == T[j]:
            x += 1
    if k<=x:
        k = x
    x = 0
print(len(T)-k)

Measured memory_bytes: 9076
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    long long n, k; std::cin >> n >> k;
    std::vector<std::vector<int>> a(62, std::vector<int>(n + 1));
    for (int i = 1; i <= n; i++) {
        std::cin >> a[0][i];
    }
    for (int t = 1; t <= 60; t++) {
        for (int i = 1; i <= n; i++) {
            a[t][i] = a[t - 1][a[t - 1][i]];
        }
    }
    int pos = 1;
    for (int t = 0; t <= 60; t++) {
        if ((k >> t) & 1) pos = a[t][pos];
    }
    std::cout << pos << std::endl;
    return 0;
}


Measured memory_bytes: 52628
import scala.io.StdIn

object Main extends App {

  private val n = StdIn.readLine().toInt
  val memo = Array.fill(n+1, n+1)(0)
  val p = Array.fill(n+1)(0)
  
  (0 until n).foreach{ i =>
    val Array(r, c) = StdIn.readLine().split(' ').map(_.toInt)
    p(i) = r 
    p(i+1) = c
  }
  //println(p.toList)
  
  def matrixChainMultiplication() = {
    (2 to n).foreach{ l =>
      (1 to (n - l + 1)).foreach{ i =>
        val j = i + l - 1
        memo(i)(j) = Int.MaxValue
        (i until j).foreach{ k =>
          memo(i)(j) = scala.math.min(memo(i)(j), memo(i)(k) + memo(k+1)(j) + p(i-1) * p(k) * p(j))
        }
      }
    }
  }
  
  matrixChainMultiplication()

  println(memo(1)(n))
  
}


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

using namespace std;

int main() {
  array<int, 10> h;
  for (int& i : h) cin >> i;
  partial_sort(h.begin(), h.begin() + 3, h.end(), greater<int>());
  for (int i = 0; i < 3; ++i) cout << h[i] << endl;
}

Measured memory_bytes: 1160