akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
#define _cTime (chrono::system_clock::now())
#define progress (chrono::duration_cast<chrono::milliseconds>(_cTime-_sTime).count())
#define reset _sTime=_cTime
auto reset;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	ll r=0,b=0;
	int n=s.size();
	rep(i,n){
		(s[i]=='0'?r++:b++);
	}
	cout<<min(r,b)*2<<endl;
}


Measured memory_bytes: 512
using System;
using static System.Console;

namespace abc176
{
    class Program
    {
        static void Main(string[] args)
        {
            var nxt = ReadLine().Split(' ');
            var n = double.Parse(nxt[0]);
            var x = int.Parse(nxt[1]);
            var t = int.Parse(nxt[2]);
            WriteLine((int)(Math.Ceiling(n / x) * t));
        }
    }
}


Measured memory_bytes: 27548
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>

using namespace std;
typedef long long LL;
const int maxn = 1e5 + 10, mod = 1e9 + 7;

int read()
{
	int x = 0, f = 1; char c = getchar();
	while(!isdigit(c)) { if(c == '-') f = 0; c = getchar(); }
	while(isdigit(c)) { x = (x << 3) + (x << 1) + (c ^ 48); c = getchar(); }
	return f ? x : -x;
}

struct mat
{
	int a[3][3];
	mat() { for(int i = 0; i <= 2; ++i) for(int j = 0; j <= 2; ++j) a[i][j] = 0;}
	mat operator * (const mat &A) const
	{
		mat tmp;
		for(int i = 0; i <= 2; ++i)
			for(int j = 0; j <= 2; ++j)
				for(int k = 0; k <= 2; ++k)
					(tmp.a[i][j] += (LL)a[i][k] * A.a[k][j] % mod) %= mod;
		return tmp;
	}
}w, now, spj;

void gao(int p)
{
	if(p <= 0) return ;
	mat x = w;
	//int fg = 0;
	//int fg = 1;
	while(p)
	{
		if(p & 1) now = x * now;
		p >>= 1; x = x * x;
	}
}

int s[maxn];

int main()
{

	int n = read(), m = read();
	for(int i = 1; i <= m; ++i) s[i] = read() + 1;
	int tmp[3][3] = {{1, 0, 1}, {2, 1, 2}, {1, 1, 2}};
	swap(w.a, tmp);
	int Tmp[3][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
	swap(now.a, Tmp);
	int TMP[3][3] = {{1, 0, 0}, {2, 1, 0}, {1, 1, 1}};
	swap(spj.a, TMP);
	int pos = 1;
	for(int i = 1; i <= m; ++i)
	{
		gao(s[i] - pos); pos = s[i] + 1;
		now = spj * now;
	}
	gao(n - pos + 1);
	//now = w * now;
	//now = w * w * w * w * w * now;
	/*
	for(int i = 0; i <= 2; ++i)
	{
		for(int j = 0; j <= 2; ++j)
			cout << now.a[i][j] << ' ';
		cout << endl;
	}*/
	//now = w * now;
	cout << now.a[2][0] << endl;

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MOD = 1e9 + 7;


//MAIN 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int H,W;
    char a[1001][1001];
    ll dp[1001][1001];
    cin>>H>>W;
    for(int i=1;i<=H;i++)
    {
        for(int j=1;j<=W;j++)
        {
            cin>>a[i][j];
            dp[i][j] = 0;
        }
    }
    dp[1][1] = 1;
    for(int i=1;i<=H;i++)
    {
        for(int j=1;j<=W;j++)
        {
            if(a[i][j] == '#')
            {
                continue;
            }
            if(i > 1)
            {
                dp[i][j] = (dp[i][j]+dp[i-1][j])%MOD;
            }
            if(j > 1)
            {
                dp[i][j] = (dp[i][j]+dp[i][j-1])%MOD;
            }
        }
    }
    cout<< dp[H][W] <<"\n";
    return 0;
}


Measured memory_bytes: 12388
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

int n, s[2100], ans;
int main() {
	cin >> n;
	REP(i, n)cin >> s[i];
	sort(s, s + n);
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				if (s[i] + s[j] <= s[k])break;
				ans++;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define MAXSIZE 1000002
#define MAXL 100
typedef long long int lli;

int main(){
    lli colatz_nums[MAXSIZE];
    lli index = 2;
    cin >> colatz_nums[1];
    int same_colatz_num_found = 0;
    while(!same_colatz_num_found){
        colatz_nums[index] = (colatz_nums[index - 1] % 2 == 0)? colatz_nums[index - 1] / 2 : 3 * colatz_nums[index - 1] + 1;
        //cout << "colatz[" << index << "] = " << colatz_nums[index] << endl;
        
        for(lli i = 1; i < index; i++){
            if(colatz_nums[i] == colatz_nums[index]){
                same_colatz_num_found = 1;
                break;
            }
        }
        
        if(!same_colatz_num_found) index++;
    }

    cout << index << endl;
    return 0;
}

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

using namespace std;

int main() {
  int H, N;
  cin >> H >> N;

  for (int i = 0; i < N; i++){
    int A;
    cin >> A;
    H -= A;
  }

  if (H <= 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }


  return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        new Program().Solve();
        Console.ReadKey();
    }

    Scanner sc = new Scanner();
    void Solve()
    {
        long a = sc.NextLong();
        string op = sc.Next();
        long b = sc.NextLong();
        if (op == "+")
            Console.WriteLine(a + b);
        else
            Console.WriteLine(a - b);
    }
    // ------------------------------------- //
    int Max(int v1, int v2) { return Math.Max(v1, v2); }
    int Min(int v1, int v2) { return Math.Min(v1, v2); }
    int[][] CreateArray2D(int n1, int n2)
    {
        int[][] ary = new int[n1][];
        for (int i = 0; i < n1; i++) ary[i] = new int[n2];
        return ary;
    }
}
class Scanner
{
    public Scanner() { }
    private string[] buff = null;
    private int bIndex = 0;
    public string Next()
    {
        if (buff == null || bIndex >= buff.Length)
        {
            buff = Console.ReadLine().Split(' ');
            bIndex = 0;
        }
        return buff[bIndex++];
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
}
class Pair<T, K>
{
    public Pair() { }
    public Pair(T f, K s)
    {
        first = f;
        second = s;
    }
    public T first {get; set;}
    public K second {get; set;}
}

Measured memory_bytes: 2776
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef pair<LL, LL> PII;
typedef vector<string> VS;
inline LL toInt(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(x,c) for(auto x: (c))
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define REVERSE(c) reverse((c).begin(), (c).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define STABLE_SORT(c) stable_sort((c).begin(),(c).end())
#define STABLE_RSORT(c) stable_sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique((c).begin(), (c).end()), (c).end());
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x)  cerr << #x << " = " << (x) << endl;


int main() {
	LL N;
	string A, B, C;
	cin >> N;
	cin >> A;
	cin >> B;
	cin >> C;

	LL ans = 0;
	REP(i, N) {
		multiset<char> S;
		S.insert(A[i]);
		S.insert(B[i]);
		S.insert(C[i]);
		LL max_count = 0;
		if (S.count(A[i]) > max_count) {
			max_count = S.count(A[i]);
		}
		if (S.count(B[i]) > max_count) {
			max_count = S.count(B[i]);
		}
		if (S.count(C[i]) > max_count) {
			max_count = S.count(C[i]);
		}
		ans += 3 - max_count;
	}

	cout << ans << endl;
		
	
    return 0;
}


Measured memory_bytes: 256
//404 Not Found {=}7 (o)7 (x)7
#include <bits/stdc++.h>
using namespace std;
#define apppend push_back
#define endl "\n"
#define dbug(x) cout << #x << "=" << x << endl

typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pii;

const int maxn = 1e5 + 10, inf = 1e9, mod = 1e9 + 7;
int ac[maxn];
int wa[maxn];
int was;
int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cout << setprecision(30);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int id;
        string s;
        cin >> id >> s;
        if (!ac[id])
        {
            if (s == "AC")
            {
                ac[id] = 1;
                was += wa[id];
            }
            else
                wa[id]++;
        }
    }
    cout << accumulate(ac + 1, ac + n + 1, 0) << ' ' << was;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // 998244353 //  //100000000
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << " "; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}
ll lcm(ll a, ll b) {return (a/__gcd(a, b))*b; }

void solve(){
    ll n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];
    ll ans = inf;
    for(ll i = -100; i <= 100; i++){
        ll cost = 0;
        rep(j, n) cost += (i-a[j])*(i-a[j]);
        ans = min(ans, cost);
    }cout << ans;
}

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


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

typedef long long ll;
const long long LINF = 1LL << 60;
const long long LMINF = 1LL << 63;
const int INF = 1 << 30;

#define REP(i,n) for(int i = 0;i < n;++i)
#define REPS(i,x) for(int i = 1;i <= (int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i >= 0;i--)
#define RREPS(i,x) for(int i=((int)(x));i > 0;i--)
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << x << "\n"

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



int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n)cin >> a[i];
    
    int cn = 1;

    while(n >= cn){
        auto result = find(ALL(a), cn);
        int dis = distance(a.begin(), result) + 1;
        if(cn == n){
            cout << dis << endl;
        }else{
            cout << dis << " ";
        }
        cn++;
    }
    return 0;
}

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

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

using namespace std;

template<class G>
class Fenwick_tree{
	vector<G> a;
public:
	Fenwick_tree(int n):a(n){}
	void add(int i,G val){
		for(i++;i<=a.size();i+=i&-i) a[i-1]+=val;
	}
	G sum(int l,int r)const{
		if(l==0){
			G res{};
			for(;r>0;r-=r&-r) res+=a[r-1];
			return res;
		}
		return sum(0,r)-sum(0,l);
	}
	int lower_bound(G val)const{
		if(val<=G{}) return 0;
		int x=0,k;
		for(k=1;k<=a.size();k<<=1);
		for(k>>=1;k>0;k>>=1) if(x+k<=a.size() && a[x+k-1]<val) val-=a[x+k-1], x+=k;
		return x;
	}
	int upper_bound(G val)const{
		if(val<G{}) return 0;
		int x=0,k;
		for(k=1;k<=a.size();k<<=1);
		for(k>>=1;k>0;k>>=1) if(x+k<=a.size() && a[x+k-1]<=val) val-=a[x+k-1], x+=k;
		return x;
	}
};

int n,bad[100000];

vector<pair<int,int>> V;

Fenwick_tree<int> F(0);
int ans[100000];

bool dfs(int i){
	if(i==n) return true;

	int next=-1;
	for(auto p:V){
		int deg=p.first,x=p.second;
		if(deg==n-1 && F.sum(x,x+1)==1){
			if(next!=-1) return false;
			next=x;
		}
	}
	if(next!=-1){
		int x=next;
		if(i==0 || bad[ans[i-1]]!=x){
			F.add(x,-1);
			ans[i]=x;
			for(auto& p:V) if(bad[x]!=p.second) p.first++;
			if(dfs(i+1)) return true;
			for(auto& p:V) if(bad[x]!=p.second) p.first--;
			F.add(x,1);
		}
		return false;
	}

	for(int p=1;;p++){
		int x=F.lower_bound(p);
		if(x==n) break;
		if(i==0 || bad[ans[i-1]]!=x){
			F.add(x,-1);
			ans[i]=x;
			for(auto& p:V) if(bad[x]!=p.second) p.first++;
			if(dfs(i+1)) return true;
			for(auto& p:V) if(bad[x]!=p.second) p.first--;
			F.add(x, 1);
		}
	}
	return false;
}

int main(){
	scanf("%d",&n);
	rep(i,n) scanf("%d",&bad[i]), bad[i]--;

	if(n==2) return puts("-1"),0;

	F=Fenwick_tree<int>(n);
	rep(i,n) F.add(i,1);

	vector<int> deg(n);
	rep(i,n) deg[bad[i]]++;
	vector<pair<int,int>> p(n);

	rep(i,n) p[i]={-deg[i],i};
	sort(p.begin(),p.end());
	rep(i,min(50,n)) V.emplace_back(-p[i].first,p[i].second);

	bool ok=dfs(0);

	if(ok){
		rep(i,n) printf("%d%c",ans[i]+1,i<n-1?' ':'\n');
	}
	else{
		puts("-1");
	}

	return 0;
}


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

#define MOD (1000000007)

using namespace std;

long long f(long long n){
    static long long memo[1000000] = {0};
    if(memo[n] > 0) return memo[n];
    if(n == 0) return 1;
    return memo[n] = (n * f(n - 1)) % MOD;
}

long long expmod(long long b, long long e){
    if(e == 0) return 1;
    long long ret = expmod(b, e / 2);
    ret *= ret;
    ret %= MOD;
    if(e % 2 == 1){
        ret *= b;
        ret %= MOD;
    }
    return ret;
}

long long inv(long long n){
    return expmod(n, MOD - 2);
}

int main(void){
    long long N, K;
    cin >> N >> K;
    for(int i = 1; i <= K; i++){
        long long ans = 1;
        ans *= f(K - 1);
        ans *= inv(f(K - i));
        ans %= MOD;
        ans *= inv(f(i - 1));
        ans %= MOD;
        ans *= f(N - K + 1);
        ans %= MOD;
        ans *= inv(f(i));
        ans %= MOD;
        if(N - K - i + 1 >= 0){
            ans *= inv(f(N - K - i + 1));
            ans %= MOD;
        }else{
            ans = 0;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import math
def sosu(n) :
    if n == 1 :
        return False
    elif n == 2 :
        return True
    elif n % 2 == 0 :
        return False
    else :
        for i in range(3, int(math.sqrt(n))+1, 2) :
            if n % i == 0 :
                return False
        return True

while True :
    a, d, n = map(int, input().split())
    if a == 0 and d == 0 and n == 0 :
        break
    
    i = 1
    x = a
    while True :
        if i > n :
            break
        if sosu(x) :
            ans = x
            i += 1
        x += d
    print(ans)
        


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

int main() {
  int X;
  cin >> X;
  int Q,R,C;
  Q = X;
  while(true){
    if(Q == 0){
      break;
    }
    R = Q % 10;
   
    Q = Q / 10;
    C += R;
  }
  if(X % C == 0){
    cout << "Yes" << endl;
  }
  if(X % C > 0){
  cout << "No" << endl;
  }
 
}

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

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];

bool X[N][N];

void initialize(){
  int i;
  for(i=0;i<N;i++){row[i]=FREE,col[i]=FREE;}
  for(i=0;i<2*N-1;i++){dpos[i]=FREE;dneg[i]=FREE;}
}

void printBoard(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(X[i][j]){
	if(row[i]!=j) return;
      }
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i] == j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void recursive(int i){
  int j;
  if(i==N){
    printBoard(); return;
  }

  for(j=0;j<N;j++){
    if(NOT_FREE == col[j] ||
       NOT_FREE == dpos[i+j] ||
       NOT_FREE == dneg[i-j+N-1]) continue;

    row[i] = j; col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;

    recursive(i+1);
    row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1] = FREE;
  }
}

int main(){
  int i,j,k;
  int r,c;
  initialize();

  for(i=0;i<N;i++)
    for(j=0;j<N;j++)X[i][j]=false;


  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d%d",&r,&c);
    X[r][c] = true;
  }

  recursive(0);

  return 0;
}
    



Measured memory_bytes: 2108
N = int(input())
S = input()
al1 = [chr(ord('A') + i) for i in range(26)]
al2 = [chr(ord('A') + i) for i in range(26)]
al = al1 + al2
ans = ""
for i in range(len(S)):
    ans += al[al.index(S[i]) + N]
print(ans)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
n, m, X, Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))

x.sort()
y.sort()

for z in range(X+1,Y+1):
    if x[-1] < z and y[0] >= z:
        print("No War")
        break
else:
    print("War")


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main() {
	int ans = 1;
	int a;
	cin >> a;
	int b[a];
	for (int i = 0;i < a;i++) {
		cin >> b[i];
	}
	int c[a / 2];
	for (int i = 0;i < (a / 2);i++) {
		c[i] = 0;
	}
	for (int i = 0;i < a;i++) {
		if (b[i] != 0) {
			c[(b[i] - 1) / 2] = c[(b[i] - 1) / 2] + 1;
		}
	}
	for (int i = 0;i < (a / 2);i++) {
		if (c[i] == 2) {
			ans = ans * 2 % 1000000007;
		}
		else {
			ans = 0;
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define long long long
#define ull unsigned long long
#define up(i,a,b) for (int i=a; i<=b; i++)
#define down(i,a,b) for (int i=a; i>=b; i--)
#define endl '\n'
#define pb push_back
#define X first
#define Y second
#define II pair<int, int>
#define III pair<int, pair<int, int> >
#define V vector
#define debug(X) cerr<< #X << " = " <<X << endl
#define debug2(X,Y) cerr<< #X << " = " <<X << ","<<#Y<<" = "<<Y<<endl
#define show(X,a,b) {cerr << #X << " = "; up(__,a,b) cerr << X[__] << ' '; cerr << endl;}
#define gc getchar
#define pc putchar

using namespace std;

inline void read(int &x)
{
    register int c = gc();
    x = 0;
    int neg = 0;
    for (;((c<48 || c>57) && c != '-') ;c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}
inline void writeln(int x){

         char buffor[21];
         register int i=0;
         int neg=0; if (x<0) {neg=1; x= -x;}
         do{
               buffor[i++]=(x%10)+'0';
               x/=10;
            } while(x);
           i--;
           if (neg) pc('-');
           while(i>=0) pc(buffor[i--]);
           pc('\n');
       }
const int N= (int) 1e5+10;
int n,m,a[N];
long it[4*N],low[4*N],high[4*N],f[4*N],v[4*N];
void input()
{
    cin>>n>>m;
    up(i,1,n) cin>>a[i];
}
//it
void build(int x,int l,int r)
{
    low[x]= l; high[x]= r; it[x]= f[x]= v[x]= 0;
    if (l==r) return;
    int m= (l+r)/2;
    build(2*x,l,m); build(2*x+1,m+1,r);
}
long sum(long f,long v,long sz)
{
    return f*sz+ (sz-1)*sz/2* v;
}
void downlazy(int x)
{
    it[2*x]+= sum(f[x],v[x],high[2*x]- low[2*x]+1);
    f[2*x]+= f[x]; v[2*x]+= v[x];
    it[2*x+1]+= sum(f[x]+(high[2*x]-low[2*x]+1)*v[x], v[x], high[2*x+1]- low[2*x+1]+1 );
    f[2*x+1]+= f[x]+(high[2*x]-low[2*x]+1)*v[x]; v[2*x+1]+= v[x];
    f[x]= v[x]= 0;
}
void update(int x,int l,int r,long newf,long newv)
{
    if (l> high[x] or r< low[x]) return;
    if (low[x]>= l and high[x]<= r)
    {
    	long sz= high[x]- low[x]+1;
        it[x]+= sum(newf+ (low[x]-l)* newv,newv,sz);
        f[x]+= newf+ (low[x]-l)* newv; v[x]+= newv;
        return;
    }
    downlazy(x);
    update(2*x,l,r,newf,newv); update(2*x+1,l,r,newf,newv);
    it[x]= it[2*x]+ it[2*x+1];
}
long query(int x,int l)
{
     if (l> high[x] or l< low[x]) return 0;
     if (low[x]== high[x]) return it[x];
     downlazy(x);
     return query(2*x,l)+ query(2*x+1,l);
}
//

void solve()
{
    build(1,1,m);
    up(i,1,n-1)
    {
        if (a[i]< a[i+1]) update(1,a[i]+1,a[i+1],0,1);
        else if (a[i]> a[i+1])
		{
			update(1,a[i]+1,m,0,1);
			update(1,1,a[i+1],m-a[i],1);
		}
    }
    long savemax= 0;
    up(i,1,m)
    {
        savemax= max(savemax, query(1,i));
        //debug(query(1,i));
    }
    long res=0;
    up(i,1,n-1) res+= (a[i+1]-a[i]+m-1)%m+1;

    cout<<res-savemax;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);// scanf phai bo
    #define TASK "tmp"
    //freopen(TASK".inp","r",stdin);
    //freopen(TASK".out","w",stdout);

    input();
    solve();

    return 0;
}


Measured memory_bytes: 15232
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <algorithm>
#define INF 1e7
using namespace std;
typedef pair<int,int> pii;

int n, m, u, v, s, f, ans;
pii p;
vector<vector<int>> e;
vector<int> d;
priority_queue<pii, vector<pii>, greater<pii>> q;

int main(){
	cin >> n >> m;
	e.resize(3*n);
	d.resize(3*n, INF);
	for (int i = 0; i < m; ++i){
		cin >> u >> v;
		e[3*(u-1)].push_back(3*(v-1)+1);
		e[3*(u-1)+1].push_back(3*(v-1)+2);
		e[3*(u-1)+2].push_back(3*(v-1));
	}
	cin >> s >> f;
	s = 3*(s-1);
	f = 3*(f-1);
	d[s] = 0;
	q.emplace(0, s);
	while (!q.empty()){
		p = q.top(); q.pop();
		u = p.second;
		if (d[u] < p.first) continue;
		for (auto& edge: e[u]){
			if (d[edge] > d[u] + 1){
				d[edge] = d[u] + 1;
				q.emplace(d[edge], edge);
			}
		}
	}
	printf("%d", (d[f] % 3 == 0) ? d[f]/3 : -1);
}

Measured memory_bytes: 17792
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h> 
using namespace std;

typedef long long ll;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0) 
#define rep(pp,nn) for (int ii = pp; ii < nn; ++ii)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

string int_to_string(int x) {
    stringstream ss;
	ss << x;
	string ni = ss.str();
	return ni;
}
int string_to_int(string x) {
	int n;
	stringstream s(x);
	s >> n;
	return n;
}

int64_t power_mod(ll a, ll b, ll mo) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = (ans % mo * a % mo) % mo;
		}
		a = (a % mo * a % mo) % mo;
		b /= 2;
	}
	return ans;
}
int64_t POW(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = ans * a;
		}
		a = a * a;
		b /= 2;
	}
	return ans;
}

vector<int64_t> INVERSE(int64_t nn, int64_t mo) {
	vector<int64_t> inv(nn + 1);
	vector<int64_t> mul(nn + 1);
	inv[0] = 1;
    inv[1] = 1;
	for (ll i = 2; i <= nn; ++i) {
		inv[i] = (mo - (mo / i) * inv[mo % i] % mo) % mo; 
	}
	mul[0] = 1;
	for (int i = 1; i <= nn; ++i) {
		mul[i] = (mul[i - 1] * inv[i]) % mo;
	}
	return mul;
}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif



int main() {
	int n;
	cin  >> n;
	vector<int64_t> a(n);
	int64_t ans = 1000;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		//if (i) {
			//if (v[i] > v[i - 1]) {
				//int64_t x = ans / v[i - 1];
				//ans = ans % v[i - 1];
				//ans += x * v[i];
			//}
		//}
	}
	for (int i = 0; i + 1 < n; ++i) {
		int64_t stocks = ans / a[i];
		ans += stocks * (max(a[i + 1] - a[i],(int64_t)0));
	}
	cout << ans;
}













Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		String S;
		Scanner sc = new Scanner(System.in);
		S = sc.next();
		int minIndex = 0;
		int maxIndex = S.length() - 1;
		while (minIndex < maxIndex) {
			if (S.charAt(minIndex++) != S.charAt(maxIndex--)) {
				System.out.println("No");
				System.exit(0);
			}
		}
		minIndex = 0;
		maxIndex = (S.length() - 1) / 2 - 1;
		while (minIndex < maxIndex) {
			if (S.charAt(minIndex++) != S.charAt(maxIndex--)) {
				System.out.println("No");
				System.exit(0);
			}
		}
		minIndex = (S.length() + 3) / 2 - 1;
		maxIndex = S.length() - 1;
		while (minIndex < maxIndex) {
			if (S.charAt(minIndex++) != S.charAt(maxIndex--)) {
				System.out.println("No");
				System.exit(0);
			}
		}
		System.out.println("Yes");
		sc.close();
	}

}

Measured memory_bytes: 22740
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
nodes=[[] for i in range(N)]
for i in range(N-1):
    a,b=MAP()
    nodes[a-1].append(b-1)
    nodes[b-1].append(a-1)
C=LIST()

C.sort(reverse=True)

ans=[0]*N
cnt=0
def rec(cur):
    global cnt
    if ans[cur]:
        return
    ans[cur]=C[cnt]
    cnt+=1
    for nxt in nodes[cur]:
        rec(nxt)
rec(0)

if N==1:
    print(0)
else:
    print(sum(C[1:]))
print(*ans)


Measured memory_bytes: 13556
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int a[s.length()];
    for(int i=0;i<s.length();i++)
    {
        a[i]=(int)s[i]-65;
        a[i]=(a[i]+n)%26;
        cout<<(char)(a[i]+65);
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
XL = [list(map(int, input().split())) for _ in range(N)]

rXL = []
for i, j in XL:
    rXL.append([i - j, i + j])
rXL = sorted(rXL, key = lambda x: x[1])
TF = [True for _ in range(N)]

maxr = rXL[0][1]
for i in range(1, N):
    if maxr <= rXL[i][0]:
        maxr = rXL[i][1]
    else:
        TF[i] = False

print(sum(TF))

Measured memory_bytes: 43560
#include<bits/stdc++.h>
using namespace std;
int n,a[200005];
int f[200005][2];
int main(){

	cin>>n;
	for(int i=1;i<=n;i++){
		char x;
		cin>>x;
		if(x=='#')
			a[i]=1;
		else
			a[i]=0;
	}
	for(int i=1;i<=n;i++){
		if(a[i]==1){
			f[i][1]=min(f[i-1][0],f[i-1][1]);
			f[i][0]=f[i-1][0]+1;
		}
		if(a[i]==0){
			f[i][0]=f[i-1][0];
			f[i][1]=min(f[i-1][0],f[i-1][1])+1;
		}
	}
	cout<<min(f[n][0],f[n][1])<<endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define MOD 1000003
#define INF 1000000000
#define mp make_pair
#define pb push_back
#define ss second
#define ff first
#define endl '\n'
#define pl cout<<endl;
void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); }
const long long INFll=1ll*INF*INF;
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define debug(x) cout << x << endl;
#define sz(a) int((a).size())
int mul(int a, int b,int mod = MOD) {
	return int(a * 1ll * b % mod);
}
int norm(int a,int mod = MOD) {
	while(a >= mod) a -= mod;
	while(a < 0) a += mod;
	//a = (a%mod+mod)%mod;
	return a;
}
int powmod(int x,int y,int mod = MOD){
	int res = 1;
	while(y>0)
	{
		if(y&1)
			res = mul(res,x,mod);
		x = mul(x,x,mod);
		y=y>>1;
	}
	return res;
}
int inv(int a,int mod = MOD) {
	return powmod(a, mod - 2);
}

int main() {


	int n;
	cin>>n;
	ll a[n+1][3];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	}
	ll dp[n+1][3];
	dp[0][0] = 0;
	dp[0][1] = 0;
	dp[0][2] = 0;
	dp[1][0] = a[1][0];
	dp[1][1] = a[1][1];
	dp[1][2] = a[1][2];
	for(int i=2;i<=n;i++)
	{
		for(int j=0;j<3;j++)
		{
			dp[i][j] = 0;
			for(int k=0;k<3;k++)
			{
				if(j!=k)
					dp[i][j] = max(dp[i][j],dp[i-1][k]+a[i][j]);
			}
		}
	}
	cout<<max(dp[n][1],max(dp[n][2],dp[n][0]));
	return 0;
}

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

int main(){
    int N, K;
    cin >> N >> K;
    ll ans = K*pow(K-1, N-1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 123;
int b[MAXN];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", &b[i]);
    deque<int> ans;
    for (int i = n; i >= 1; i--) {
        for (int j = n - 1; j >= 0; j--) {
            if (!b[j]) continue;
            int cur = b[j], cnt = 0;
            for (int k = j - 1; k >= 0; k--) {
                if (b[k]) cnt++;
            }
            if (cnt == cur - 1 && cur <= i) {
               ans.push_front(cur);
               b[j] = 0;
               break;
            }
        }
    }
    if ((int)ans.size() != n) return !printf("-1\n");
    for (int i : ans) printf("%d\n", i);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b ;
  
  if (a % 2 == 0 || b % 2 == 0){
    cout << "Even" << endl;
  }
  else{
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
template <typename T>
using V = std::vector<T>;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

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

  i64 n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  assert(c <= d);

  const i64 x = (a < b) ? (b - a) : (a - b);

  auto solve = [&]() -> bool {
    i64 high = (n - 1) * d;
    i64 low = (n - 1) * c;

    // Go up i times, go down (n-1-i) times.
    for (int i = n - 1; i >= 0; --i) {
      if (x > high) return false;
      if (low <= x && x <= high) return true;
      high -= c + d;
      low -= c + d;
    }

    return false;
  };
  cout << (solve() ? "YES" : "NO") << endl;
}


Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int main()
{
    int a,b,c,d,e;
    cin>>a>>b>>c>>d;
    if(a>b)
    {
        e=a;
        a=b;
        b=e;
    }
    if(c>d)
    {
        e=c;
        c=d;
        d=e;
    }
       cout<<(a+c);

    return 0;
}


Measured memory_bytes: 3600
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
#include<boost/multiprecision/cpp_dec_float.hpp>
namespace mp=boost::multiprecision;
#define mulint mp::cpp_int
#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    mulint X,K,D;
    cin >> X >> K >> D;
    mulint dis=X;
  if(dis<0) dis*=-1;
    if(dis-D*K>0){
        cout << dis-D*K << endl;
        return 0;
    }
    else{
        mulint need=dis/D;
        K-=need;
        if(K%2==0){
            cout << dis%D << endl;
        }
        else{
            mulint ans=(dis%D-D);
          if(ans<0) ans*=-1;
          cout << ans << endl;
        }
    }
}


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

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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;cout<<n*n*n<<endl;

  return 0;

}


Measured memory_bytes: 636
package main

import("fmt")

func main() {
    var a, b int
    fmt.Scanf("%d", &a)
    fmt.Scanf("%d", &b)
    c := a * b
    if c % 2 == 0 {
        fmt.Println("Even")
    } else {
        fmt.Println("Odd")
    }
}

Measured memory_bytes: 512
//四則演算 #pragma GCC target("avx")
//並列計算 #pragma GCC optimize("O3")
//条件分岐を減らす #pragma GCC optimize("unroll-loops")
//浮動小数点演算 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
inline void print() { cout << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();
    
    int n, k; cin >> n >> k;
    VI a(n); cin >> a;
    map<int, int> m;
    ++m[0];
    ll ans = 0;
    FOR(i, 0, n) {
        if (0 < i)a[i] += a[i - 1];
        --a[i] %= k;
        if (k - 1 == i)--m[0];
        else if (k <= i)--m[a[i - k]];
        ans += m[a[i]];
        ++m[a[i]];
    }
    print(ans);
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
long long num[41];
int a[41];
void cal(long long x)
{
    int pos=0;
    while(x)
    {
        a[pos++]=x%2;
        x/=2;
    }
    long long t=0;
    for(int i=0;i<pos;i++)
    {
        if(a[i]==1)
        {
            for(int j=0;j<i;j++)
                num[j]+=(1ll<<i)/2;
            num[i]+=t+1;
        }
        t+=a[i]*(1ll<<i);
    }
}
int main()
{
    long long a,b,ans=0;
    scanf("%lld%lld",&a,&b);
    cal(b);
    for(int i=0;i<=40;i++)
        num[i]*=-1;
    if(a) cal(a-1);
    for(int i=0;i<=40;i++)
        num[i]*=-1,ans+=num[i]%2*(1ll<<i);
    printf("%lld\n",ans);
}


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 x1 = sc.nextInt();
			int y1 = sc.nextInt();
			int x2 = sc.nextInt();
			int y2 = sc.nextInt();

			int tmpx = x2 - x1;
			int tmpy = y2 - y1;

			int x3 = x2 - tmpy;
			int y3 = y2 + tmpx;

			int x4 = x3 - tmpx;
			int y4 = y3 - tmpy;


			System.out.println(x3 + " " + y3 + " " + x4 + " " +y4);
		}
	}
}


Measured memory_bytes: 24020
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int N;
bool color[MX];
vector<vector<pair<int, bool> > > graph;

void dfs(int v, int p, bool cur) {
    color[v] = cur;
    F0R(i, sz(graph[v])) {
        int curV = graph[v][i].f;
        bool swap = graph[v][i].s;
        if (curV == p) continue;
        if (swap) {
            dfs(curV, v, !cur);
        } else dfs(curV, v, cur);
    }
}

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

    cin >> N;
    F0R(i, N) {
        vector<pair<int, bool> > blank; graph.pb(blank);
    }
    F0R(i, N-1) {
        int A, B, C; cin >> A >> B >> C;
        A--; B--; C = C % 2;
        graph[A].pb(mp(B, C)); graph[B].pb(mp(A, C));
    }

    dfs(0, -1, false);

    F0R(i, N) {
        cout << color[i] ? 1 : 0;
        cout << endl;
    }

    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 8688
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main()
{
    int n, k;
    int pos[2];
    int color;
    cin >> n >> k;
    for(int i=0;i<k;++i)
    {
        cin >> pos[0] >> pos[1];
        if(pos[0] + pos[1] > n) cout << (n-max(pos[0], pos[1])) % 3 + 1 << endl;
        else cout << (min(pos[0], pos[1])-1) % 3 + 1 << endl;
    }
}

Measured memory_bytes: 1164
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            String S = in.next();
            boolean ok;
            ok = S.charAt(0) == 'A';
            String substring = S.substring(2, S.length() - 1);
            ok = ok && substring.chars().filter(c -> c == 'C').count() == 1;
            String substring1 = S.substring(0, 2);
            ok = ok && substring1.indexOf('C') == -1;
            String substring2 = S.substring(S.length() - 1);
            ok = ok && substring2.indexOf('C') == -1;
            ok = ok && S.substring(1).chars().filter(c -> c != 'C').filter(c -> 'A' <= c && c <= 'Z').count() == 0;
            out.println(ok ? "AC" : "WA");
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

    }
}



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

int main(){
  int N,M;
  cin>>N>>M;
  vector<int64_t> a(N),b(N),c(M),d(M);
  for(int i=0;i<N;++i) cin>>a[i]>>b[i];
  for(int i=0;i<M;++i) cin>>c[i]>>d[i];

  for(int i=0;i<N;++i){
    int64_t ch=1e15;
    int res;
    for(int j=0;j<M;++j){
      if(ch>abs(a[i]-c[j])+abs(b[i]-d[j])){
      res=j+1;
      ch=abs(a[i]-c[j])+abs(b[i]-d[j]);
      }
    }
    cout<<res<<endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

int m,n,ai,min,max;

long sum;

scanf("%d",&n);

for(m=0;m<n;m++){

scanf("%d",&ai);

if(m==0){

min=ai;

max=ai;

sum=ai;

}

else{

if(ai<min){

min=ai;

}

if(max<ai){

max=ai;

}

sum+=(long)ai;

}

}

printf("%d %d %ld\n",min,max,sum);

return 0;

}

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

int main(){
  ll l, r;
  cin >> l >> r;
  
  r = min(r,l+2018);
  int ans = 2018;
  
    for(ll i=l; i <= r; i++){
      for(ll j=i+1; j<=r; j++){
        int x = i*j % 2019;
          ans = min(ans,x);   
      }
    }
  cout << ans << endl;
  return 0;
}

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

int main()
{
    int count = 0;
    string str;
    vector<int> abc(3);
    cin >> str;
    for (int i = 0; i < 3;i++){
        if(str.at(i)=='a'){
            abc.at(0) = 1;
        }
        else if(str.at(i)=='b'){
            abc.at(1) = 1;
        }
        else if(str.at(i)=='c' ){
            abc.at(2) = 1;
        }
    }
    count = abc.at(0) + abc.at(1) + abc.at(2);
    if(count==3){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}

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

int main() {

    int N, K;

    cin >> N;
    cin >> K;

    int sum;

    if(N == 1) {
        sum = K;
    } else {
        sum = K * pow(K - 1, N - 1);
    }

    cout << sum << endl;
}

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

int main(void){

  double r,menseki,ensyu;

  cin >>r ;

  menseki = r*r*3.141592653589;
  ensyu = 2*r*3.141592653589;

  printf("%f %f\n",menseki,ensyu);

  return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N, T;
    cin >> N >> T;
    set<pair<int, int>> A;
    rep(i,N) {
        int a, b;
        cin >> a >> b;
        A.insert({a,b});
    }
    for (auto x : A) {
        if (x.second <= T) {
            cout << x.first << endl;
            return 0;
        }
    }
    cout << "TLE" << endl;
}


Measured memory_bytes: 256