akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>

using namespace std;
using ll = long long;

int main(){
    ll N;
    cin>>N;
    ll A[N];
    for(int i=0;i<N;i++) {cin>>A[i];A[i] -= i+1;}
    sort(A, A+N);
    ll b = A[N/2];
    ll ans=0;
    for(int i=0;i<N;i++){
        ans += abs(A[i]-b);
    }
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 1792
n = int(input())
a = [int(i) for i in input().split()] 
#print(a)
b = [0] * n
#print(b)
for i in range(0, n)[::-1]:
  if (i+1)*2 > n:
    if a[i] == 1:
      b[i] = 1
  else:
    tmp = 0
    for j in range(i,n)[::i+1]:
     # print(i, j)
      tmp = tmp ^ b[j]
    b[i] = tmp ^ a[i]
#print(b)
print(sum(b))
for i in range(n):
  if b[i] == 1:
    print(i+1, end=" ")


Measured memory_bytes: 7276
using System;
class Search
{
    public long[,,] GetMin(long[,] a)
    {
        int n = a.Length;
        n = (int)Math.Pow(n, 0.5);
        long[,,] b = new long[n - 1, n, n];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                b[0, i, j] = a[i, j];
        for (int g = 0; g < n; g++)
        {
            for (int k = 1; k < n - 1; k++)
            {
                for (int l = 0; l < n; l++)
                {
                    long min = long.MaxValue;
                    for (int i = 0; i < n; i++)
                    {
                        if (i != l && a[l, i] != -1 && b[k - 1, i, g] != -1)
                        {
                            min = Math.Min(min, a[l, i] + b[k - 1, i, g]);
                        }
                        if (b[k - 1, l, g] != -1)
                            b[k, l, g] = Math.Min(b[k - 1, l, g], min);
                        else if (min != long.MaxValue)
                            b[k, l, g] = min;
                        else
                            b[k, l, g] = -1;
                    }
                }
            }
        }
        return b; //b[k,l,g]はlから最大k個の点を経由してgまで行く最短距離
    }
}
class Program
{
    public static void Main()
    {
        Search s = new Search();
        string[] str = Console.ReadLine().Split(' ');
        int h = int.Parse(str[0]);
        int w = int.Parse(str[1]);
        long[,] c = new long[10, 10];
        for (int i = 0; i < 10; i++)
        {
            str = Console.ReadLine().Split(' ');
            for (int j = 0; j < 10; j++)
                c[i, j] = long.Parse(str[j]);
        }
        long[,,] b = s.GetMin(c);
        long sum = 0;
        for (int i = 0; i < h; i++)
        {
            str = Console.ReadLine().Split(' ');
            for (int j = 0; j < w; j++)
                if (int.Parse(str[j]) != -1)
                    sum += b[8, int.Parse(str[j]), 1];
        }
        Console.WriteLine(sum);
    }
}

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

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

    int max = 1 << 29;
    int count = 0;
    for (int i = 0; i < n; i++){
        int tmp;
        cin >> tmp;
        if (max > tmp){
            count++;
            max = tmp;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main()
{
    int a[100], n, i, j, mini, x;
    int c = 0;
 
    scanf("%d", &n);
    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);
 
    for (i = 0; i < n; i++) {
        mini = i;
        for (j = i; j < n; j++) {
            if (a[j] < a[mini])
                mini = j;
        }
        if (mini != i) {
            x = a[i];
            a[i] = a[mini];
            a[mini] = x;
            c += 1;
        }
    }
 
    for (i = 0; i < n; i++) {
        if (i == n - 1) {
            printf("%d\n", a[i]);
        } else {
            printf("%d ", a[i]);
        }
    }
    printf("%d\n", c);
 
    return 0;
}

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

int main(){
 int r,d,x;
 cin >> r >> d >> x;
 for(int i = 0; i<10; i++){
     int xi = 0;
     xi = r*x-d;
     cout << xi << endl;
     x = xi;
 } 
 return 0;
 
}

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

int main(){
  string A, B, C;
  cin >> A >> B >> C;
  A+='Z';
  B+='Z';
  C+='Z';
  char i='a';
  char ans = 'Z';
  while(i!='Z'){
    if(i=='a'){
      i=A.at(0);
      A.erase(A.begin());
      ans='A';
    }
    if(i=='b'){
      i=B.at(0);
      B.erase(B.begin());
      ans='B';
    }
    if(i=='c'){
      i=C.at(0);
      C.erase(C.begin());
      ans='C';
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//“ In order to be irreplaceable, one must always be different”
#include <bits/stdc++.h>
using namespace std;
# define ll long long
#define endl "\n"
# define pi 3.14159265359
#define mod 1000000007
# define str string
# define vll vector<ll>
# define vstr vector<str>
# define vchar vector<char>
# define pb push_back
# define mll map<ll,ll>
#define mchar map<char, ll>
# define mstr map<str,ll>
# define vp vector< pair<ll,ll> >
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
# define f(x,y) for(int x=0;x<y;x++)
# define r(x,y) for(int x=y;x>=0;x--)
# define loop(x,y,z) for(int x=y;x<z;x++)
ll power(ll a , ll b){ll res=1;for(ll i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll gcd(ll a, ll b){
    if(b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a, b);
}
void print(vll a){
    for(int i=0;i<a.size();i++){
        cout<<a[i]<<' ';
    }
    cout<<endl;
}
vll inp(int n){
    vll a;
    ll x;
    f(i,n){
        cin>>x;
        a.pb(x);
    }
    return a;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll x,y;
    cin>>x>>y;
    ll a[x];
    f(i,x){
        cin>>a[i];
    }
    vll v1;
    v1.resize(x);
    for(ll i=0;i<x;i++){
        v1[i]=0;
    }
    f(i,y){
        ll b,c;
        cin>>b>>c;
        b--;
        c--;
        if(a[b]<a[c]){
            if((v1[b]==0) || (v1[b]==1)){
                v1[b]=2;
            }
             if(v1[c]==0){
                v1[c]=1;
            } 
        }
        if(a[c]<a[b]){
            if((v1[c]==0) || (v1[c]==1)){
                v1[c]=2;
            }
            if(v1[b]==0){
                v1[b]=1;
            }
        }
        if(a[c]==a[b]){
            v1[c]=2;
            v1[b]=2;
        }
    }
    //print(v1);
    ll ans=0;
    f(i,v1.size()){
        if((v1[i]==1) || (v1[i]==0)){
            ans++;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4792
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<double,Int> pdp;
#define A first
#define B second
#define pb(x) push_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define Itype(a) typeof(a.begin()) 
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(Itype(t) i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
const int MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A, B, C;
    cin >> A >> B >> C;
    cout << (A == B && B == C ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n,m; cin>>n>>m;
    vector<vector<ll>> s(m);
    rep(i,m){
        ll k; cin>>k;
        rep(j,k){
            ll tmp; cin>>tmp;
            s[i].push_back(tmp);
        }
    }
    vector<ll> p(m);
    rep(i,m) cin>>p[i];
    ll res=0;
    rep(i, 1<<n){
        bool iftrue=true;
        rep(j,m){
            ll tmp=0;
            for(ll x: s[j]){
                ll y=x-1;
                if((i>>y) & 1) tmp++;
            }
            if(tmp%2 != p[j]) iftrue=false;
        }
        if(iftrue) res++;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'

typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const Int INF = (1<<20);

signed main(){
    /*Int N,K;cin >> N >> K;
    vector<Int> H(N);
    for(auto &i:H) cin >> i;
    sort(H.begin(),H.end());
    reverse(H.begin(),H.end());
    for(Int i=0;i<K;i++){
        H[i] = 0;
    }
    Int ans = 0;
    for(auto &i:H) ans+=i;
    cout << ans << endl;*/
    Int N,K;cin >> N >> K;
    priority_queue<Int> que;
    for(Int i=0;i<N;i++){
        Int a;cin >> a;
        que.push(a);
    }
    Int sum = 0;
    for(Int i=0;i<N;i++){
        if(K>0){
            que.pop();
            K--;
        }else{
            sum+=que.top();
            que.pop();
        }
    }
    cout << sum << endl;
}



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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 28;
const ll INFL = 1LL << 50;


class Solver {
  public:
    map<string, int> mapping;
    ll get_int(string &s, int &i) {
        //debug(s.substr(i));
        assert(isdigit(s[i]));
        ll res = 0;
        while(isdigit(s[i])) {
            res *= 10;
            res += s[i++] - '0';            
        }
        return res;
    }
    ll get_atom(string &s, int &i) {
        //debug(s.substr(i));
        assert('A' <= s[i] and s[i] <= 'Z');
        string atom;
        atom.push_back(s[i++]);
        while('a' <= s[i] and s[i] <= 'z') {
            atom.push_back(s[i++]);
        }
        return mapping.count(atom) ? mapping[atom] : -INFL;
    }
    ll calc(string &s, int &i) {
        //debug(s.substr(i));
        assert(s[i] == '(');
        i++;
        ll res = 0;
        while(s[i] != ')') {
            if(s[i] == '(') {
                ll sum = calc(s, i);
                if(sum < 0) return -INFL;
                ll num = get_int(s, i);
                res += sum * num;
            } else {
                ll sum = get_atom(s, i);
                if(sum < 0) return -INFL;
                ll num = 1;
                if(isdigit(s[i])) num = get_int(s, i);
                res += sum * num;
            }
        }
        i++;
        return res;
    }
    bool solve() {        
        while(true) {
            string s; cin >> s;
            if(s == "END_OF_FIRST_PART") break;
            ll w; cin >> w;
            assert(mapping.count(s) == 0);
            mapping[s] = w;
        }
        // for(auto p : mapping) {
        //     //debug(p);
        // }
        while(true) {
            string q; cin >> q;
            if(q == "0") break;
            int i = 0;
            q = "(" + q + ")";
            ll ans = calc(q, i);
            if(ans < 0) cout << "UNKNOWN" << endl;
            else cout << ans << endl;
        }        
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}

Measured memory_bytes: 3224
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int x;
  scan(x);
  if (x >= 2000) {
    print(1);
    return 0;
  }
  int a = x / 100;
  int b = x % 100;
  if (a * 5 >= b) {
    print(1);
  } else {
    print(0);
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define int long long
#define f first
#define s second
signed main()
{
    FAST;
    
    int i=0,j=0,k=0,n=0,m=0,count=0,temp=0,z;
    int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
    int left=0,up=0,anss=0,start=0,end=0,r=0,q=0,total=0;
    int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
    int prev=0,mid=0,zz=0,d=0,val=0;
    
    cin>>n>>m;
    ans = n*(n-1);
    ans += m*(m-1);
    
    cout<<ans/2<<endl;
    
}

Measured memory_bytes: 256
function main()
  
  S = split(chomp(readline()),"")
  
  check = false
  count = 0
  
  check_A = 10^10
  check_Z = 0
  
  for i in 1:length(S)
    
    if S[i] == "A" && i < check_A
      check_A = i
    end
    
    if S[i] == "Z" && i > check_Z
      check_Z = i
    end
    
  end
  
  println(check_Z - check_A + 1)
  
end

main()

Measured memory_bytes: 134056
n,x = map(int,input().split())
an = list(map(int,input().split()))

an = sorted(an)

count = 0
for a in an:
	x -=a
	
	if x < 0:
		break
	
	count+=1
else:
	if 0 < x:
		count-=1
	
print(count) 

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
const double pi=3.14159265358979323846;
//setprecision(15)有効数字15桁
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
double a, b, x;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a>>b>>x;
    if(a*b/2>=x/a){
        cout<<setprecision(15)<<atan((b*b*a/2/x))*180/pi<<"\n";
    }
    else{
        cout<<setprecision(15)<<atan(2*(a*a*b-x)/a/a/a)*180/pi<<"\n";
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define pb push_back
#define ff first
#define ss second
#define BS binary_search
#define all(c) (c).begin(),(c).end()
#define sz(x) (int)(x).size()
#define EPS 0.000000001 //1e-9
using pii=pair<int,int>;
const long long INF=1e18;

template <class A, class B> ostream& operator<<(ostream& os, const pair<A,B> p) {return os << "(" << p.first << "," << p.second << ")";} 

void dprint(string s) {cout << endl;}
template <class T, class... U> void dprint(string s, T t, U... u) 
{int w = s.find(','); cout << "[" << s.substr(0,w) << ": " << t << "] "; dprint(s.substr(w+1, (int)s.size()-w), u...);} 

#define DEBUG 
#ifdef DEBUG
#define dbg(X...) dprint(#X,X)
#else
#define dbg(X...) "KEEP CALM" 
#endif

const int N=1e6+5; // Don't forget to CHANGE this value ACC. TO Q.

int32_t main()
{
    IOS;
    int k; cin>>k;
    bool rem[k+1]={};
    int prv=0;
    for(int i=1;i<=k;i++)
    {
        int n=((prv*(10%k))%k + 7%k)%k;
        if(n==0)
            {cout<<i; return 0;}
        prv=n;
    }
    cout<<-1;
    return 0;
}

Measured memory_bytes: 4584
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int a = scanner.nextInt();
		int b = scanner.nextInt();

		int total = 0;
		for (int i = 1; i <= n; i++) {
			int one = i % 10;
			int ten = Math.floorDiv(i % 100, 10);
			int hundred = Math.floorDiv(i % 1000, 100);
			int thousand = Math.floorDiv(i % 10000, 1000);
			int man = (i == 10000)? 1 : 0;

			int sum = one + ten + hundred + thousand + man;
			if (a <= sum && sum <= b) {
				total += i;
			}
		}
		System.out.println(total);
	}
}

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

int main()
{
    int N;
    int alice, bob;
    alice = bob = 0;
    cin >> N;

    vector<int> data(N);
    rep(i, N) cin >> data[i];
    sort(data.begin(), data.end());
    rep(i, N)
    {
        if (i % 2 == 0)
            alice += data[N - 1 - i];
        else
            bob += data[N - 1 - i];
    }
    cout << alice - bob << endl;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, M = MAP()
A = [0] + LIST()

A_acc = list(accumulate(A))
A_acc_mod = [x%M for x in A_acc]

ans = 0
for value in Counter(A_acc_mod).values():
	ans += value*(value-1)//2

print(ans)

Measured memory_bytes: 27588
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map>
#include <map>
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
using namespace std;

int main(){
	int a, b ,x;

	cin >> a >> b;

	x = a * b;
	x = fmod((double)x, 2);

	if (x == 0) {
		cout << "Even";
	}
	else {
		cout << "Odd";
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define sz(a) (int)a.size()
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define vii vector<pii>
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}
 
ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 


int solve(){


	int n,m;cin>>n>>m;
	int a[m];
	inputarr(a,m);
	int sum=0;
	for(int i=0;i<m;i++) sum+=a[i];
	if(sum>n) cout<<-1;
else cout<<n-sum;

    return 0;
}
signed main(){
    asdf
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> boss_num(n-1);
  vector<int> buka_num(n+1); //初期化

  rep(i, n-1) cin >> boss_num.at(i);
  rep(i,n-1){
    buka_num.at(boss_num.at(i))++;
  }

 for (int i = 1; i < n + 1 ; ++i){
   cout << buka_num.at(i) << endl;
 }
  //TLE
  // rep(i, n){
  //   cout << count(all(boss_num), i+1) << endl;
  // }

}

Measured memory_bytes: 4776
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String strn = input.readLine( );
		int n = Integer.parseInt(strn);

		String strt = input.readLine( );
		String[] tlist = strt.split(" ");
		int[] t = new int[n];
		int sum = 0;
		for(int i=0; i<n; i++){
			t[i] = Integer.parseInt(tlist[i]);
			sum = sum + t[i];
		}

		String strm = input.readLine( );
		int m = Integer.parseInt(strm);
		String[][] xlist = new String[m][];
		int answer = sum;

		for(int i=0; i<m; i++){
			String str = input.readLine( );
			xlist[i] = str.split(" ");
			answer = sum + Integer.parseInt(xlist[i][1]) - t[Integer.parseInt(xlist[i][0])-1];
			System.out.println(answer);
		}


	}

}


Measured memory_bytes: 23252
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm> 
#include<vector>
using namespace std;
int m, n, a, b, temp, head, tail = 1, c[100010], q[100010];
vector<int> ac[100010];
int main()
{
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; i++)
	{
		scanf("%d%d", &a, &b);
		ac[a].push_back(b);
		ac[b].push_back(a);
	}
	q[++head] = 1;//因为从room1开始搜索，所以，源 搜索点是1，因此，1入队赋初值 
	while(head <= tail)//只要队列中有元素，从左至右逐个为源进行查找（搜索） 
	{
		for(int i = 0; i < ac[q[head]].size(); i++)//遍历与源房间连通的房间 
		{
			if(c[ac[q[head]][i]] == 0) //如果该房间没有放指示牌 
			{
				q[++tail] = ac[q[head]][i];//与源房间连通的房间入队 
				c[ac[q[head]][i]] = q[head];//与源房间连通的房间的指示牌指向源房间
			}
		}
		head++;//遍历完所有与源房间连通的房间后，出队，以下一个房间为源进行搜索 
	}
	for(int i = 2; i <= n; i++)
	{
		if(c[i] == 0)  
		{
			printf("No\n");
			return 0;
		} 
	}
	printf("Yes\n");
	for(int i = 2; i <= n; i++)
	{
		printf("%d\n", c[i]);
	}
	return 0;
}

Measured memory_bytes: 10936
n = int(input())
edge_ls = [0] * n
for i in range(n):
    x,l = map(int,input().split())
    r = x+l
    left = x-l
    edge_ls[i] = [left,r]
edge_ls.sort(key=lambda x : x[1])
ans = 1
last = edge_ls[0][1]
for i in range(1,n):
    if last <= edge_ls[i][0]:
        ans += 1
        last = edge_ls[i][1]
print(ans)
    





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

#define STACK_MAX (100 + 1)

double stack[STACK_MAX];
int head = 0;

void push(double n){
	int i;
	
	for (i = head; i > 0; i--){
		stack[i] = stack[i - 1];
	}
	head++;
	stack[0] = n;
}

double pop(void){
	double temp;
	int i;
	temp = stack[0];
	
	for (i = 0; i < head - 1; i++){
		stack[i] = stack[i + 1];
	}
	stack[i + 1] = 0;
	head--;
	return(temp);
}

double integer(char *str)
{
	double sum;
	int i;
	sum = i = 0;
	
	while (str[i] != '\0'){
		sum = sum * 10 + str[i] - '0';
		i++;
	}
	return (sum);
}

int main(void)
{
	char operate[100];
	char temp[10];
	int i, j;
	double a, b;
	
	memset(operate, '\0', sizeof(operate));
	while (scanf("%[^\n]", operate) != EOF){
		getchar();
		memset(stack, 0, sizeof(stack));
		
		i = 0;
		
		while (operate[i] != '\0'){
			j = 0;
			memset(temp, '\0', sizeof(temp));
			while (operate[i] != ' ' && operate[i] != '\0'){
				temp[j] = operate[i];
				i++;
				j++;
			}
			if (operate[i] == ' ' || operate[i] == '\0'){
				switch(temp[0] + temp[1]){
					case '+' + '\0':
					a = pop();
					b = pop();
					push(b + a);
					break;
					
					case '-' + '\0':
					a = pop();
					b = pop();
					push(b - a);
					break;
					
					case '*' + '\0':
					a = pop();
					b = pop();
					push(b * a);
					break;
					
					case '/' + '\0':
					a = pop();
					b = pop();
					push(b / a);
					break;
					
					default:
					if (temp[0] == '-'){
						push(-1 * integer(&temp[1]));
					}
					else {
						push(integer(temp));
					}
				}
				if (operate[j] == '\0'){
					break;
				}
				i++;
			}
		}
		
		printf("%f\n", pop());
		memset(operate, '\0', sizeof(operate));
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int MOD = 1000000007;
int INF = numeric_limits<int>::max();
 
 
signed main(){

  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int64_t N;
  cin >> N;
  int64_t A[N], sum[N];
  cin >> A[0];
  sum[0] = A[0];
  for(int i=1;i<N;i++){
    cin >> A[i];
    sum[i] = sum[i-1] + A[i];
  }

  int64_t ans = INF;
  for(int i=0;i<N;i++){
    ans = min(ans, abs((sum[N-1] - sum[i])- sum[i] ));
  }

  cout << ans << endl;

}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
const int maxn = 1200;
const int maxw = 24000;
struct block{
	int w, s, v;
	bool operator < (const block &b){
		return w + s > b.w + b.s;
	}
}b[maxn];
LL dp[maxn][maxw];
int main(){
	int N;
	cin >> N;
	for(int i = 1; i <= N; i += 1)
		cin >> b[i].w >> b[i].s >> b[i].v;
	sort(b + 1, b + N + 1);
	for(int i = 0; i < N; i += 1)
		for(int j = 0; j < maxw; j += 1){
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
			if(j >= b[i + 1].w) dp[i + 1][min(j - b[i + 1].w, b[i + 1].s)]
				= max(dp[i + 1][min(j - b[i + 1].w, b[i + 1].s)], dp[i][j] + b[i + 1].v);
		}
	LL ans = 0;
	for(int j = 0; j < maxw; j += 1) ans = max(ans, dp[N][j]);
	cout << ans;
}

Measured memory_bytes: 188544
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  int N,M;
  cin >> N >> M;
  if(N==M){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}

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

int gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

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

  vector<int> x(N);
  rep(i, N) cin >> x[i];
  rep(i, N) x[i] = abs(x[i] - X);

  int d = x.front();
  rep(i, N) d = min(d, gcd(d, x[i]));

  cout << d << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main()
{
 
    int N,T,c[110]={},t[110]={},f=0,ans=INT32_MAX;
    cin>>N>>T;
 
    for(int i=0;i<N;i++){
        cin>>c[i]>>t[i];
 
        if(t[i]<=T){
            ans = min(ans,c[i]);
            f=1;
        }
    }
 
 
    if(f==1){
        cout << ans <<endl;
    }else{
        cout <<"TLE"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func min(a, b int) int {
  if a < b {
    return a
  } else {
    return b
  }
}

type P struct {
  c int
  s byte
}

func main() {
  var N, K int
  var S string
  fmt.Scan(&N, &K, &S)

  var ps []P
  
  p := P{c:1, s:S[0]}
  for i := 1; i < N; i++ {
    if S[i-1] != S[i] {
      ps = append(ps, p)
      p = P{c:1, s:S[i]}
    } else {
      p.c++
    }
  }
  ps = append(ps, p)

  var max, sum int
  width := K * 2 + 1

  if ps[0].s == '0' {
    ps = append([]P{P{c:0, s:'1'}}, ps...)
  }
  if ps[len(ps)-1].s == '0' {
    ps = append(ps, P{c:0, s:'1'})
  }

  L := len(ps)
  for i := 0; i < min(width, L); i++ {
    sum += ps[i].c
  }
  max = sum
  for i := min(width, L)+1; i < L; i+=2 {
    sum = sum + ps[i].c + ps[i-1].c - ps[i-min(width, L)].c - ps[i-min(width, L)-1].c
    if max < sum {
      max = sum
    }
  }
  fmt.Println(max)
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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 int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;


int main() {

	int q;
	cin >> q;

	min_priority_queue<ll> r;
	priority_queue<ll> l;

	ll rsum = 0;
	ll lsum = 0;

	ll sum = 0;

	REP(qi, q) {
		int a;
		cin >> a;
		if (a == 1) {
			ll b, c;
			cin >> b >> c;
			sum += c;
			if (l.size() < 1 || l.top() > b) {
				l.push(b);
				lsum += b;
			}
			else {
				r.push(b);
				rsum += b;
			}
			if (l.size() < r.size()) {
				ll i = r.top();
				r.pop();
				l.push(i);
				rsum -= i;
				lsum += i;
			}
			else if (l.size() >= r.size() + 2) {
				ll i = l.top();
				l.pop();
				r.push(i);
				lsum -= i;
				rsum += i;
			}
		}
		else {
			ll a = l.top();
			ll ans = (a*(ll)l.size() - lsum) + (rsum - a * (ll)r.size()) + sum;
			cout << a << ' ' << ans << endl;
		}


	}

}



Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s, s1, s2, s3;
 
  cin >> s;
  
  s1 = s / 100;
  s2 = (s - s1 * 100) / 10;
  s3 = s - s1 * 100 - s2 * 10;
  
  cout << s1 + s2 + s3 << endl;
}

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

int main() {
	int x, y , z;
	cin >> x >> y >> z;

	int ans = 0;
	int i = z;
	while (i <= x) {
		i += y+z;
		ans++;
	}
	ans--;

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

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

int main()
{
    long ans = 0;
    std::string s;
    bool flag = false;
    int add = 0;

    std::cin >> s;
    for (int i = 0; i < s.length(); i++)
    {
        if (flag && s[s.length() - 1 - i] < '9')
        {
            s[s.length() - 1 - i]++;
        }
        else if (flag && s[s.length() - 1 - i] == '9')
        {
            continue;
        }

        ans += s[s.length() - 1 - i] < '6' ? (s[s.length() - 1 - i] - '0') : ('9' - s[s.length() - 1 - i] + 1);
        flag = s[s.length() - 1 - i] > '5' || (s[s.length() - 1 - i] == '5' && s.length() - 2 - i >= 0 && s[s.length() - 2 - i] > '4');
    }
    if (flag)
        ans++;
    //std::cout << flag << std::endl;
    std::cout << ans << std::endl;
}

Measured memory_bytes: 1412
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int read() {
	int q=0;char ch=' ';
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') q=q*10+ch-'0',ch=getchar();
	return q;
}
typedef long long LL;
const int N=100005;
int n,K,js;LL ans;
int a[N],b[N],L[N],R[N],c[N<<1],d[N<<3];LL s[N],f[N];
void GG() {puts("-1");exit(0);}
void pd(int i) {d[i<<1]=d[(i<<1)|1]=d[i],d[i]=0;}
int query(int x,int s,int t,int i) {
	if(s==t) return d[i];
	int mid=(s+t)>>1; if(d[i]) pd(i);
	if(x<=mid) return query(x,s,mid,i<<1);
	else return query(x,mid+1,t,(i<<1)|1);
}
void chan(int l,int r,int s,int t,int i,int v) {
	if(l>r) return;
	if(l<=s&&t<=r) {d[i]=v;return;}
	int mid=(s+t)>>1; if(d[i]) pd(i);
	if(l<=mid) chan(l,r,s,mid,i<<1,v);
	if(mid+1<=r) chan(l,r,mid+1,t,(i<<1)|1,v);
}
LL getf(int x) {
	int k=query(x,1,js,1);
	if(!k) return 0;
	return f[k]+(c[L[k]]%K-c[x]%K+K)%K;
}
int main()
{
	n=read(),K=read();
	for(RI i=1;i<=n;++i) {
		a[i]=read(),b[i]=read();
		s[i]=s[i-1]+a[i];
		if(b[i]==1&&a[i]+a[i]>K) {puts("-1");return 0;}
		//不同方向的列车走这条路的时间要不相交
	}
	for(RI i=n;i>=1;--i)
		if(b[i]==1) L[i]=(K-2LL*s[i-1]%K)%K,R[i]=(K-2LL*s[i]%K)%K;
		else L[i]=0,R[i]=K-1;
	for(RI i=1;i<=n;++i) c[++js]=L[i],c[++js]=R[i];
	sort(c+1,c+1+n+n);
	js=1;for(RI i=2;i<=n+n;++i) if(c[i]!=c[js]) c[++js]=c[i];
	for(RI i=n;i>=1;--i) {
		L[i]=lower_bound(c+1,c+1+js,L[i])-c;
		R[i]=lower_bound(c+1,c+1+js,R[i])-c;
		f[i]=getf(L[i]);
		if(L[i]>R[i]) chan(R[i]+1,L[i]-1,1,js,1,i);
		else chan(1,L[i]-1,1,js,1,i),chan(R[i]+1,js,1,js,1,i);
	}
	ans=1e18;
	for(RI i=1;i<=js;++i) ans=min(ans,getf(i));
	printf("%lld\n",ans+s[n]+s[n]);
	return 0;
}

Measured memory_bytes: 7296
h,w,n=map(int,input().split())
jl=[0]*10
cnt={}
if n==0:
  print((w-2)*(h-2))
  for i in range(9):
    print(0)
  exit()
for i in range(n):
  a,b=map(int,input().split())
  a-=1
  b-=1
  for j in range(max(0,b-2),min(w-2,b+1)):
    for k in range(max(0,a-2),min(h-2,a+1)):
      if (k, j) in cnt:
        cnt[(k, j)]+=1
      else:
        cnt[(k, j)]=1
jl[0]=(h-2)*(w-2)
for i in cnt.values():
  jl[0]-=1
  jl[i]+=1
for i in jl:
  print(i)

Measured memory_bytes: 151704
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        String s = sc.next();
        if (a >= 3200) {
            System.out.println(s);
        } else {
            System.out.println("red");
        }
        sc.close();
    }
}


Measured memory_bytes: 35516
#include<bits/stdc++.h>
using namespace std;
long long ar[200010];
int main()
{
	long long n,i;
	scanf("%lld",&n);
	long long xo=0;
	for(i=0;i<n;i++)
	{
		scanf("%lld",ar+i);
		xo^=ar[i];
	}
	for(i=0;i<n;i++)
		printf("%lld ",xo^ar[i]);
	printf("\n");
}

Measured memory_bytes: 5308
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
using namespace std;
int main(){
  int x,a,b;
  cin>>x>>a>>b;
  if(abs(x-a)<abs(x-b)){
    cout<<'A'<<endl;
  }else{
    cout<<'B'<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
use std::io::stdin;
use std::time::SystemTime;

#[allow(dead_code)]
fn read_line() -> String {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn read<T>() -> T
where T: std::str::FromStr
{
    read_line().parse::<T>().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T>() -> Vec<T>
where T: std::str::FromStr
{
    read_line().split(" ").map(|n| n.parse::<T>().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn read_chars() -> Vec<char>
{
    read_line().chars().collect()
}

#[allow(dead_code)]
fn print_time() -> () {
    println!("{:?}", SystemTime::now());
}

#[allow(unused_variables)]
fn main() {
    let s = read_chars();
    let k: u64 = read();
    
    let mut f = true;
    let mut c = 0;
    let mut t = '1';
    for v in s {
        if v != '1' {
            t = v;
            f = false;
            break;
        } else {
            c = c + 1;
        }
    }
    if f || c >= k {
        println!("1");
    } else {
        println!("{}", t);
    }
}



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

int main() {
int A,B;
  cin >> A >> B ;  
int C=A+B;
  if (A%3==0||B%3==0||C%3==0){
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }
}


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

using namespace std;

#define Rep(b, e, i) for (int i = b; i <= e; i++)
#define Repr(e, b, i) for (int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n - 1, i)
#define repr(n, i) Repr(n - 1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T, vector<T>, greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false) std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<vec> mat;
typedef vector<vecll> matll;
typedef vector<vecd> matd;

template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
	o << "{";
	for (int i = 0; i < (int)v.size(); i++)
		o << (i > 0 ? ", " : "") << v[i];
	o << "}";
	return o;
}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1 << 29;
const ll INFL = 1e18;
const ll MOD = 1000000007;

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

//********************************template END****************************************//

void solve()
{
	int N;
	cin >> N;
	int ans = 0;
	rep(N, i)
	{
		int d;
		cin >> d;
		if (d & 1) ans = 1;
	}
	cout << (ans ? "first" : "second") << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
  n, m = map(int, input().split(" "))
  H = tuple(map(int, input().split(" ")))

  edges = [[]] * n

  for _ in range(m):
    a, b = map(int, input().split(" "))
    a -= 1
    b -= 1
    if len(edges[a]) == 0:
      edges[a] = [b]
    else:
      edges[a].append(b)

    if len(edges[b]) == 0:
      edges[b] = [a]
    else:
      edges[b].append(a)

  arr = sorted(enumerate(H), key=lambda tpl: -tpl[1])

  ans = [False] * n
  done_set = set()
  for i, h in arr:
    if i in done_set:
      continue

    ans[i] = True
    done = {i}
    for j in edges[i]:
      done.add(j)
      if H[j] >= h:
        ans[i] = False

    done_set |= done

  print(len(tuple(filter(lambda x: x, ans))))




main()


Measured memory_bytes: 47240
/*input 
10 10
158260522 877914575 602436426 24979445 861648772 623690081 433933447 476190629 262703497 211047202
*/ 
#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;
typedef long long int ll;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
#define ld double
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=2e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e16;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
int n,k;
ld arr[maxn];
bool wk(ld x){
    ll stps=0;
    REP(i,n) stps+=floor(arr[i]/x);
    return (stps<=k);
}
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    cin>>n>>k;
    REP(i,n) cin>>arr[i];
    ld l=0,r=INF;
    REP1(i,50){
        ld mid=(l+r)/2;
        if(wk(mid)) r=mid;
        else l=mid;
    }
    cout<<(int)ceil(l);
}


Measured memory_bytes: 5268
s = [i for i in input()]
odd = ["R","U","D"]
even = ["L","U","D"]
for i in range(len(s)):
    if ((i+1) % 2 == 1 and s[i] in odd) or ((i+1) % 2 == 0 and s[i] in even):
        continue
    else:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
int cnt[N],a[N];
int main(){
        memset(cnt,0,sizeof(cnt));
        int n; cin>>n; long long sum=0;
        for(int i=0;i<n;i++) { cin>>a[i]; cnt[a[i]]++; sum+=(long long)a[i]; }
        int q; cin>>q; long long b,c;
        while(q--){
                cin>>b>>c;
                sum=(sum+(c-b)*cnt[b]);
                cnt[c]+=cnt[b];
                cnt[b]=0;
                cout<<sum<<endl;
        }
}



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

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

            string checkFirst = "MARCH";
            long[] count = new long[5];
            long pair = 0;

            for (int i = 0; i < n; i++)
            {
                string check = null;
                check = Console.ReadLine();

                if (checkFirst.IndexOf(check[0]) != -1)
                {
                    count[checkFirst.IndexOf(check[0])]++;
                }
            }

            for (int j = 0; j < 5; j++)
            {
                for (int k = j + 1; k < 5; k++)
                {
                    for (int l = k + 1; l < 5; l++)
                    {
                        pair += count[j] * count[k] * count[l];
                    }
                }
            }
            Console.WriteLine(pair);
            Console.Read();
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define int long long int
using namespace std;

int knapsack(vector<int>& v, vector<int>& w, int n, int targetw){
    vector<vector<int>> dp(n+1, vector<int>(targetw+1, 0));
    for(int i=1; i<=n; i++){
        for(int j=1; j<=targetw; j++){
            if(w[i-1] > j){
                dp[i][j] = dp[i-1][j];
            } else {
                dp[i][j] = max(dp[i-1][j], v[i-1]+dp[i-1][j-w[i-1]]);
            }
        }
    }
    return dp[n][targetw];
}

int32_t main(){
    int n, targetw;
    cin >> n >> targetw;
    vector<int> w(n);
    vector<int> v(n);
    for(int i=0; i<n; i++){
        cin >> w[i] >> v[i];
    }
    cout << knapsack(v, w, n, targetw) << "\n";
}

Measured memory_bytes: 80256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <string>
using namespace std ;

int main(){
    map<string,int> check ;
    vector<int> cnt ;
    int n ; cin >> n ;
    for(int i=0;i<n;i++){
        string s ; cin >> s ;
        if(check.count(s)) cnt.at(check.at(s))++ ;
        else{
            cnt.push_back(1) ;
            check[s] = cnt.size()-1 ;
        }
    }
    int m ; cin >> m ;
    for(int i=0;i<m;i++){
        string t ; cin >> t ;
        if(check.count(t)) cnt.at(check.at(t))-- ;
    }
    sort(cnt.begin(),cnt.end()) ;
    reverse(cnt.begin(),cnt.end()) ;
    cout << max(0,cnt.at(0)) << endl ;
}


Measured memory_bytes: 256