akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define rep2(i, l, r) for(Int i = (Int)(l); i < (Int)(r); ++i)
#define guard(x) if( not (x) ) continue;
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif

template<typename T>
using RQ = std::priority_queue<T, std::vector<T>, std::greater<T>>;

int main() {
   Int v, e, f;
   std::cin >> v >> e >> f;
   std::vector<Int> ss(e+1), ts(e+1), cs(e+1), fs(e+1), bs(e+1);
   rep2(i,1,e+1) {
      Int a, b, c, d;
      std::cin >> a >> b >> c >> d;
      ss[i] = a, ts[i] = b, cs[i] = d, fs[i] = 0, bs[i] = c;
   }
   std::vector<std::vector<Int>> es(v);
   rep2(i,1,e+1) {
       Int s = ss[i], t = ts[i];
      es[s].emplace_back(i);
      es[t].emplace_back(-i);
   }
   Int res = 0;
   Int source = 0, sink = v-1;
   std::vector<Int> hs(v);
   while( f > 0 ) {
      RQ<std::pair<Int,Int>> q;
      q.emplace(0, source);
      std::vector<Int> ps(v, -1), xs(v, -1), ys(v);
      xs[source] = 0;
      ys[source] = f;
      while( not q.empty() ) {
         Int d, s; std::tie(d, s) = q.top(); q.pop();
         guard( d == xs[s] );
         for(Int i : es[s]) {
            Int k = std::abs(i);
            Int t = i > 0 ? ts[k] : ss[k];
            Int tf = i > 0 ? bs[k] : fs[k];
            guard( tf > 0 );
            Int nd = d + (i>0?cs[k]:-cs[k]) + hs[s] - hs[t];
            guard( xs[t] == -1 or xs[t] > nd );
            xs[t] = nd;
            ps[t] = i;
            ys[t] = std::min(ys[s], tf);
            q.emplace(nd, t);
         }
      }
      Int tf = ys[sink];
      f -= tf;
      if( f > 0 and tf == 0 ) {
         res = -1;
         break;
      }
      rep(i, v) hs[i] += xs[i];
      for(Int i=sink, k=ps[i]; i!=source; i=(k>0?ss[k]:ts[-k]), k=ps[i]) {
         Int ak = std::abs(k);
         if( k > 0 ) {
            fs[ak] += tf;
            bs[ak] -= tf;
         }
         else {
            fs[ak] -= tf;
            bs[ak] += tf;
         }
      }
      res += tf * hs[sink];
      if( f == 0 ) break;
   }
   printf("%ld\n", res);
}



Measured memory_bytes: 3312
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
	
		while(true){
			String str[] = scan.nextLine().split(" ");
			int a = Integer.parseInt(str[0]);
			int b = Integer.parseInt(str[2]);
			if("?".equals(str[1])) break;
			if("+".equals(str[1])){
				System.out.println(a+b);
			} else if("-".equals(str[1])){
				System.out.println(a-b);
			} else if("*".equals(str[1])){
				System.out.println(a*b);
			} else if("/".equals(str[1])){
				System.out.println(a/b);
			}
		}
	}
} 

Measured memory_bytes: 17180
if __name__ == '__main__':
	l = input().split()
	count = 0

	for i in range(len(l)):
		i -= count
		if l[i] == '+':
			l[i - 2] = str(int(l[i - 2])  + int(l[i - 1]))
			l.pop(i - 1)
			l.pop(i - 1)
			count += 2

		elif l[i] == '-':
			l[i - 2] = str(int(l[i - 2])  - int(l[i - 1]))
			l.pop(i - 1)
			l.pop(i - 1)
			count += 2

		elif l[i] == '*':
			l[i - 2] = str(int(l[i - 2])  * int(l[i - 1]))
			l.pop(i - 1)
			l.pop(i - 1)
			count += 2

		else:
			continue
	if len(l) > 1:
		print("Error")
	else:
		print(l[0])



Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S ;
  if(S=="A"){
    cout << "T";
  }
  if(S=="T"){
    cout << "A";
  }
  if(S=="G"){
    cout << "C";
  }
  if(S=="C"){
    cout << "G";
  }
}

Measured memory_bytes: 256
a,b,k = gets.chomp.split.map(&:to_i)
ai = gets.chomp.split.map(&:to_i)
bi = gets.chomp.split.map(&:to_i)
aiSum,biSum = [0],[0]
for i in 0..ai.count - 1 do
  if ai[i] + aiSum[i] > k
    break
  end
  aiSum[i + 1] = ai[i] + aiSum[i]
end
for j in 0..bi.count - 1 do
  if bi[j] + biSum[j] > k
    break
  end
  biSum[j + 1] = bi[j] + biSum[j]
end

num = 0
best = biSum.count - 1
aiSum.each_with_index do |a,i|
  while biSum[best] > k - a
    best -= 1
  end
  if num < i + best
    num = i + best
  end
end
puts num


Measured memory_bytes: 46164
#include<cstdio>
const int N=107;
int n,m,k,P,f[N][N][N],C[N][N],pw[N][N];
void inc(int&a,int b){a+=b-P,a+=a>>31&P;}
int sub(int a,int b){return a-=b,a+(a>>31&P);}
int mul(int a,int b){return 1ll*a*b%P;}
int main()
{
    scanf("%d%d%d%d",&n,&m,&k,&P),f[0][0][0]=1;
    for(int i=0;i<=100;++i) for(int j=C[i][0]=1;j<=i;++j) inc(C[i][j]=C[i-1][j],C[i-1][j-1]);
    for(int i=0;i<=100;++i) for(int j=pw[i][0]=1;j<=100;++j) pw[i][j]=mul(pw[i][j-1],i);
    for(int h=1;h<=k;++h)
    {
	for(int i=0;i<=n;++i)
	    for(int j=0;j<=m;++j)
		for(int t=mul(pw[k-h+1][j],sub(pw[h][m-j],pw[h-1][m-j])),s=1,l=i;l<=n;++l)
		    inc(f[h][l][j],mul(mul(s,C[n-i][l-i]),f[h-1][i][j])),s=mul(s,t);
	for(int i=0;i<=n;++i)
	    for(int j=m;~j;--j)
		for(int t=mul(pw[h][n-i],sub(pw[k-h+1][i],pw[k-h][i])),s=1,l=j+1;l<=m;++l)
		    s=mul(s,t),inc(f[h][i][l],mul(mul(s,C[m-j][l-j]),f[h][i][j]));
    }
    printf("%d",f[k][n][m]);
}

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

namespace Dice_I
{
    class Program
    {
        static void Main(string[] args)
        {
            var input_surface = Console.ReadLine().Split(' ');
            char[] input_command = Console.ReadLine().ToCharArray();
            Dice dice = new Dice(input_surface);
            for (int i = 0; i < input_command.Length; ++i)
            {
                dice.rotation(input_command[i]);
            }
            Console.WriteLine(dice.get_surface(0));
        }
    }

    class Dice
    {
        private int[] surface;

        public Dice(String[] str)
        {
            surface = new int[6];
            for (int i = 0; i < 6; ++i)
            {
                this.surface[i] = int.Parse(str[i]);
            }
        }

        public int[] get_surface()
        {
            return this.surface;
        }
        public int get_surface(int n)
        {
            return this.surface[n];
        }

        public void rotation(char c)
        {
            switch (c)
            {
                case 'E':
                    rotation_E();
                    break;
                case 'N':
                    rotation_N();
                    break;
                case 'S':
                    rotation_S();
                    break;
                case 'W':
                    rotation_W();
                    break;
            }
        }

        private void rotation_E() 
        {
            rotation_run(0, 3, 5, 2);
        }

        private void rotation_N()
        {
            rotation_run(0, 1, 5, 4);
        }

        private void rotation_S() 
        {
            rotation_run(0, 4, 5, 1);
        }
        private void rotation_W()
        {
            rotation_run(0, 2, 5, 3);
        }

        static void swap(ref int a, ref int b)
        {
            var t = a;
            a = b;
            b = t;
        }

        void rotation_run(int a, int b, int c, int d)
        {
            var work = surface[a];
            surface[a] = surface[b];
            surface[b] = surface[c];
            surface[c] = surface[d];
            surface[d] = work;
        }
    }
}


Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int b,i;
    cin>>b;
    cout<<a[b-1]<<endl;
}


Measured memory_bytes: 256
from itertools import permutations

N, C = map(int, input().split())

D = [list(map(int, input().split())) for _ in range(C)]
grid = [list(map(int, input().split())) for _ in range(N)]

cnt = [[0] * C for _ in range(3)]

for i in range(N):
    for j in range(N):
        cnt[(i + j) % 3][grid[i][j] - 1] += 1

ans = N * N * 1000 + 10
for color in permutations(range(C), 3):
    dis = 0
    for i in range(3):
        for j in range(C):
            d = D[j][color[i]]
            num = cnt[i][j]
            dis += d * num

    ans = min(ans, dis)

print(ans)


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

using namespace std;

int main()
{
	int n;
  	cin >> n;
  	vector<int> a(n);
  	for(auto &x: a) cin >> x;
  	sort(a.begin(), a.end());
  	cout << a[n / 2] - a[(n / 2) - 1];
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i= a ; i < b ; ++i)
#define rep(i,n) fo(i,0,n)
#define pln(n) printf("%lld\n",n)
#define sll(n) scanf("%lld",&n)
#define ss(n) scanf("%s",n)
#define vi vector < int >
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define dbg3(x,y,z) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) <<" , "<< #z <<": "<<(z)<<endl; }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<int>
#define tr(c, it) \
for(decltype(c.begin()) it = c.begin(); it!= c.end(); it++)
#define pis pair<int,string>
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c),x) != c.end())
#define mod (int)(1e9 + 7) 
using namespace std;



int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> s(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = n-1; i >= 0; i--){
		if(i +1 < n)s[i] = (s[i+1] + a[i]%mod)%mod;
		else s[i] = a[i];
	}
	int ans = 0;
	for(int i = 0; i < n-1; i++){
		ans = ans + ((ll)a[i] * s[i+1])%mod;
		ans = ans%mod;
	}
	cout << ans;



}


Measured memory_bytes: 4756
n,k = map(int,input().split())
l = list(map(int,input().split()))
dp = [0]*n
dp[0] = 0
dp[1] = abs(l[1]-l[0])+dp[0]
for i in range(2,n):
    r = i-k
    if r < 0:
        r = 0

    mi = 9999999999
    for j in range(r,i):
        t = dp[j]+abs(l[j]-l[i])
        if t < mi:
            mi = t

    dp[i] = mi

print(dp[-1])

Measured memory_bytes: 52448
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define F first
#define S second
#define FBO find_by_order
#define OOK order_of_key
#define mset(m,v) memset((m),(v),sizeof(m))
#define inrep int TC;cin>>TC;while(TC--)
#define cppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PI 3.1415926535897932384626433832795028841971693993751
#define trace1(x) cerr<<#x<<": "<<x<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<"\n"
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"\n"
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
// SOLUTION
 
int main() {
	cppio;
	int n;
	cin >> n;
	ll a[n], b[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) cin >> b[i];
	for(int i = 1; i < n; i++) a[i] += a[i - 1];
	for(int i = 1; i < n; i++) b[i] += b[i - 1];
	ll ans = a[0] + b[n -  1];
	for(int i = 1; i < n; i++) ans = max(ans, a[i] + b[n - 1] - b[i - 1]);
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int a['z' - 'a' + 1] = {};
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); ++i) {
    ++a[s[i] - 'a'];
  }
  bool flag = false;
  for(int i = 0; i <= 'z' - 'a'; ++i) {
    if(!a[i]) {cout << char('a' + i) << endl; flag = true; break; }
  }
  if(!flag) cout << "None" << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int
main()
{
    int A[3][3] = {{0,0,0},{0,0,0},{0,0,0}};
    int B[3][3] = {{0,0,0},{0,0,0},{0,0,0}};
    int N = 0;;

    cin >> A[0][0] >> A[0][1] >> A[0][2];
    cin >> A[1][0] >> A[1][1] >> A[1][2];
    cin >> A[2][0] >> A[2][1] >> A[2][2];    

    cin >> N;

    int b[100] = {0};
    for(int i=0;i<N;i++)
        cin >> b[i];

    for(int i=0;i<N;i++) {
        for(int j=0;j<3;j++) {        
            for(int k=0;k<3;k++){
                if(b[i] == A[j][k]) {
                    B[j][k] = 1;
                }
            }
        }
    }

    for(int i=0;i<3;i++){
        if(B[i][0] == 1 &&
           B[i][1] == 1 &&
           B[i][2] == 1) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    for(int i=0;i<3;i++){
        if(B[0][i] == 1 &&
           B[1][i] == 1 &&
           B[2][i] == 1) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    if(B[0][0] == 1 &&
       B[1][1] == 1 &&
       B[2][2] == 1) {
        cout << "Yes" << endl;
        return 0;
    }

    if(B[0][2] == 1 &&
       B[1][1] == 1 &&
       B[2][0] == 1) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;    
    return 0;
}

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


int main(){
  string s;
  cin >> s;
  vector<string> d = {"2019/04/30",s};
  sort(d.begin(),d.end());
  if(d.at(0) == s) cout << "Heisei" << endl;
  else cout << "TBD" << endl;
  }


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n, d;
    cin >> n >> d;
    cout << ceil(n, 2*d+1) << endl;

    return 0;
}


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

template<typename T> struct UnionFind {
  vector<int> par;
  vector<int> rank;
  vector<T> ws;

  UnionFind(int n = 1, T e = 0)
      : par(n), rank(n), ws(n) {
    init(n, e);
  }

  void init(int n, T e) {
    for (int i = 0; i < n; ++i) {
      par[i] = i;
      rank[i] = 0;
      ws[i] = e;
    }
  }
  int root(int x) {
    if (par[x] == x) {
      return x;
    } else {
      int r = root(par[x]);
      ws[x] += ws[par[x]];
      return par[x] = r;
    }
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  T weight(int x) {
    root(x);
    return ws[x];
  }
  T diff(int x, int y) {
    return weight(y) - weight(x);
  }
  bool unite(int x, int y, T w = 0) {
    w -= weight(y) - weight(x);
    x = root(x);
    y = root(y);
    if (x == y) return false;

    if (rank[x] < rank[y]) {
      swap(x, y);
      w = negate<T>()(w);
    }
    par[y] = x;
    ws[y] = w;
    if (rank[x] == rank[y]) ++rank[x];
    return true;
  }
};

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

  int n, q; cin >> n >> q;
  UnionFind<ll> uf(n);

  while (q--) {
    int com; cin >> com;
    if (com) {
      int x, y; cin >> x >> y;
      cout << ( (uf.same(x, y)) ? to_string(uf.diff(x, y)) : "?" ) << endl;
    } else {
      int x, y, z; cin >> x >> y >> z;
      uf.unite(x, y, z);
    }
  }
  return 0;
}



Measured memory_bytes: 4404
#include <iostream>
#include <string>
#define llt long long int

using namespace std;
int main()
{
    llt n, a;

    cin >> n >> a;

    llt m = n % 500;

    if (a >= m)
        cout << "Yes" << endl;

    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int  long long
#define tc(t)  int t; cin>>t; while(t--)
#define f(n)    for(int i=0;i<n;i++)
#define endl   "\n"
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
     int n;
     cin>>n;
     vector<int>v(n);
 
     f(n)cin>>v[i];
     int k=1;
     int count=0;
     for(int i=0;i<n;i++)
     {
         if(v[i]!=k) count++;
         else k++;
     }
     if (count==n) cout<<"-1"<<endl;
     else 
        cout<<count<<endl;
 
 
 
 
 
 
 
 
}

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

struct Point {
  int x = 0, y = 0;
  int cnt = 0;
};

int main() {
  int n;
  cin >> n;
  vector<vector<int>> a(2, vector<int>(n));
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }

  queue<Point> q;
  q.push({});

  int mx = 0;
  while (!q.empty()) {
    Point p = q.front();
    q.pop();

    if (p.x >= n || p.y > 1) continue;

    p.cnt += a[p.y][p.x];

    if (p.y == 1 && p.x == n - 1) {
      mx = max(mx, p.cnt);
      continue;
    }
    if (p.x < n) { q.push({x : p.x + 1, y : p.y, cnt : p.cnt}); }
    if (p.y < 2) { q.push({x : p.x, y : p.y + 1, cnt : p.cnt}); }
  }
  cout << mx << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n;
char c[200];
long long aa[25];
int tot=0;
void work2(){
	long long  q=1,t=26;
	while(n>t){
		n-=t;
		t*=26;
		q++;
	}
	n--;
	if(n==0){
		for(int i=1;i<=q;i++)cout<<'a';
		cout<<endl;
		return ;
	}
	while(n){
		c[++tot]=char('a'+(n%26));
		n/=26;
	}
	while(tot<q){
		c[++tot]='a';
	}
	for(int i=tot;i>0;i--){
		cout<<char(c[i]);
	}
	cout<<endl;
}

int main(){
	cin>>n;
	
	work2();
	return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string s;
  cin >> s;
  vll lw(n + 1), rb(n + 1);
  for (int i = 0; i < n; i++) {
    lw[i + 1] = lw[i];
    if (s[i] == '#')
      lw[i + 1]++;
  }
  for (int i = n; i > 0; i--) {
    rb[i - 1] = rb[i];
    if (s[i - 1] == '.') {
      rb[i - 1]++;
    }
  }
  ll ans = n;
  for (int i = 0; i <= n; i++) {
    ans = min(ans, lw[i] + rb[i]);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	string s;
	int atta[26]={0};
	cin >> s;
	for(int j=0;s[j]!='\0';j++){
		
		for(int i=0;i<26;i++){
			char moji = 'a' +i;
			if(s[j]==moji){
				atta[i] = 1;
			}
		}
	}
	
	for(int i=0;i<26;i++){
		if(atta[i]==0){
			char kotae = 'a' + i;
			cout << kotae << endl;
			break;
		}
		else if (i==25) cout << "None" << endl;
	}
	
	return 0;
}

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

int main() {
  int N;
  int k=0,timeall=0;
  cin >> N;
  string s[N];
  int t[N];
  string name;
  
for(int i=0;i<N;i++) {
 cin >> s[i]>>t[i];
 timeall+=t[i];
}
cin>> name;

while(name!=s[k]){
k++;
}

for(int i=0;i<=k;i++) timeall -=t[i];

 cout <<timeall;}

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

const int N = 3010;
int n, a[N], g[N];
vector<int> e[N];

int dfs(int v) {
	if (g[v] >= 0) return g[v];
	g[v] = 0;
	for (int i = 0; i < (int)e[v].size(); i++) {
		int u = e[v][i];
		g[v] |= !dfs(u);
	}
	return g[v];
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (int i = 0; i < n - 1; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		x--; y--;
		if (a[x] > a[y])
			e[x].push_back(y);
		else if (a[x] < a[y]) {
			e[y].push_back(x);
		}
	}
	fill_n(g, n, -1);
	for (int i = 0; i < n; i++) if (dfs(i)) 
		printf("%d ", i + 1);
	printf("\n");
}

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

int sumOfNth(int num) {
    int sum = 0;
    while (num > 0) {
        sum += num % 10;
        num /= 10;
    }
    return sum;
}

int main(void){
    int n;
    cin >> n;
    
    int ans = 10000000;
    for (int i=1; i<n; i++) {
        int a = i;
        int b = n - a;
        ans = min(ans, sumOfNth(a)+sumOfNth(b));
        
    }
    cout << ans << endl;
}



Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 1e9;
  for (int i = 0; i < n; i++) {
    int x = a[i];
    vector<int> subs;
    vector<int> full;
    for (int j = 0; j < n; j++) {
      if (a[j] >= x) {
	subs.push_back(a[j]);
      }
      else {
	if (subs.size() >= k) {
	  sort(subs.begin(), subs.end());
	  for (int l = 0; l < subs.size() - k + 1; l++) {
	    full.push_back(subs[l]);
	  }
	}
	subs.clear();
      }
    }
    if (subs.size() >= k) {
      sort(subs.begin(), subs.end());
      for (int l = 0; l < subs.size() - k + 1; l++) {
	full.push_back(subs[l]);
      }
    }
    sort(full.begin(), full.end());
    if (full.size() >= q) {
      ans = min(ans, full[q - 1] - x);
    }
  }
  cout << ans;
}


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

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

fn main() {
    let n: usize = read();
    let m: usize = read();

    if n == m {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(){
  int n;
  int d,s,a,i;
  while(1){
    scanf("%d",&n);
    if(!n)break;
    a=1;
    s=0;
    for(i=0;i<n;i++){
      scanf("%d",&d);
      if(d>1)a=0;
      if(d)s++;
    }
    if(a)printf("NA\n");
    else printf("%d\n",s+1);
  }
  return 0;
}

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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int res = 0;
	if (N % 2 == 0) {
		for (int x = 5; x <= N; x *= 5) {
			res += (N / 2) / x;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <stack>
#include <vector>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <set>
#include <limits>
#include <numeric>
using namespace std;

int main()
{
	int n;
	cin >> n;
	int k;
	cin >> k;
	vector<int> heights(n + k, 0);
	vector<int> dp(n + k, numeric_limits<int>::max());

	for (int i = 0; i < n; ++i)
	{
		cin >> heights[i + k];
	}
	for (int i = 0; i < k; ++i)
	{
		heights[i] = heights[k];
		dp[i] = 0;
	}

	for (int i = k; i < heights.size(); ++i)
	{
		for (int j = i - k; j < i; ++j)
		{
			dp[i] = min(dp[i], dp[j] + abs(heights[j] - heights[i]));
		}
	}

	cout << dp.back();

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n,h;
  cin >> h >> n;
  ll s=0;
  for(ll i=0;i<n;i++) {
    ll tmp;
    cin >> tmp;
    s+=tmp;
  }
  if(s>=h) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3660
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int main(){
    int n, m; cin >> n >> m;
    VI c(m), dp(n+1);
    REP(i, m) cin >> c[i];
    SORT(c);
    REPS(i, n) dp[i] = i;
    FOR(i, 1, m){
        FORS(j, 1, n){
            if(j >= c[i])
                chmin(dp[j], dp[j-c[i]]+1);
        }
    }
    cout << dp[n] << endl;
    return 0;
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000003
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

//power_mod
inline int Pow_mod(int x, int pow){
    if(pow==0) return 1;
    int a=Pow_mod(x, pow/2);
    a=a*a%mod;
    if(pow%2==1) a*=x;
    return a%mod;
}

int fact[1000010];



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

    fact[0]=1;
    rep(i,1000005)fact[i+1]=fact[i]*(i+1)%mod;

    int q; cin>>q;
    rep(i,q){
        int x,d,n; cin>>x>>d>>n;
        if(d==0){
            cout<<Pow_mod(x,n)<<endl; continue;
        }
        int newx=x*Pow_mod(d,mod-2)%mod;
        if(mod<newx+n or newx==0)cout<<0<<endl;
        else cout<<fact[newx+n-1]*Pow_mod(fact[newx-1],mod-2)%mod*Pow_mod(d,n)%mod<<endl;
    }

}

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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    char a;
    cin >> a;
    cout << (a <= 'Z' ? "A" : "a") << endl;
    return 0;
}


Measured memory_bytes: 3560
import sys
sys.setrecursionlimit(100000)

def func(num,pr):
  global l,ans

  if len(l[num])!=0:
    for z in l[num]:
      if z[0]==pr:
        continue

      if pr==-1:
        ans[z[0]]=z[1]
      else:
        ans[z[0]]=ans[num]+z[1]
      func(z[0],num)

N=int(input())
l=[ [] for z in range(N)]
ans=[0]*N


for z in range(N-1):
  u,v,w=list(map(int,input().split(" ")))
  l[u-1].append((v-1,w))
  l[v-1].append((u-1,w))

func(0,-1)

#print(l)
#print(ans)


for z in ans:
  if z%2==0:
    print(1)
  else:
    print(0)

Measured memory_bytes: 86472
/*
Coded by XIZCM
*/

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <iomanip>
#include <vector>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <ctime>
#include <fstream>
#include <stdarg.h>

using namespace std;

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

const bool debug=false;
const bool INJUDGE=false;
const int MAXN=100005;
const int MOD=1000000007;
const int INF=1000000007;

template<class T>T emax(T& a,T b){return a=max(a,b);}
template<class T>T emin(T& a,T b){return a=min(a,b);}
template<class T>void byebye(T info){cout<<info<<endl;exit(0);}
template<class T1,class T2>ostream& operator<<(ostream& out,pair<T1,T2> P){out<<P.first<<" "<<P.second;return out;}
template<class T>ostream& operator<<(ostream& out,vector<T> V){for(int i=0;i<V.size();++i)out<<V[i]<<" ";return out;}

int n,k;

int main(){
	cin>>n>>k;
	if(k==1){
		cout<<0<<endl;
		return 0;
	}
	int mx=n-(k-1),mn=1;
	cout<<mx-mn<<endl;
	return 0;
}



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

using namespace std;

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define endl "\n"

#define aim_cpo do{ios::sync_with_stdio(false);\
cin.tie(nullptr);cout.precision(10);cout<<fixed;}while(0)

#define LOCAL_INPUT do{FILE *stream1;\
stream1=freopen("/Users/aim_cpo/CLionProjects/competitive/in.txt","r",stdin);\
if(stream1==nullptr)return 0;}while(0)

#define LOCAL_OUTPUT do{FILE *stream2;\
stream2 = freopen("out.txt", "w", stdout);\
if (stream2 == nullptr) return 0;}while(0)

#ifdef LOCAL_DEFINE
#define show(x) cerr << #x << " = " << x << endl
#else
#define show(x)
#endif

typedef long long ll;
typedef unsigned long long ull;

constexpr const int INT_INF=0x3f3f3f3f; // 1061109567
constexpr const ll LL_INF=0x3f3f3f3f3f3f3f3f; // 4557430888798830399

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

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

// INT
#define GCD(a, b) __gcd(a, b)
template <typename T> T LCM(T a, T b) {return a / GCD(a, b) * b;}
template <typename T> T EXTGCD(T a, T b, T& x, T& y) {
    T d = a;
    if (b != 0) {d=EXTGCD(b,a%b,y,x);y-=(a/b)*x;}
    else x=1,y=0;
    return d;
}
template <typename T> bool is_prime(T a) {
    for(int i=2;i*i<=a;i++)if(a%i==0)return 1;
    return 0;
}

// MOD
const ll MOD = (ll)1e9 + 7;
#define add(a, b) ((a % MOD) + (b % MOD)) % MOD
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define sub(a, b) ((a % MOD) + MOD - (b % MOD)) % MOD
template <typename T> T mod_inverse(T a, T mod, bool prime){ // if mod is prime, "prime" is true.
    if(prime){
        T tmp=mod-2,now=a,res=1;while(tmp){if(tmp&1)res=mul(res,now);now=mul(now,now);tmp>>=1;}
        return res;
    }else{T x,y;EXTGCD(a,mod,x,y);return (mod+x%mod)%mod;}
}
#define divide(a, b) ((a % MOD) * (mod_inverse(b, MOD, true))) % MOD

//LLの数値をつかう時は最後にLをつける癖をつけよう
//
//  ┏┓┏┓　┓　┏┓
//  ┏┛┃┃　┃　┗┫
//  ┗┛┗┛　┻　┗┛
//
//   謹┃賀┃新┃年┃
//   ━┛━┛━┛━┛
//WWWWWWWWWWWWWWWWWWWWWW

int n, m, w, k;
double a[3001];
double dp[3001][3001];

int main() {
    aim_cpo; // インタラクティブのときは消すように.
#ifdef LOCAL_DEFINE
    LOCAL_INPUT; // インタラクティブのときは消すように.
//    LOCAL_OUTPUT; // ファイルに出力したいときのみ
    show(MOD);
#endif
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    dp[0][0] = 1.0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= n; j++) {
            if (dp[i][j] == 0.0) continue;
            dp[i + 1][j + 1] += dp[i][j] * a[i];
            dp[i + 1][j] += dp[i][j] * (1.0 - a[i]);
        }
    }
    double ans = 0.0;
    for (int i = n; i >= 0; i--) {
        if (i > n - i) ans += dp[n][i];
        else break;
    }
    cout << ans << endl;
#ifdef  LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s." << endl;
#endif
    return 0;
}

Measured memory_bytes: 68864
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int c=0;
    if(n<10)cout<<n<<endl;
    else if(n>=10&&n<=99)cout<<9<<endl;
    else{
        c+=9;
        for(int i=100;i<=n;i++){
            stringstream s;
            string a="";
            s<<i;
            s>>a;
            if(a.size()%2==1)c++;
            else i*10;
        }
        cout<<c<<endl;
    }

    return 0;
}


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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = (int)2e5 + 9;
const int MOD = 2019;

int cnt[MOD];

int main(){
  fastIO;
  string t;
  cin >> t;
  int n = t.size();
  int cur = 0;
  int pw = 1;
  ll ans = 0;
  cnt[0]++;
  for(int i = n - 1; i >= 0 ; i -- ){
    cur += (t[i] - '0') * pw;
    cur %= MOD;
    ans += cnt[cur];
    cnt[cur] ++ ;
    pw = (pw * 10) % MOD;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3808
N, K = map(int, input().split(' '))
A = list(map(int, input().split(' ')))

X = 0
bit_l = 0
while K >= (1 << bit_l):
    bit_l += 1
bit_l -= 1

while bit_l >= 0:
    one = 0
    for a in A:
        one += int(((a >> bit_l) & 1) == 1)
    if one < N - one and (X | (1 << bit_l)) <= K:
        X = X | (1 << bit_l)
    bit_l -= 1

ans = sum([a ^ X for a in A])
print(ans)

Measured memory_bytes: 14620
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



int main() {
	int n;
	ll l;

	cin >> n >> l;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int last = -1;
	for (int i = 0; i < n - 1; i++) {
		if (a[i] + a[i + 1] >= l) {
			last = i;
			break;
		}
	}

	if (last < 0) {
		cout << "Impossible" << endl;
		return 0;
	}
	cout << "Possible" << endl;

	for (int i = 0; i < last; i++) {

		cout << i + 1 << endl;
	}

	for (int i = n - 2; i >= last; i--) {

		cout << i + 1 << endl;
	}

}

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

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

  int ans = 0;

  rep(i,n+1){
    ans += i;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
class aoj
{
    static void Main()
    {
        double a = 0,b= 100000;
        while (true)
        {
            string c = Console.ReadLine();
            if (String.IsNullOrEmpty(c)) break;
            double d = double.Parse(c);
            if (d > a)
            {
                a = d;
                goto stop;
            }
            else if (d < b)
            {
                b = d;
                goto stop;
            }
            stop:;
        }
        Console.WriteLine(a - b);
    }
}

Measured memory_bytes: 9224
N, X = map(int, input().split())
L = [0] * (N + 1)
L[0] = 1
for i in range(1, N + 1):
    L[i] = 2 * L[i - 1] + 3

P = [0] * (N + 1)
P[0] = 1
for i in range(1, N + 1):
    P[i] = 2 * P[i - 1] + 1


def calc(N, X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + L[N - 1]:
        return calc(N - 1, X - 1)
    else:
        return P[N - 1] + 1 + calc(N - 1, X - 2 - L[N - 1])


print(calc(N, X))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
int main()
{
    int N,M;
    cin >> N >> M;
    vector<vector<int>> book(M,vector<int>(N,0));
    vint P(M);
    REP(i,M){
        int K;
        int s;
        cin >> K;
        REP(k,K){
            cin >> s;
            s--;
            book[i][s] = 1;
        }
    }
    cin >> P;
    int ans=0;
    for(int bit=0; bit < (1 << N); bit++){
        vint cnt(M);
        bool flag = true;
        for(int s=0; s<N; s++){
            if(bit & (1 << s)){
                for(int i=0; i<M; i++){
                    if(book[i][s]){
                        cnt[i]++;
                    }
                }
            }
        }
        REP(i,P.size()){
            if(P[i] != cnt[i]%2){
                flag = false;
            }
        }
        if(flag){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

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

  cout << (n/10==9 || n%10==9 ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
a = list(raw_input())
b = []
q = input()
for _ in xrange(q):
    line = raw_input().split()
    if line[0] == "1":
        a, b = b, a
    elif line[1] == "1":
        b.append(line[2])
    else:
        a.append(line[2])
print ''.join(b[::-1] + a)


Measured memory_bytes: 57596
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <queue>
#include<string>
#include<cstring>
#include<complex>
#include<cmath>
using namespace std;
#define rep(i, n)   for(int i = 0; i < (int)(n); i++)
#define rrp(i, n)   for(int i = ((int)(n)); i >=0; i--)
#define mpp(i,j,k)  make_pair((int)(i),make_pair((int)(j),(int)(k)))
typedef pair<int,pair<int,int > > ppp;
typedef pair<int,int> pp;
typedef vector<int> vi;
typedef vector<vi>  vvi;
vector <pair<int,int>  >  d;
vector <vector <pair<int,int>  > > e(200000);
int ddd[200000];
vi dd,dx,ans;
int s,t,ek,l,r,n,m,x,y;
int dfs(int i){
  ddd[i]=1;
  rep(k,e[i].size()){
    ek=e[i][k].first;
    if(ddd[ek])continue;
    
    if(dfs(ek)){
       dd[i]^=1;
       ans.push_back(e[i][k].second);}
  }
 return dd[i];
}
int main(){
cin>>n>>m;
rep(i,n)cin>>s>>t,d.push_back(make_pair(s,t));
sort(d.begin(),d.end());
for(auto& i : d)dx.push_back(i.first);
dd.push_back(d[0].second);
rep(i,n-1)dd.push_back(d[i+1].second^d[i].second);
dd.push_back(d.back().second^0);
rep(i,m){
cin>>l>>r;
auto xt=lower_bound(dx.begin(),dx.end(),l);
auto yt=lower_bound(dx.begin(),dx.end(),r+1);
int yi=yt-dx.begin();
int xi=xt-dx.begin();
if(xt==yt)continue;
e[xi].push_back(make_pair(yi,i+1));
e[yi].push_back(make_pair(xi,i+1));
}
rep(ii,dd.size()){
    if (ddd[ii]==0){
       if (dfs(ii)){
         cout<<-1<<endl;
         return 0;}
         }}
cout<<ans.size()<<endl;
sort(ans.begin(),ans.end());
for(int i:ans)cout<<i<<" ";
cout<<endl;
  return 0;
}


Measured memory_bytes: 17396
#include <bits/stdc++.h>
using namespace std;
int n;
pair<int,int> a[234567];
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>(a[i].second)>>(a[i].first);
	}
	sort(a,a+n);
	int t=0,c=0;
	for(int i=0;i<n;i++){
		t+=a[i].second;
		if(t>a[i].first)break;
		c++;
	}
	if(c==n)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll a,b;
    cin>>a>>b;
    
    if(a == 1 && b == 2)cout << 3 << endl;
    else if (a == 1 && b == 3)cout << 2 << endl;
    else if (a == 2 && b == 1)cout << 3 << endl;
    else if (a == 3 && b == 1)cout << 2 << endl;
    else if (a == 2 && b == 3)cout << 1 << endl;
    else if (a == 3 && b == 2)cout << 1 << endl;
    else cout << 1 << endl;
    
    return 0;
}



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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    double dis = sqrt(pow((x1 - x2), 2) + pow((y1 - y2), 2));
    cout << fixed << setprecision(5) << dis << endl;
    return 0;
}


Measured memory_bytes: 3272
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){

    ll n;
    cin >> n;
    pair<ll,ll> p[n];
    rep(i,0,n){
	ll a,b;
	cin >> a >> b;
	p[i] = {b,a};
    }
    sort(p,p+n);
    ll t = 0;
    rep(i,0,n){
	t = t+p[i].sd;
	if(p[i].ft < t){
	    No;
	    ret 0;
	}
    }
    Yes;
    return  0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    int N,K,Q; cin >> N >> K >> Q;
    vector<int> a(N);
    rep(i,N) cin >> a[i];
    int ans = INF;
    rep(i,N){
        vector<int> v;
        vector<vector<int>> v2(N);
        int now = 0;
        rep(j,N){
            if(a[j] < a[i]){
                rep(k,v.size()){
                    v2[now].push_back(v[k]);
                }
                now++;
                v.clear();
            }
            else{
                v.push_back(a[j]);
            }
        }
        rep(j,v.size()){
            v2[now].push_back(v[j]);
        }
        vector<int> v3;
        rep(j,N){
            sort(v2[j].begin(),v2[j].end());
            rep(k,max(0,(int)v2[j].size()-K+1)){
                v3.push_back(v2[j][k]);
            }
        }
        sort(v3.begin(),v3.end());
        if(v3.size() < Q) continue;
        int Min = INF;
        int Max = 0;
        rep(j,Q){
            Min = min(Min,v3[j]);
            Max = max(Max,v3[j]);
        }
        ans = min(ans,Max-Min);
    }
    cout << ans << endl;
}


Measured memory_bytes: 384