akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pi pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#ifdef LOCAL
template <class T> ostream &operator<<(ostream &str, const vector<T> &vec) {
  str << '[';
  for (auto it = vec.begin(); it != vec.end(); it++) {
    if (it != vec.begin())
      str << ", ";
    str << *it;
  }
  str << ']';
  return str;
}
#define var(x) "[" << #x << ": " << x << "] "
#define dbg cerr << "  line " << __LINE__ << ": "
#else
#define var(x) 0
struct dbg_cls {
  template <class T> dbg_cls &operator<<(const T &oth) { return *this; }
} dbg;
#endif
using ll = long long;
int main(int argc, char **argv) {
#ifdef LOCAL
  int _time = clock();
#endif
  ios::sync_with_stdio(false), cin.tie(0);
  auto solve = [&]() {
    int n, m;
    cin >> n >> m;
    char c;
    vector<vector<bool>> v(n, vector<bool>(m));
    vector<vector<int>> dp(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> c;
        v[i][j] = c == '#' ? 1 : 0;
      }
    }
#define dp(i, j) (i < 0 || j < 0 ? (int)1e9 : dp[i][j])
    dp[0][0] = v[0][0];
    for (int i = 1; i < n; i++)
      dp[i][0] = dp[i - 1][0] + (v[i][0] && !v[i - 1][0]);
    for (int j = 1; j < m; j++)
      dp[0][j] = dp[0][j - 1] + (v[0][j] && !v[0][j - 1]);
    for (int i = 1; i < n; i++)
      for (int j = 1; j < m; j++)
        dp[i][j] = min(dp[i - 1][j] + (v[i][j] && !v[i - 1][j]),
                       dp[i][j - 1] + (v[i][j] && !v[i][j - 1]));
    cout << dp[n - 1][m - 1] << '\n';
  };
  int t = 1;
  // cin >> t;
  while (t--)
    solve();
#ifdef LOCAL
  cerr << "Took " << (1000ll * ll(clock() - _time)) / CLOCKS_PER_SEC << "ms.\n";
#endif
  return 0;
}

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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define MOD 1e9+7;

using ll = long long;
using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    set<int> st;
    vector<int> cnt(N, 0);
    
    rep(i, N) {
        int A;
        cin >> A;
        st.insert(A);
        cnt[A]++;
    }

    int num = (int)st.size() - K;
    int ans = 0, tmp = 0;
    if(num > 0) {
        sort(cnt.begin(), cnt.end(), greater<int>());

        for (int i = 0; i < K; i++) {
            if(cnt[i] > 0) {
                //cout << i << cnt[i] << "\n";
                tmp += cnt[i];
            }
        }
        ans = N - tmp;
    }

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


Measured memory_bytes: 10368
import java.util.*;

public class Main {
	public static void printArray(int[] a) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + ", ");
		}
		System.out.println();
	}

	public static<T> void printList(Iterable<T> a) {
		System.out.print("[");
		boolean first = true;
		for (T t : a) {
			if (first) {
				first = false;
			} else {
				System.out.print(", ");
			}
			System.out.print(t);
		}
		System.out.println("]");
	}

	public enum Event {
		Unblock, Block, Walk,
	}

	public static final class Item implements Comparable<Item> {
		public int time, X;
		public Event event;
		public Item(int time, Event event, int X) {
			this.time = time;
			this.event = event;
			this.X = X;
		}

		@Override
		public int compareTo(Item o) {
			int x = this.time - o.time;
			if (x != 0) {
				return x;
			}
			return this.event.compareTo(o.event);
		}

		@Override
		public String toString() {
			return String.format("(%d, %s, %d)", time, event, X);
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(); // 2 * 10^5
		int Q = sc.nextInt(); // 2 * 10^5

		ArrayList<Item> list = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			int s = sc.nextInt(); // 10^9
			int t = sc.nextInt(); // 10^9
			int x = sc.nextInt(); // 10^9
			list.add(new Item(s - x, Event.Block, x));
			list.add(new Item(t - x, Event.Unblock, x));
		}
		for (int i = 0; i < Q; i++) {
			int d = sc.nextInt(); // 10^9
			list.add(new Item(d, Event.Walk, i));
		}
		Collections.sort(list);
		// printList(list);
		int[] answers = new int[Q];
		TreeSet<Integer> blocks = new TreeSet<Integer>();

		for (Item item : list) {
			if (item.event == Event.Block) {
				blocks.add(item.X);
			}
			if (item.event == Event.Unblock) {
				blocks.remove(item.X);
			}
			if (item.event == Event.Walk) {
				// printList(blocks);
				answers[item.X] = blocks.isEmpty() ? - 1 : blocks.first();
			}
		}
		StringBuilder sb = new StringBuilder();
		for (int x : answers) {
			sb.append(x);
			sb.append("\n");
		}
		System.out.print(sb);
	}
}


Measured memory_bytes: 190008
#include<iostream>
#include<cstdio>
using namespace std;
int check (int t)
{
	for(int i=2;i*i<=t;i++)
	{
		if(t%i==0)
			return 1;
	}
	return 0;
}
int a[1500];
int main()
{
	int ans=0,i;
	for(i=2;i<11100;i++)
	{
		if(check(i*5+1)==0)
			a[ans++]=i*5+1;
	}
	int n;
	cin>>n;
	for(i=0;i<n-1;i++)
		cout<<a[i]<<" ";
		
	cout<<a[i]<<endl;
	return 0;
} 

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

int divCount(int n) 
{ 
    bool hash[n + 1]; 
    memset(hash, true, sizeof(hash)); 
    for (int p = 2; p * p < n; p++) 
        if (hash[p] == true) 
            for (int i = p * 2; i < n; i += p) 
                hash[i] = false; 
    
    int total = 1; 
    for (int p = 2; p <= n; p++) { 
        if (hash[p]) { 
			int count = 0; 
	            if (n % p == 0) { 
                	while (n % p == 0) { 
                   		n = n / p; 
                    	count++; 
               		} 
            		total = total * (count + 1); 
            }  
        } 
    } 
    return total; 
} 

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n; cin>>n;
	int m=n;
	int ans = 0;
	while(m){
		ans+=(n/m);
		m--;
	}
	int f = divCount(n);
	cout<<ans-f<<"\n";
	return 0;
}

Measured memory_bytes: 4552
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, m, n) for (int i = m; i < n; i++)
#define repr(i, m, n) for (int i = m; i >= n; i--)
#define db(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD   998244353
#define PI (acos(-1))
#define EPS 1e(-9);
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//--GLOBAL---------------------------------


//--MAIN-----------------------------------
void Main() {
    int N; cin>>N;
    string S; cin>>S;
    rep(i,S.size()){
        char c=S[i];
        c+=N;
        if(c>'Z') c-=26;
        S[i]=c;
    }
    
    cout<< S <<"\n";

}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  rep(i,n/2) {
    int x = n/2-1-i;
    if(s.substr(0,x)==s.substr(x,x)) {
      cout << 2*x << endl;
      return 0;
    }
  } 
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int N,M,X,Y;
    int i,j;
    cin>>N>>M>>X>>Y;
    int x[N],y[M];
    for(i=0;i<N;i++)cin>>x[i];
    for(i=0;i<M;i++)cin>>y[i];
   
    for(i=X+1;i<=Y;i++)
    {
                for(j=0;j<N;j++)
        {
            if(x[j]>=i)goto damedesita;
        }

          for(j=0;j<M;j++)
        {
            if(y[j]<i)goto damedesita;
        }
        cout<<"No War"<<endl;
        return 0;
       
       damedesita:
       continue;
    }
  
    cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val l1 = read()
    val l2 = read()
    val l3 = read()
    val ans = "${l1[0]}${l2[1]}${l3[2]}"
    println(ans)
    pw.flush()
}

/****** Decrared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
    }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)
        }
    }
    return v.map { it.toList() }.toList()
}

fun gcd(a: Long, b: Long): Long = 
    if(b != 0L) a else gcd(b, a % b)

fun lcm(a: Long, b: Long) = 
    (a * b) / gcd(a, b)

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 31772
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

Vi divi(10000050,1);
void solve(){
    ll n;
    cin >> n;
    repi(i,2,10000020){
        for(ll j=i; j<10000020; j+=i){
            divi[j]++;
        }
    }
    ll ans=0;
    repi(i,1,n+1){
        ans+=i*divi[i];
    }
    print(ans);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 81192
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

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

  int ans;
  if (a <= 9 && b <= 9) ans = a * b;
  else ans = -1;

  cout << ans << endl;

  return 0;
}


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


int main(){
    int n; cin >> n;
    vector<int> d1(100, 0), d2(100, 0);
    bool flg = false;
    for(int i=0; i<n; i++){
        cin >> d1[i] >> d2[i];
        if(i>=2){
            if(d1[i-2]==d2[i-2] && d1[i-1]==d2[i-1] && d1[i]==d2[i]){
                flg = true;
            }
        }
    }
    if(flg) cout << "Yes" << endl;
    else    cout << "No"  << endl;


    return 0;
}

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

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;

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

bool check(string s)
{
   int k = s.size()/2;
   for(int i = 0; i <k; i++)
   {
      if(s[i] != s[i+k])
         return false;
   }
   return true;
}
int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   int a, b, x; cin >> x>>a >> b;
   abs(a -x) >= abs(b - x) ? cout << "B" : cout << "A";
}


Measured memory_bytes: 3656
#include<iostream>
#include<limits.h>

using namespace std;

const int N=2e5+10;

int a[N],n;

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

    cin>>n;

    for(int i=0;i<n;i++) cin>>a[i];

    int maxv=INT_MIN;
    int minv=a[0];

    for(int i=1;i<n;i++)
    {
        maxv=max(maxv,a[i]-minv);
        minv=min(minv,a[i]);
    }

    cout<<maxv<<endl;

    return 0;
}


Measured memory_bytes: 3928
#include <iostream>
#include <algorithm>
#include <cstring>
 
using namespace std;
 
char s[101];
char t[101];
 
void solve()
{
	sort(s, s + strlen(s));
	sort(t, t + strlen(t), greater<int>());
	if(strcmp(s, t) < 0) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}
 
int main()
{
	cin >> s >> t;
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2222;
int d[3][maxn][maxn], g[maxn][maxn];
int main(){
	int n, m, q; cin >> n >> m >> q;
	for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++){
		char c; cin >> c;
		g[i][j] = c - '0';
	}
	for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++){
		d[0][i][j] = g[i][j];
		d[1][i][j] = g[i][j] & g[i - 1][j];
		d[2][i][j] = g[i][j] & g[i][j - 1];
	}
	for(int k = 0; k < 3; k++)
	for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++){
		d[k][i][j] += d[k][i - 1][j] + d[k][i][j - 1] - d[k][i - 1][j - 1];
	}
	auto get = [&](int id, int l, int r, int ll, int rr){
		int cs = d[id][ll][rr] - d[id][l - 1][rr] - d[id][ll][r-1] + d[id][l - 1][r - 1];
		return cs;
	};
	while(q--){
		int l, r, ll, rr;
		cin >> l >> r >> ll >> rr;
		int ans = get(0, l, r, ll, rr) - get(1, l + 1, r, ll, rr) - get(2, l, r + 1, ll, rr);
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 77568
#include<stdio.h>

#define SHEET_MAX 101

#define LOOP_RESET 0

#define NULL 0

int main(){

        unsigned short usW_D_row;                    /* 行数格納用変数 */

        unsigned short usW_D_col;                    /* 列数格納用変数 */

        unsigned long ulW_D_sheet[SHEET_MAX][SHEET_MAX];        /* 表格納用配列 */

        unsigned short usW_D_i,usW_D_j;                    /* ループ変数 */

        

        /* 配列の初期化 */

        for(usW_D_i = LOOP_RESET;usW_D_i < SHEET_MAX;usW_D_i++){

                for(usW_D_j = LOOP_RESET;usW_D_j < SHEET_MAX;usW_D_j++){

                        ulW_D_sheet[usW_D_i][usW_D_j] = NULL;

                }

        }

        

        /* 行数、列数の入力 */

        scanf("%d %d", &usW_D_row, &usW_D_col);

        

        /* 表の要素の入力 */

        for(usW_D_i =LOOP_RESET;usW_D_i < usW_D_row;usW_D_i++){

                for(usW_D_j = LOOP_RESET;usW_D_j < usW_D_col;usW_D_j++){

                        scanf("%ld", &ulW_D_sheet[usW_D_i][usW_D_j]);

                }

        }

        

        /* 各行の要素の合計の計算 */

        for(usW_D_i =LOOP_RESET;usW_D_i < usW_D_row;usW_D_i++){

                for(usW_D_j = LOOP_RESET;usW_D_j < usW_D_col;usW_D_j++){

                        ulW_D_sheet[usW_D_i][usW_D_col] += ulW_D_sheet[usW_D_i][usW_D_j];

                }

        }

        

        /* 各列の要素の合計の計算 */

        for(usW_D_i =LOOP_RESET;usW_D_i < usW_D_row;usW_D_i++){

                for(usW_D_j = LOOP_RESET;usW_D_j < usW_D_col;usW_D_j++){

                        ulW_D_sheet[usW_D_row][usW_D_j] += ulW_D_sheet[usW_D_i][usW_D_j];

                }

        }

        

        /* 全要素の合計の計算 */

        for(usW_D_i = LOOP_RESET;usW_D_i < usW_D_row;usW_D_i++){

                ulW_D_sheet[usW_D_row][usW_D_col] += ulW_D_sheet[usW_D_i][usW_D_col];

        }

        

        /* 表を出力 */

        for(usW_D_i =LOOP_RESET;usW_D_i <= usW_D_row;usW_D_i++){

                for(usW_D_j = LOOP_RESET;usW_D_j < usW_D_col;usW_D_j++){

                        /* 末列以外の要素の出力 */

                        printf("%ld ", ulW_D_sheet[usW_D_i][usW_D_j]);

                }

                /* 末列の出力 */

                printf("%ld\n", ulW_D_sheet[usW_D_i][usW_D_col]);

        }

        return LOOP_RESET;

}


Measured memory_bytes: 2116
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

const long long MOD = 1000000007;
LL dp[101010];
bool broken[101010];
void solve(long long N, long long M, std::vector<long long> a){
    REP(i, 101010)dp[i]=0;
    dp[0]=1;
    REP(i, M)broken[i]=false;
    REP(i, M)broken[a[i]]=true;
    for(int i=0; i <=N; i++){
        if(!broken[i+1])dp[i+1]=(dp[i+1]+dp[i])%MOD;
        if(!broken[i+2])dp[i+2]=(dp[i+2]+dp[i])%MOD;
    }
    cout<<dp[N]<<endl;

}

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


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
using vpii = vector<pair<int, int>>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, n) for (int i = 1; i < (int)n; i++)
const ll mod = 1e9+7;
const ll inf = 1e12;
const double pi = 3.141592;


int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n, m, q;
  cin >> n >> m >> q;
  vector<vector<int>> t(n, vector<int>(n, 0));
  rep(i, m){
    int l, r;
    cin >> l >> r;
    ++t[r-1][l-1];
  }
  rep(i, n-1) t[i+1][n-1] += t[i][n-1];
  for(int y = n-2; y >= 0; --y){
    for(int x = 0; x <= n-1; ++x){
      t[x][y] += t[x][y+1];
      if(x) t[x][y] += t[x-1][y]-t[x-1][y+1];
    }
  }
  rep(i, q){
    int p, q;
    cin >> p >> q;
    cout << t[q-1][p-1] << "\n";
  }
  return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const ll INF = 1LL<<60;

int main()
{
  ll n,k;cin>>n>>k;

  int ans=1;
  rep(i, n) {
    int tmp_bai = ans*2;
    int tmp_k = ans+k;
    if (tmp_bai < tmp_k) {
      ans = ans*2;
    } else {
      ans = ans+k;
    }
  }
  cout << ans << endl;
  return 0;
}

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

bool is_prime(long long x) {
    if (x <= 1) return false;
    for (long long i = 2; i * i <= x; i++) if (x % i == 0) return false;
    return true;
}

bool isGaussianPrime(int a, int b) {
    if (a < 0) a = -a;
    if (b < 0) b = -b;
    if (a == 0) return b % 4 == 3 && is_prime(b);
    if (b == 0) return a % 4 == 3 && is_prime(a);
    return is_prime(a * a + b * b);
}

int main() {
    int T; cin >> T;
    while (T--) {
        int a, b; cin >> a >> b;
        cout << "CP"[isGaussianPrime(a, b)] << endl;
    }
    return 0;
}


Measured memory_bytes: 3056
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

typedef long long s64;

const int MaxN = 1000;
const int M = 1000000007;

int n, m;
s64 k;

char s[MaxN + 1][MaxN + 2];

struct matrix
{
	int a[2][2];

	inline void construct(int v1, int v2, int v3, int v4)
	{
		a[0][0] = v1, a[0][1] = v2;
		a[1][0] = v3, a[1][1] = v4;
	}

	friend inline matrix operator*(const matrix &lhs, const matrix &rhs)
	{
		matrix res;
		for (int i = 0; i < 2; ++i)
			for (int j = 0; j < 2; ++j)
				res.a[i][j] = ((s64)lhs.a[i][0] * rhs.a[0][j] + (s64)lhs.a[i][1] * rhs.a[1][j]) % M;
		return res;
	}
};
matrix tr;

int main()
{
	cin >> n >> m >> k;
	for (int i = 1; i <= n; ++i)
		scanf("%s", s[i] + 1);

	int cx = 0, lx = 0;
	for (int i = 1; i <= n; ++i)
	{
		cx += s[i][1] == '#' && s[i][m] == '#';
		for (int j = 1; j < m; ++j)
			lx += s[i][j] == '#' && s[i][j + 1] == '#';
	}

	int cy = 0, ly = 0;
	for (int j = 1; j <= m; ++j)
	{
		cy += s[1][j] == '#' && s[n][j] == '#';
		for (int i = 1; i < n; ++i)
			ly += s[i][j] == '#' && s[i + 1][j] == '#';
	}

	int num = 0;
	for (int i = 1; i <= n; ++i)
		num += count(s[i] + 1, s[i] + m + 1, '#');

	if (k <= 1 || (cx && cy))
	{
		puts("1");
		return 0;
	}

	if (cx > 0)
		tr.construct(num, 0, M - lx, cx);
	else if (cy > 0)
		tr.construct(num, 0, M - ly, cy);
	else
		tr.construct(num, 0, 0, 0);

	matrix res = tr;
	for (s64 i = k - 2; i; i >>= 1)
	{
		if (i & 1)
			res = res * tr;
		tr = tr * tr;
	}

	cout << (res.a[0][0] + res.a[1][0]) % M;
	cout << endl;

	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
# define int long long
# define mo 1000000007
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
# define fi first
# define se second
signed main()
{
   gok
  int n;
  cin>>n;
  int a[n];
  map<int,int> mp;
  for(int i=0;i<n;i++)
  {
      int x;
      cin>>x;
      mp[x]++;
      if(mp[x]>1)
      {
          cout<<"NO";
          return 0;
      }
  }
  cout<<"YES";
   return 0;
}


Measured memory_bytes: 12800
#include <iostream>
using namespace std;
const int N = 100010;
int parents[N];
int res[N];
int friends[N];
int n,m,k;

int find(int curr){
  if(parents[curr] != parents[parents[curr]]) parents[curr] = find(parents[curr]);
  return parents[curr];
}

int main(){
  cin >> n >> m >> k;
  for(int i = 1; i <= n; i ++){
    parents[i] = i;
    res[i] = 1;
  }
  while(m --){
    int a, b;
    cin >> a >> b;
    int pa = find(a);
    int pb = find(b);
    if(pa != pb){
      parents[pa] = pb;
      res[pb] += res[pa];
    }
    friends[a] ++;
    friends[b] ++;
  }
  for(int i = 1; i <= n; i ++){
    res[i] = res[find(i)];
  }
  while(k --){
    int a, b;
    cin >> a >> b;
    int pa = find(a);
    int pb = find(b);
    if(pa == pb){
      res[a] --;
      res[b] --;
    }
  }
  for(int i = 1; i <= n; i ++){
    //cout << parents[i] << endl;
    cout << res[i]-1 - friends[i] << " ";
  }
  cout << endl;
  return 0;
}

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

import sys
from fractions import gcd

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 list4d(a, b, c, d, e): return [[[[e] * d for j in range(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(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)

N = INT()
A = LIST()

l = 1
for a in A:
    l = lcm(l, a)
l %= MOD

B = [0] * N
for i, a in enumerate(A):
    B[i] = fermat(l, a, MOD)

ans = 0
for b in B:
    ans += b
    ans %= MOD
print(ans)


Measured memory_bytes: 6192
#include <stdio.h>

int main(void){
	char op='+';
	int a,b;

	while(op != '?'){
		scanf("%d %c %d",&a,&op,&b);
	
		switch(op){
			case '+':
				printf("%d\n",a + b);
				break;
			case '-':
				printf("%d\n",a - b);
				break;
			case '*':
				printf("%d\n",a * b);
				break;
			case '/':
				printf("%d\n",a / b);
				break;
			case '?':
				break;
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18;
int main(){
    int n,k,ans=0;
    cin>>n>>k;
    vector<int>h(n);
    rep(i,n)cin>>h[i];
    rep(i,n){
        if(h[i]>=k)ans++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 640
#include<stdio.h>
#define MAX 90

long long int F[MAX];

void fib(int n){
  int i;
   F[0]=F[1]=1;
   for(i=2;i<n+1;i++){
     F[i]=F[i-1]+F[i-2];
   }
}

int main(){
  int n;
  scanf("%d",&n);
  fib(n);
  printf("%lld\n",F[n]);
  return 0;
}




Measured memory_bytes: 2004
c = input()
a_index = 300000
z_index = 0
for i in range(len(c)):
    if c[i] == "A":
        a_index = min(a_index,i)
    elif c[i] == "Z":
        z_index = max(z_index,i)
print(z_index - a_index+1)

Measured memory_bytes: 3516
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 998244353LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,s;

ll moddiv(ll a,ll b){
	ll x0=MOD,x1=b,x2,n0=0LL,n1=1LL,n2,t=a%b,m,ans;
	if (t==0) return a/b;
		for(int i=0;i<900;i++){
      m=x0/x1;
      x2=x0-x1*m;
      n2=(n0-m*n1)%MOD;
      if (x2==1){
        ans=(n2+MOD)%MOD;
        break;
      }
      x0=x1;x1=x2;
      n0=n1;n1=n2;
    }
	return (a+((t*ans)%MOD)*b-t)/b;
}
//剰余の割ざん

//aのn乗 mod c
ll expmod(ll a,ll n){
  ll ans=1LL,aa=a,beki=n;
  for(int i=0;i<64;i++){
    if (beki%2==1) ans=ans*aa%MOD;
    aa=aa*aa%MOD;
    beki/=2;
    if (beki==0)break;
  }
  return ans;
}

//nCk
vi mulmod(500001);//0!,1!,2!,3!,4!,,,,
void first_nCk(){
  mulmod[0]=1;
  for(ll i=1;i<500001;i++){
    mulmod[i]=mulmod[i-1]*i%MOD;
  }
}
ll nCk(ll nn,ll kk){
  return moddiv(mulmod[nn],mulmod[kk]*mulmod[nn-kk]%MOD);
}



int main(){
  ll ans=0;
  cin >> n >>s;
  vi a(n),b(n);
  REP(i,n) cin>>a[i];

  vi dp(s*2+2),dp2(s*2+2);

  dp[0]=expmod(2LL,n);
  //cout<<dp[0]<<endl;

  for(ll i=0;i<n;i++){
    
    for(ll j=0;j<a[i];j++){
      dp2[j]=dp[j];
      if (j==s)break;
    }

    for(ll j=0;j<s+1;j++){
      if (j+a[i]<=s){
        dp2[j+a[i]]=(moddiv(dp[j],2LL)+dp[j+a[i]])%MOD;
      }
    }

    for(ll j=0;j<s+1;j++){
      dp[j]=dp2[j];
    }
/*
    cout<<endl;
    for(ll j=0;j<s+1;j++){
      cout<<dp[j]<<endl;
    }
    cout<<endl;
  */  
    
  }



  ans=dp[s];
  cout<<ans<<endl;
  return 0;
}




Measured memory_bytes: 7000
def bfs(graph, start, rm)
  visited = {}
  count = 0
  queue = [start]
  until queue.empty? do
    p = queue.shift
    neighbors = graph[p]
    neighbors.each do |n|
      next if visited[n]
      next if (p == rm[0] && n == rm[1]) || (p == rm[1] && n == rm[0])
      visited[n] = true
      queue.push(n)
      count += 1
    end
  end
  count
end

n, m = gets.strip.split.map(&:to_i)
graph = {}
(1..n).each do |i|
  graph[i] = []
end

edges = []
m.times do
  a, b = gets.strip.split.map(&:to_i)
  graph[a] << b
  graph[b] << a
  edges << [a, b]
end

num_bridges = 0
edges.each do |e|
  count = bfs(graph, 1, e)
  num_bridges += 1 if count < n
end

puts num_bridges

Measured memory_bytes: 3836
import java.util.Scanner;

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

		int window = sc.nextInt();
		int curtain = sc.nextInt();

		int width = window - (curtain * 2);

		if(width < 0) {
			System.out.println(0);
		}else {
			System.out.println(width);
		}
	}
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long

vector<int> oddpat(int l){
  if(l==1){
    vector<int> w({0,1});
    return w;
  }
  vector<int> v = oddpat(l-2);
  vector<int> ret;
  REP(i,v.size()){
    ret.push_back(v[i]);
  }
  REP(i,v.size()){
    ret.push_back(v[v.size()-1-i]+(1<<(l-2)));
  }
  REP(i,v.size()){
    if(!(i%2)){
      ret.push_back(v[i]+(3<<(l-2)));
      ret.push_back(v[i]+(2<<(l-2)));
    }else{
      ret.push_back(v[i]+(2<<(l-2)));
      ret.push_back(v[i]+(3<<(l-2)));
    }
  }
  return ret;
}

vector<int> adlib(int l){
  vector<int> v = oddpat((l+1)/2*2-1);
  if(l%2)return v;
  vector<int> ret;
  REP(i,v.size())ret.push_back(v[i]);
  REP(i,v.size())ret.push_back((1<<(l-1))+v[v.size()-1-i]);
  return ret;
}

int cntbit(int k){
  int ret=0;
  REP(i,17){
    if(k%2)ret++;
    k/=2;
  }
  return ret;
}

int n,a,b;
vector<int> pv;

int permu(int l){
  int bits[17];
  REP(i,17){
    bits[i]=l%2;
    l/=2;
  }
  REP(i,pv.size()){
    swap(bits[pv[pv.size()-1-i]],bits[pv.size()-1-i]);
  }
  int ret=0;
  REP(i,17){
    ret+=bits[i]<<i;
  }
  return ret;
}

int main(){
  cin>>n>>a>>b;
  b=a^b;
  if(cntbit(b)%2==0){
    cout<<"NO"<<endl;
    return 0;
  }
  int bi = cntbit(b);
  REP(i,17){
    if((b>>i)%2)pv.push_back(i);
  }
  vector<int> v,odd=oddpat(cntbit(b));
  if(n-cntbit(b)==0){
    cout<<"YES"<<endl;
    REP(i,odd.size()){
      if(i==0)cout<<(odd[i]^a);
      else cout<<" "<<(odd[i]^a);
    }
    cout<<endl;
    return 0;
  }
  vector<int> w=adlib(n-cntbit(b));
  REP(i,odd.size()){
    REP(j,w.size()){
      if(!(i%2))v.push_back((w[j]<<bi)+odd[i]);
      else v.push_back((w[w.size()-1-j]<<bi)+odd[i]);
    }
  }
  cout<<"YES"<<endl;
  REP(i,v.size()){
    if(i==0)cout<<(permu(v[i])^a);
    else cout<<" "<<(permu(v[i])^a);
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 1692
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T>
struct DiameterForEdge{
  using Edge = pair<int, T>;
  vector<T> dp;
  vector<vector<Edge> > G;
  DiameterForEdge(int n):dp(n),G(n){}
  void add_edge(int u,int v,T c){
    G[u].emplace_back(v,c);
    G[v].emplace_back(u,c);
  }
  void dfs(int v,int p,int &s){
    if(p<0) dp[v]=T(0);
    if(dp[s]<dp[v]) s=v;
    for(Edge e:G[v]){
      int u=e.first;
      if(u==p) continue;
      dp[u]=dp[v]+e.second;
      dfs(u,v,s);
    }
  }
  pair<int, int> endPoints(){
    int s=0;
    dfs(s,-1,s);
    int t=s;
    dfs(t,-1,t);
    return make_pair(s,t);
  }
  T build(){
    int t=endPoints().second;
    return dp[t];
  }
  vector<T> distance(int v){
    dfs(v,-1,v);
    return dp;
  }
  vector<T> farthest(){
    int t=endPoints().second;
    auto ds=dp;
    auto dt=distance(t);
    for(int i=0;i<(int)ds.size();i++)
      if(ds[i]<dt[i]) ds[i]=dt[i];
    return ds;
  }
};


template<typename V>
V compress(V v){
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(),v.end()),v.end());
  return v;
}
template<typename T>
map<T, int> dict(const vector<T> &v){
  map<T, int> res;
  for(int i=0;i<(int)v.size();i++)
    res[v[i]]=i;
  return res;
}
map<char, int> dict(const string &v){
  return dict(vector<char>(v.begin(),v.end()));
}

//INSERT ABOVE HERE
signed main(){
  int n;
  while(cin>>n,n){
    vector<int> ps(n),ds(n);
    for(int i=1;i<n;i++) cin>>ps[i],ps[i]--;
    for(int i=1;i<n;i++) cin>>ds[i];

    vector<int> deg(n,0);
    for(int i=1;i<n;i++) deg[i]++,deg[ps[i]]++;

    vector<int> vs;
    for(int i=0;i<n;i++)
      if(deg[i]>1) vs.emplace_back(i);
    auto dc=dict(vs);

    int sum=0;
    DiameterForEdge<int> H(vs.size());
    for(int i=1;i<n;i++){
      sum+=ds[i];
      int u=ps[i],v=i;
      if(!dc.count(u)) continue;
      if(!dc.count(v)) continue;

      H.add_edge(dc[u],dc[v],ds[i]);
      sum+=ds[i]*2;
    }

    cout<<sum-H.build()<<endl;
  }
  return 0;
}



Measured memory_bytes: 3264
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int N; cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    ll mx = A[0];
    ll ans = 0;
    rep2(i, 1, N) {
        if (mx > A[i]) ans += mx-A[i];
        else mx = A[i];
    }
    cout << ans << endl;
}


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

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

		vector<int> h;
		for ( int i = 0; i < n; i++ ) {
				int x;
				scanf("%d", &x);
				h.push_back(x);
		}

		sort (h.begin(), h.end());

		int d, min = 1e9;
		for ( int i = 0; i <= n - k; i++ ) {
				d = h[i+k-1] - h[i];
				if ( min > d ) min = d;
		}

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

		return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string a,b;
    cin >> a >> b;
    if (a.length() > b.length())
    {
        cout << "GREATER" << endl;
    }
    else if (a.length() < b.length())
    {
        cout << "LESS" << endl;
    }
    else
    {
        if (a > b)
        {
            cout << "GREATER" << endl;
        }
        else if (a == b)
        {
            cout << "EQUAL" << endl;
        }
        else
        {
            cout << "LESS" << endl;
        }
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

class UnionFind{
public:
    vector<int> par;
    vector<int> dist_from_par;
    UnionFind(int n){
        init(n);
    }
    void init(int n){
        par.resize(n);
        for(int i=0;i<n;i++){
            par[i] = i;
        }
        dist_from_par.assign(n, 0);
    }
    P find(int x){
        if(par[x] != x){
            P res = find(par[x]);
            dist_from_par[x] += res.second;
            par[x] = res.first;
        }
        return make_pair(par[x], dist_from_par[x]);
    }
    // x -- d --> y
    void unite(int x, int y, int d){
        assert(par[x] == x && par[y] == y);
        assert(dist_from_par[x] == 0 && dist_from_par[y] == 0);
        par[y] = x;
        dist_from_par[y] = d;
    }
};

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

    UnionFind uf(N);
    for(int i=0;i<M;i++){
        int L, R, D;
        cin >> L >> R >> D;
        L--; R--;
        P root_L = uf.find(L);
        P root_R = uf.find(R);
        if(root_L.first == root_R.first){
            if(root_R.second - root_L.second != D){
                cout << "No" << endl;
                return 0;
            }
        }else{
            if(root_L.second + D <= root_R.second){
                uf.unite(root_R.first, root_L.first, root_R.second - (root_L.second + D));
            }else{
                uf.unite(root_L.first, root_R.first, (root_L.second + D) - root_R.second);
            }
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int M = 1e9+7;
void mult(vector<vector<int>> &m1, vector<vector<int>> &m2){
    vector<vector<int>> res(m1.size(), vector<int> (m1.size()));
    for (int i=0; i<m1.size(); i++)
        for (int j=0; j<m1.size(); j++){
            for (int k=0; k<m1.size(); k++)
                res[i][j] = (res[i][j]+(1ll*m1[i][k]*m2[k][j])%M)%M;
        }
    m1 = res;
}
int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    int N, ans=  0;
    long long K;
    cin >> N >> K;
    vector<vector<int>> m1(N, vector<int>(N)), m2 = m1;
    for (int i=0; i<N; i++)
        m1[i][i] = 1;
    for (auto &i: m2)
        for (auto &j: i)
            cin >> j;
    while (K){
        if (K&1)
            mult(m1, m2);
        K >>= 1;
        mult(m2, m2);
    }
    for (auto &i:m1)
        for (auto &j: i){
            ans += j;
            if (ans>=M)
                ans -= M;
        }
    cout << ans << "\n";
}

Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    vn = vk = vn_k = 1
    for i in range(1, n+1):
        vn = vn * i % modp
        if i == k:
            vk = vn
        if i == n-k:
            vn_k = vn
    return vn * get_inv(vk, modp) * get_inv(vn_k, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

def main():
    print('Yes' if len(set(lmis()))==2 else 'No')

main()


Measured memory_bytes: 5172
# abc108_b.py
# https://atcoder.jp/contests/abc108/tasks/abc108_b

# B - Ruined Square /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# xy平面上に正方形があり、4 つの頂点の座標は反時計回りに順番に (x1,y1),(x2,y2),(x3,y3),(x4,y4) です。 
# なお、x 軸は右向きに、y軸は上向きに取ることにします。
# 高橋君は、これら 4つの座標のうち (x3,y3),(x4,y4)を忘れてしまいました。
# x1,x2,y1,y2が与えられるので、x3,y3,x4,y4 を復元してください。
# なお、これらの条件から、x3,y3,x4,y4は一意に存在し、整数となることが証明できます。

# 制約
#     |x1|,|y1|,|x2|,|y2|≤100
#     (x1,y1)≠ (x2,y2)
#     入力はすべて整数である

# 入力
# 入力は以下の形式で標準入力から与えられる。
# x1 y1 x2 y2

# 出力
# x3,y3,x4,y4をこの順に整数で出力せよ。

# 入力例 1
# 0 0 0 1

# 出力例 1
# -1 1 -1 0

# 4点 (0,0),(0,1),(−1,1),(−1,0) は、この順に正方形を反時計回りに見たときの 4 頂点をなします。 
# (x3,y3)=(1,1),(x4,y4)=(1,0)は、頂点が時計回りに並んでいるので適さないことに注意してください。

# 入力例 2
# 2 3 6 6

# 出力例 2
# 3 10 -1 7

# 入力例 3
# 31 -41 -59 26

# 出力例 3
# -126 -64 -36 -131


def calculation(lines):
    x1, y1, x2, y2 = list(map(int, lines[0].split()))
    # N = int(lines[0])
    v1, v2 = x2-x1, y2-y1
    x3, y3 = x2-v2, y2+v1
    x4, y4 = x3-v1, y3-v2
    return [str(x3) + ' ' + str(y3) + ' ' + str(x4) + ' ' + str(y4)]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['0 0 0 1']
        lines_export = ['-1 1 -1 0']
    if pattern == 2:
        lines_input = ['2 3 6 6']
        lines_export = ['3 10 -1 7']
    if pattern == 3:
        lines_input = ['31 -41 -59 26']
        lines_export = ['-126 -64 -36 -131']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')


# 起動処理
if __name__ == '__main__':
    main()


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

int main(){
    int x;
    cin >> x;
    int ans = 0;
    int d;
    d = x / 500;
    ans += d * 1000;
    x -= d * 500;
    d = x / 5;
    ans += d * 5;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
local n=io.read("n")
local c,s,f={},{},{}
for i=1,n-1 do
    c[i],s[i],f[i]=io.read("n","n","n")
end

for i=1,n do
    local t=0
    for j=i,n-1 do
        if t<s[j] then
            t=s[j]
        elseif t%f[j]>0 then
            t=t+f[j]-t%f[j]
        end
        t=t+c[j]
    end
    print(t)
end

Measured memory_bytes: 880
a, b, c, d = map(int, input().split())
             
for i in range(120):
    c = c- b 
    a = a - d                                              
    if c<=0 and a>0:
        print("Yes")
        break
    elif c>0 and a<=0:
        print("No")
        break
    elif c<=0 and a<=0:
        print("Yes")
        break

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
const int N = 3e5 + 5;
int n, m, a[N], ans;
int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
	}
	sort(a + 1, a + 1 + n);
	for (int i = 30; i > 0; --i) {
		int p = n, tmp = 1 << i;
		for (int j = 1; j <= n; ++j) {
			if (a[j] == 0) continue;
			while (p > j && (a[p] == 0 || a[p] > tmp - a[j])) --p;
			if (p > j && a[p] + a[j] == tmp) {
				ans++;
				a[j] = a[p] = 0;
			}
		}
	}
	cout << ans;
}

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

public class Main {
    
    static int m;
    static int n;
    static ArrayList<Integer>[] next;
    static boolean[] dp;
    static int[] count;
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        //StringTokenizer st=new StringTokenizer(br.readLine());
        n=Integer.parseInt(br.readLine());
        System.out.println((n<1200) ? "ABC":"ARC");
    }
    
}


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

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


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
int a,b;
cin >> a>> b;
if((a*b)%2==0){
  cout << "Even" << endl;
}else{
    cout << "Odd" << endl;
}
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;

ll manhattan_dist(int x1, int y1, int x2, int y2){
    return abs(x1-x2) + abs(y1-y2);
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);

    int n,m; cin >> n >> m;
    vi a(n),b(n),c(m),d(m);
    rep(i,n) cin >> a[i] >> b[i];
    rep(i,m) cin >> c[i] >> d[i];

    rep(stu,n){
        ll dist = 1000000000;
        int cp = 0;
        rep(chk,m){
            ll m = manhattan_dist(a[stu],b[stu],c[chk],d[chk]);
            if(m<dist) {
                cp = chk;
                dist = m;
            }
        }
        cout << cp+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
import io, os
input = sys.stdin.buffer.readline
#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

n, m = map(int, input().split())
g = [[] for _ in range(n)]
edge = []
for i in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    g[a].append(b)
    edge.append((a, b))

from collections import deque
INF = 10**18
temp= INF
for a, b in edge:
    q = deque([])
    q.append(b)
    visit = [INF]*n
    visit[b] = 0
    par = [-1]*n
    while q:
        v = q.popleft()
        for u in g[v]:
            if visit[u] == INF:
                visit[u] = visit[v]+1
                par[u] = v
                q.append(u)
    if visit[a]+1 <= temp:
        ans = []
        v = a
        ans.append(v+1)
        while par[v] != -1:
            v = par[v]
            ans.append(v+1)
        temp =  visit[a]+1

if temp == INF:
    print(-1)
else:
    if ans:
        print(len(ans))
        print(*ans, sep='\n')
    else:
        print(-1)


Measured memory_bytes: 9920