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

#define ll long long
#define ld long double
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define ppb pop_back
#define vll vector<ll>
#define vi vector<int>
#define endl "\n"

const ll INF = 1000000007;

/*
const int max_size = 100001;
int parent[max_size];
int Size[max_size];

int root(int x){
	while(x!=parent[x]){
		parent[x] = parent[parent[x]];
		x = parent[x];
	}
	return x;
}

void sunion(int x,int y){
	int rx = root(x);
	int ry = root(y);
	if(rx != ry){
		if(Size[rx] > Size[ry]){
			parent[ry] = parent[rx];
			Size[rx] += Size[ry];
		}
		else{
			parent[rx] = parent[ry];
			Size[ry] += Size[rx];
		}
	}
}
*/

const int maxn = 1e5+5;
vi edge[maxn];
bool vis[maxn];
int dist[maxn];
int in_deg[maxn];

void dfs(int u){
	vis[u] = 1;
	for(auto v : edge[u]){
		dist[v] = max(dist[v],dist[u]+1);
		in_deg[v]--;
		if(in_deg[v]==0){
			dfs(v);
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin >> t;
	while(t--){
		int n,m;
		cin >> n >> m;
		while(m--){
			int u,v;
			cin >> u >> v;
			edge[u].pb(v);
			in_deg[v]++;
		}
		for(int i=1;i<=n;i++){
			if(!vis[i] && in_deg[i]==0) dfs(i);
		}
		int ans=0;
		for(int i=1;i<=n;i++) ans = max(ans,dist[i]);
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 9728
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<long long, long long>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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;
using ll = long long;
const ll mod = 1e9 + 7;

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

  int n; cin >> n;
  int p; cin >> p;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
    a[i] %= 2;
  }

  ll dp[n][2];
  rep(i, n) {
    dp[i][0] = dp[i][1] = 0;
  }

  dp[0][0] = 1;
  dp[0][a[0]]++;

  for(int i=1; i<n; i++) {
    if (a[i] == 0) {
      dp[i][0] = dp[i-1][0]*2;
      dp[i][1] = dp[i-1][1]*2;
    } else {
      dp[i][0] = dp[i-1][0] + dp[i-1][1];
      dp[i][1] = dp[i-1][0] + dp[i-1][1];
    }
  }

  cout << dp[n-1][p] << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.List;

public class Main {

  static int n;
  static long[] ans;
  static List<Long> x, y, p;

  public static void main(String[] args) throws Exception {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);

    String[] in = br.readLine().split(" ");

    br.close();

    out.println(in[0].charAt(0) - 'a' >= 0 ? "a" : "A");

    out.flush();
  }
}


Measured memory_bytes: 32692
# include <iostream>
# include <cstdio>
using namespace std;
const int N = 3e5 + 12;
int sum[N],n;
char str[N];
int main()
{
   scanf("%d",&n);scanf("%s",str + 1);
   for(int i = 1;i <= n;i++)sum[i] = str[i] == 'E',sum[i] += sum[i - 1];
   int mx = N;
   for(int i = 1;i <= n;i++)
   mx = min(mx,i - 1 - sum[i - 1] + sum[n] - sum[i]);
   printf("%d\n",mx);
}

Measured memory_bytes: 1664
#include <cstdio>

int main() {
  int r, c;
  scanf("%d %d", &c, &r);
  int table[c + 1][r + 1];
  for (int i = 0; i < c + 1; i++)
  {
    for (int j = 0; j < r + 1; j++)
    {
      table[i][j] = 0;
    }
  }
  for (int i = 0; i < c; i++)
  {
    for (int j = 0; j < r; j++)
    {
      scanf("%d", &table[i][j]);
      table[i][r] += table[i][j];
      table[c][j] += table[i][j];
    }
    table[c][r] += table[i][r];
  }
  for (int i = 0; i < c + 1; i++)
  {
    for (int j = 0; j < r + 1; j++)
    {
      printf("%d", table[i][j]);
      if (j != r)
        printf(" ");
    }
    printf("\n");
  }
}


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

int sumOfDigit (int i) {
  return i / 10000 + i / 1000 % 10 + i / 100 % 10 + i % 100 / 10 + i % 10;
}

int main () {
  int N;
  cin >> N;
  int min = 1 << 30;
  for (int i=1; i <= (N / 2) + 1; ++i) {
    int a = i;
    int b = N - i;
    int sum_a = sumOfDigit(a);
    int sum_b = sumOfDigit(b);
    if (sum_a + sum_b < min) {
      min = sum_a + sum_b;
    }
  }
  cout << min << endl;
  return 0;
}

Measured memory_bytes: 256
PROGRAM Frog1
      IMPLICIT NONE
      integer(16) :: n
      integer(16),allocatable :: h(:),dp(:)
      integer(16) :: i,jump1,jump2
      
      read*, n
      allocate( h(1:n) )
      read*, h(:)
      
      allocate( dp(1:n) )
      dp(:) = 10**5
      dp(1) = 0
      dp(2) = abs( h(2)-h(1) )
      
      do i = 3,n
        jump1 = dp(i-1) + abs( h(i)-h(i-1) )
        jump2 = dp(i-2) + abs( h(i)-h(i-2) )
        dp(i) = min( jump1,jump2 )
      end do
      
      print*,dp(n)
      
      
      
      
      END PROGRAM

Measured memory_bytes: 3840
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    T = NLI()
    A = NLI()
    B = NLI()
    gap = [a-b for a, b in zip(A, B)]

    if T[0]*gap[0] + T[1]*gap[1] == 0:
        print("infinity")
        exit()

    if gap[0]*gap[1] > 0 or abs(T[0]*gap[0]) > abs(T[1]*gap[1]):
        print(0)
        exit()

    x = abs(gap[0]*T[0])
    y = abs(T[0]*gap[0] + T[1]*gap[1])
    if x % y == 0:
        print(x // y * 2)
        exit()
    else:
        print(x // y * 2 + 1)



if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define ll          long long int
#define ld          double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         1000000000000000000
#define MAXN        200005
#define LOG         20
#define mod         1000000007
using namespace std;
 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char ch;
    cin>>ch;
    cout<<char(ch+1);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,re,sum;
    cin>>n;
    re=n;
    sum=0;
    while(re>0)
    {
        sum+=re%10;
        re/=10;
    }
    if(n%sum==0)
    {
        printf("Yes\n");
        //printf("S")
    }
    else printf("No\n");
    return  0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n],b,c;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a,a+n);
  b = a[0];
  for (int i = 1; i < n-1; i++) {
    if (abs(a[i]-a[n-1]/2) < abs(a[n-1]/2-b)) {
      b = a[i];
    }
  }
  c = a[0];
  for (int i = 1; i < n-1; i++) {
    if (abs(a[i]-(a[n-1]-1)/2-1) < abs((a[n-1]-1)/2+1-c)) {
      c = a[i];
    }
  }
  cout << a[n-1] << ' ';
  if (abs(b-a[n-1]/2) < abs((a[n-1]-1)/2+1-c)) {
    cout << b;
  } else {
    cout << c;
  }
}

Measured memory_bytes: 3952
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+9
#define MOD 1000000007
using namespace std;


int main(){
    int A,B;
    cin >> A >> B;
    
    if(A>B){
        cout<<2*A-1<<endl;
    }else if(B>A){
        cout<<2*B-1<<endl;
    }else{
        cout<<A+B<<endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

ll gcd(ll a, ll b) {
    if(a < b){
        return gcd(b, a);
    }
    ll r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

void factorize(ll n, unordered_map<ll, ll>& out){
    out.clear();
    while(n % 2 == 0){
        out[2]++;
        n /= 2;
    }
    for(ll p = 3; p * p <= n; p += 2){
        while(n % p == 0){
            out[p]++;
            n /= p;
        }
    }
    if(n > 2){
        out[n]++;
    }
}


int main(){
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    unordered_map<ll, ll> map;
    factorize(g, map);
    cout << map.size() + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
string a[100],b[100];
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    
	int N,M;
    string result="No";
	cin >> N >> M;
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    for(int i=0;i<M;i++){
        cin >> b[i];
    }
    for(int ii=0;ii<=N-M;ii++){
        for(int ij=0;ij<=N-M;ij++){
            bool judge=true;
            for(int ji=0;ji<M;ji++){
                for(int jj=0;jj<M;jj++){
                    if(a[ii+ji][ij+jj]!=b[ji][jj]) judge=false;
                }
            }
            if(judge) result="Yes";
        }
    }
    cout << result << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma O3
#define int long long
using namespace std;
const int mod=998244353;
int n,a,b,k,ca,cb,ans;
int gt[3000005],rgt[3000005];
int binpow(int x,int mu){
	if(mu==1) return x%mod;
	else{
		int tmp=binpow(x,mu/2);
		if(mu%2==1) return ((tmp*tmp%mod)*x)%mod;
		else return tmp*tmp%mod;
	}
}
signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n>>a>>b>>k;
	gt[0]=1;
	for(int i=1;i<3000004;i++){
		gt[i]=(gt[i-1]%mod*(n-i+1)%mod)*(binpow(i,mod-2)%mod)%mod;
	}
	for(int ca=0;ca<=n;ca++){
		cb=(k-ca*a)/b;
		if(cb*b+ca*a!=k||cb<0) continue;
		ans=(gt[ca]*gt[cb]%mod+ans)%mod;
	}
	cout<<ans;
}

Measured memory_bytes: 24576
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<ll> h(n);
  rep(i, n) cin >> h.at(i);
  int ans = 0;
  int count = 0;
  rep(i, n){
    if(i == n-1){
      ans = max(ans, count);
      break;
    }
    else if(h.at(i) >= h.at(i+1)){
      count++;
    }
    else{
      ans = max(ans, count);
      count = 0;
    }
  }
  cout << ans << endl;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {

            int nn = int.Parse(Console.ReadLine());
            int[] aa = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            Array.Sort(aa);
            Array.Reverse(aa);

            int alice = 0;
            int bob = 0;
            
            for(int i =1; 2*i-1 <= nn; i++)
            {
                alice += aa[2 * i - 2];
            }

            bob = aa.Sum() - alice;

            Console.WriteLine(alice - bob);
        }
    }
 }


Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>

using namespace std;

typedef long long ll;

int main() {
    int n;
    while (cin >> n, n) {
        vector<int> ids;
        map<int, ll> sales;
        int i;
        ll p, q;
        for (int k=0; k<n; ++k) {
            cin >> i >> p >> q;
            if ( ! sales.count(i)) ids.push_back(i);
            sales[i] += p * q;
        }
        bool na = true;
        for (int k=0; k<(int)ids.size(); ++k) {
            if (1000000 <= sales[ids[k]]) {
                cout << ids[k] << endl;
                na = false;
            }
        }
        if (na) cout << "NA" << endl;
    }
}

Measured memory_bytes: 1288
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define BOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

int main(){
    
    int H,W;
    cin>>H>>W;
    vector<string> Red(H),Blue(H);
    REP(i,H){
        Red[i]=string(W,'#');
        Blue[i]=string(W,'#');
    }
    
    REP(i,H)REP(j,W){
        if(j==0){
            Blue[i][j]='.';
        }else if(j==W-1){
            Red[i][j]='.';
        }
        if(i%2==0){
           if(j!=0)Red[i][j]='.';
        }else{
           if(j!=W-1)Blue[i][j]='.';
        }
    }
    
    vector<string> ori(H);
    REP(i,H)cin>>ori[i];
    
    REP(i,H)REP(j,W){
        if(ori[i][j]=='#'){
            Red[i][j]='#';
            Blue[i][j]='#';
        }
    }
    
    REP(i,H){
        REP(j,W)cout<<Red[i][j];
        cout<<endl;
    }
    cout<<endl;
    
    REP(i,H){
        REP(j,W)cout<<Blue[i][j];
        cout<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    int half_a,half_b,half_c,count=0;
    while(true){
        if(a==1&&b==1&&c==1){
            count = 0;
            break;
        }
        if(a==b&&b==c){
            count = -1;
            break;
        }
        if(a%2==0&&b%2==0&&c%2==0){
            half_a = a/2;
            half_b = b/2;
            half_c = c/2;
            a = half_b+half_c;
            b = half_a+half_c;
            c = half_a+half_b;
            count++;
        }else{
            break;
        }
    }
    cout << count << endl;
    return 0;
}

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

#pragma region union_find
class UnionFind {
private:
    vector<int> par;
    vector<int> rank;

public:
    UnionFind(int N) {
        par.resize(N);
        rank.resize(N, 0);
        for (int i = 0; i < N; ++i) {
            par.at(i) = i;
        }
    };
    int find(int x) {
        if (par.at(x) == x) {
            return x;
        } else {
            return par.at(x) = find(par.at(x));
        }
    };
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (rank.at(x) < rank.at(y)) {
            par.at(x) = y;
        } else {
            par.at(y) = x;
            if (rank.at(x) == rank.at(y)) ++rank.at(x);
        }
    };
    bool same(int x, int y) {
        return find(x) == find(y);
    };
};
#pragma endregion

#pragma region kruskal
struct edge {
    int from;
    int to;
    int cost;
};

bool comp(const edge &e1, const edge &e2) {
    return e1.cost < e2.cost;
}

int kruskal(vector<edge> &es, int V) {
    sort(es.begin(), es.end(), comp);
    UnionFind tree(V);
    int ret = 0;
    for (auto &e : es) {
        if (!tree.same(e.from, e.to)) {
            tree.unite(e.from, e.to);
            ret += e.cost;
        }
    }
    return ret;
}
#pragma endregion

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

    int N;
    cin >> N;
    vector<pair<int, int> > x(N), y(N);
    for (int i = 0; i < N; ++i) {
        int a, b;
        cin >> a >> b;
        x.at(i) = make_pair(a, i);
        y.at(i) = make_pair(b, i);
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    vector<edge> es;
    for (int i = 1; i < N; ++i) {
        auto p1 = x.at(i - 1);
        auto p2 = x.at(i);
        int x1 = p1.second;
        int x2 = p2.second;
        int dx = abs(p1.first - p2.first);
        es.push_back(edge{x1, x2, dx});
        es.push_back(edge{x2, x1, dx});
        auto q1 = y.at(i - 1);
        auto q2 = y.at(i);
        int y1 = q1.second;
        int y2 = q2.second;
        int dy = abs(q1.first - q2.first);
        es.push_back(edge{y1, y2, dy});
        es.push_back(edge{y2, y1, dy});
    }
    cout << kruskal(es, N) << endl;

    return 0;
}

Measured memory_bytes: 10096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int Maxn=1005;
int rx[Maxn],ry[Maxn],rc[Maxn];
int bx[Maxn],by[Maxn],bc[Maxn];
int dx[]={1,1,-1,-1},dy[]={1,-1,1,-1};
namespace mcmf{
    const int MAXN=2*Maxn,MAXM=10*Maxn;
    struct node{int to,next,v,k,pair;}e[MAXM*2];
    int h[MAXN],cur[MAXN],Instack[MAXN],cnt,S,T;
    ll dis[MAXN];
    void AddEdge(int x,int y,int v,int k,int pair){
        e[cnt]=(node){y,h[x],v,k,pair};h[x]=cnt;
    }
    void AddEdge(int x,int y,int v,int k){
        AddEdge(x,y,v,+k,++cnt+1);
        AddEdge(y,x,0,-k,++cnt-1);
    }
    bool SPFA(){
        static int vis[MAXN];
        memset(vis,0,sizeof(vis));
        memset(dis,0x3f,sizeof(dis));
        queue<int>Q;Q.push(S);
        dis[S]=0;vis[S]=true;
        while(Q.size()){
            int x=Q.front();Q.pop();
            vis[x]=false;
            for(int p=h[x];p;p=e[p].next){
                int y=e[p].to;
                if(e[p].v&&dis[y]>dis[x]+e[p].k){
                    dis[y]=dis[x]+e[p].k;
                    if(!vis[y]){
                        vis[y]=true;
                        Q.push(y);
                    }
                }
            }
        }
        return dis[T]!=0x3f3f3f3f3f3f3f3f;
    }
    int dfs(int x,int Maxflow){
        int flow=0;
        if(x==T||!Maxflow)return Maxflow;
        Instack[x]=true;
        for(int&p=cur[x];p;p=e[p].next){
            int y=e[p].to,ret;
            if(dis[y]!=dis[x]+e[p].k||Instack[y])continue;
            ret=dfs(y,min(Maxflow,e[p].v));
            e[p].v-=ret;e[e[p].pair].v+=ret;
            Maxflow-=ret;flow+=ret;
            if(!Maxflow)break;
        }
        Instack[x]=false;
        return flow;
    }
    pair<int,ll>mcmf(int s,int t){
        S=s,T=t;
        pair<int,ll>ret;
        while(SPFA()){
            memcpy(cur,h,sizeof(h));
            int flow=dfs(S,INT_MAX);
            ret.first+=flow;
            ret.second+=flow*dis[T];
        }
        return ret;
    }
}
int main(){
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d%d%d",&rx[i],&ry[i],&rc[i]);
    for(int i=1;i<=n;i++)scanf("%d%d%d",&bx[i],&by[i],&bc[i]);
    int S=0,T=2*n+1;
    for(int i=1;i<=n;i++){
        mcmf::AddEdge(S,i,rc[i],0);
        mcmf::AddEdge(i+n,T,bc[i],0);
        for(int d=0;d<4;d++){
            mcmf::AddEdge(i,T+d+1,INT_MAX,+dx[d]*rx[i]+dy[d]*ry[i]);
            mcmf::AddEdge(T+d+1,i+n,INT_MAX,-dx[d]*bx[i]-dy[d]*by[i]);
        }
    }
    cout<<-mcmf::mcmf(S,T).second<<"\n";
    return 0;
}

Measured memory_bytes: 768
from collections import Counter

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


X=list(map(int,input().split()))
Xremainder=[x % M for x in X]

Xcount=Counter(X)
Xremaindercount=Counter(Xremainder)


#print(Xcount)
#print(Xremaindercount)
#余りが0のものは２個ずつとって1組に
answer=Xremaindercount[0]//2
Xremaindercount[0]-=(Xremaindercount[0]//2)*2
#print(answer)

if M%2==0:
  #Mが偶数のとき、余りがM//2のものは余り0のものと同様に扱える
  limit=int(M//2)
  answer+=Xremaindercount[M//2]//2
  Xremaindercount[M//2]-=(Xremaindercount[M//2]//2)*2
else:
  limit=int(M//2+1)

for i in range(1,limit):
  #余りがiとM-iのものを組み合わせるとMの倍数の組ができる
  s=Xremaindercount[i]
  t=Xremaindercount[M-i]
  answer+=min(s,t)
  Xremaindercount[i]-=min(s,t)
  Xremaindercount[M-i]-=min(s,t)

#print(Xremaindercount)
#print(answer)


for i in Xcount:
  #余りで組み合わせた後,同じ数同士のものが残り得るかを判定し、残っていたら組み合わせる
  if Xremaindercount[i%M]>=2 and Xcount[i]>=2:
    answer+=min(Xremaindercount[i%M],Xcount[i])//2
    Xremaindercount[i%M]-=(min(Xremaindercount[i%M],Xcount[i])//2)*2

print(answer)

Measured memory_bytes: 28124
#include<stdio.h>
int is(int x){
	while(x!=0){
		if(x%10==7) return 1;
		x/=10;
	}
	return 0;
}
int main(){
	int n;
	scanf("%d",&n);
	if(is(n)) printf("Yes");
	else printf("No");
	return 0;
}

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

int main() {
  string s; cin >> s;
  deque<char> dq;
  rep(i,s.size()) dq.push_back(s[i]);
  int q; cin >> q;
  int rev;
  rep(i,q) {
    int qi; cin >> qi;
    if (qi == 1) rev++;
    else {
      int f; cin >> f;
      char c; cin >> c;
      if (f == 1) {
        if (rev%2 == 0) dq.push_front(c); 
        else dq.push_back(c);
      }
      else { 
        if (rev%2 == 0) dq.push_back(c); 
        else dq.push_front(c);
      }
    }
  }
  while(!dq.empty()) {
    if (rev%2 == 0) {
      cout << dq.front();
      dq.pop_front();
    } else {
      cout << dq.back();
      dq.pop_back();
    }
  }
  cout << endl;
  return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, a, b, v[50];

LL comb(LL x, LL y) {
	if(x < y) { return 0; }
	LL z = 1;
	inc(i, y) {
		z *= x - i;
		z /= i + 1;
	}
	return z;
}

int main() {
	cin >> n >> a >> b;
	inc(i, n) { cin >> v[i]; }
	
	sort(v, v + n, greater<LL>());
	
	LL sum = 0;
	inc(i, a) { sum += v[i]; }
	printf("%.8f\n", 1.0 * sum / a);
	
	LL c = count(v, v + n, v[a - 1]);
	LL f =  find(v, v + n, v[a - 1]) - v;
	
	LL ans = 0;
	if(f == 0) {
		incII(i, a, b) { ans += comb(c, i); }
	} else {
		ans = comb(c, a - f);
	}
	
	cout << ans << endl;
	
	return 0;
}


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

using namespace std;

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

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back
#define pb push_back

vector< vector<int> > v;

int main(void){
  int n, d;
  int ans = 0;

  cin >> n >> d;
  v.resize(n);
  rep(i, n){
    v[i].resize(d);
    rep(j, d) cin >> v[i][j];
  }

  rep(i, n){
    for(int j = i+1; j < n; ++j){
      int sum = 0;
      rep(k, d){
        sum += (v[i][k] - v[j][k]) * (v[i][k] - v[j][k]) ;
      }
      int x = sqrt(sum);
      if(x * x == sum) ans++;
    }
  }
  
  cout << ans << endl;
  return 0;
}


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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, x, y;
  cin >> n >> x >> y;
  map<int, int> count;
  for(int i = 1; i < n; i++){
    count[i] = 0;
  }
  for(int i = 1; i < n; i++){
    for(int j = i+1; j <= n; j++){
      count[min(abs(j-i),abs(x-i)+1+abs(y-j))]++;
    }
  }
  for(map<int,int>::iterator it = count.begin(); it != count.end(); it++){
    cout << it->second << '\n';
  }
  return 0;
}

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

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;
}
struct Unionfind {
    vector<int> par;
    vector<int> sizes;

    Unionfind(int n) : par(n), sizes(n, 1) {
        for(int i = 0; i < n; ++i) par[i] = i;
    }

    int root(int x) {
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        if(sizes[x] < sizes[y]) swap(x, y);
        par[ry] = rx;
        sizes[rx] += sizes[ry];
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) {
        return sizes[root(x)];
    }

};

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

    int n;
    cin >> n;
    vector<int> b(n);
    rep(i, n) {
        ll a;
        cin >> a;
        b[i] = a - (i+1);
    }

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

    int c = b[n/2];

    ll ans = 0;

    rep(i, n) {
        ans += abs(ll(b[i]) - c);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3948
fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

fn main() {
    let nzw = readn::<usize>(" ");
    let n = nzw[0];
    let _z = nzw[1];
    let w = nzw[2];

    let a = readn::<isize>(" ");
    let mut dp = vec![vec![0; n]; 2];
    dp[0][n-1] = (a[n-1] - w as isize).abs();
    if n > 1 {
        dp[1][n-1] = (a[n-2] - a[n-1]).abs();
    }
    for i in (0..n-1).rev() {
        if i > 0 {
            dp[1][i] = std::cmp::min((a[i-1]-a[n-1]).abs(), dp[0][i+1]);
        }
        dp[0][i] = std::cmp::max(dp[0][i+1], dp[1][i+1]);
    }
    //dp[0][0] = std::cmp::max(dp[0][1], dp[1][1]);
    println!("{}", dp[0][0]);
    //dp[0][n-1] = (a[n-2] - a[n-1]).abs();
    //dp[0][n-2] = (a[n-3] - a[n-1]).abs(), (a[n-2]-a[n-1]).abs()
}

Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main () {
  int N;
  cin >> N;
  int he[110];
  int max = 0;
  for (int i = 0; i < N; i ++) {
    cin >> he[i];
    if (max < he[i]) max = he[i];
  }
  he[N] = 0;
  int ans = 0;
  for (int i = 0; i < max; i ++) {
    int s = 0;
    for (int j = 0; j < N; j ++) {
      if (he[j] > 0 && he[j + 1] <= 0) {
        s ++;
        he[j] --;
      }
     if (he[j] > 0 && he[j + 1] > 0) he[j] --;
    }
    ans += s;
  }
  cout << ans << endl;
}
  
      

Measured memory_bytes: 256
import copy
from collections import deque
n, m, r = map(int,input().split())
R = list(map(int, input().split()))

f_inf = float('inf')
wf = [[f_inf for _ in range(n+1)] for __ in range(n+1)]

tree = [[] for _ in range(n+1)]
for i in range(m):
    a, b, c = map(int, input().split())
    wf[a][b] = c
    wf[b][a] = c
for i in range(1, n+1):
    wf[i][i] = 0
for k in range(1, n+1):
    for i in range(1, n+1):
        for j in range(1, n+1):
            wf[i][j] = min(wf[i][j], wf[i][k]+wf[k][j])

all_type = []
def get_all_type(r, info, lon):
    if lon == len(info):
        return [info]
    result = []
    for i in r:
        if i in info:
            continue
        else:
            next_info = copy.deepcopy(info)
            next_info.append(i)
            result.extend(get_all_type(r, next_info, lon))
    return result

Result = []
for i in get_all_type(R, [], r):
    j = deque(i)
    x = j.popleft()
    result = 0
    while j:
        y = j.popleft()
        result += wf[x][y]
        x = y
    Result.append(result)
print(min(Result))

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

long long I, O, T, J, L, S, Z;
long long K = 0;

int main(){
	cin >> I >> O >> T >> J >> L >> S >> Z;
	K += O;

	long long tmp1 = 0;
	long long tmp2 = 0;

	tmp1 += 2*(I/2);
	tmp1 += 2*(J/2);
	tmp1 += 2*(L/2);

	if(I>0 && J > 0 && L > 0){
		tmp2 = 3;
		I--;J--;L--;
		tmp2 += 2*(I/2);
		tmp2 += 2*(J/2);
		tmp2 += 2*(L/2);
	}
	cout << K  + max(tmp1, tmp2)<< endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] array = new int[n];

		for(int i=0;i<n;i++) {
			array[i] = sc.nextInt();
		}

		int buff = 0;
		int count=0;

		for(int i=0;i<n;i++) {
			if(array[i] == buff+1) {
				buff = array[i];
			}else {
				count++;
			}
		}
		
		if(buff == 0) {
			System.out.println(-1);
		}else {
			System.out.println(count);
		}
		
	}
}




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

int main() {
  int N, a, b, c, d;
  cin >> N;
  a = N / 1000;
  b = ( N - a * 1000 ) / 100;
  c = ( N - a * 1000 - b * 100 ) / 10;
  d = N - a * 1000 - b * 100 - c *10;
  if ( (a == b && b == c) || ( b == c && c == d )) {
    cout << " Yes " << endl;
  }
  else {
    cout << " No " << endl;
  }
}
  


Measured memory_bytes: 3584
L,R = (int(i) for i in input().split())

tmp = float("inf")
count_i = 0
count_j = 0

for i in range(L,R+1):
    if count_i > 2019:break
    
    count_j = 0
    for j in range(i+1,R+1):
        if count_j >2019:break
        mod = i*j%2019
        if mod<tmp:
            tmp = mod
            
        count_j += 1
    count_i += 1
print(tmp)

Measured memory_bytes: 40300
#include <bits/stdc++.h>
using namespace std;
int main() {
  //ifstream cin("in.txt");
  ios::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  vector<list<int>> L(n);
  while (q--) {
    int op;
    cin >> op;
    if (op == 0) {
      int t, x;
      cin >> t >> x;
      L[t].push_back(x);
    } else if (op == 1) {
      int t;
      cin >> t;
      bool first = true;
      for (auto p : L[t]) {
        if (first) {
          first = false;
        } else {
          cout << " ";
        }
        cout << p;
      }
      cout << endl;
    } else if (op == 2) {
      int s, t;
      cin >> s >> t;
      L[t].splice(L[t].end(), L[s]);
    }
  }

  return 0;
}


Measured memory_bytes: 18780
import java.lang.*;
import java.util.*;
import java.io.*;

class Main{
    public String startsWithYaki(String s){
	String retStr = "No";
	if((s.length()>3)&&(s.substring(0,4).equals("YAKI"))){
	    retStr = "Yes";
	}
	return retStr;
    }
    
    public static void main(String[] args){
       try{
          BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
          BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
	  String s = br.readLine();
	  Main yn = new Main();
	  String outStr = yn.startsWithYaki(s);
	  bw.write(outStr);
	  bw.newLine();
	  bw.flush();
       }catch(Exception e){
          e.printStackTrace();
       }
}

}


Measured memory_bytes: 22356
#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 = 1 << 30;
const ll MOD = 1000000007;

int main() {
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    int sum = a1 + a2 + a3;
    if (sum < 22) {
        cout << "win" << endl;
    } else {
        cout << "bust" << endl;
    }

    return 0;
}

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

using namespace std;

int N, K;
long long int S;

long long int P = 1000000000;
int main(void) {

	cin >> N >> K >> S;

	if (S == P) {
		int cnt = 0;
		for (int i = 1; i <= K; i++) {
			if (cnt != 0) { cout << " ";  }
			cout << P; cnt++;
		}
		for (int i = K + 1; i <= N; i++) {
			if (cnt != 0) { cout << " "; }
			cout << 1; cnt++;
		}
		cout << endl; return 0;
	}

	int cnt = 0;
	for (int i = 1; i <= K; i++) {
		if (cnt != 0) { cout << " "; }
		cout << S; cnt++;
	}
	for (int i = K + 1; i <= N; i++) {
		if (cnt != 0) { cout << " "; }
		cout << S+1; cnt++;
	}
	cout << endl; return 0;

	


	return 0;
}

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

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

  int cnt=0;
  int ts, flg;
  rep(i, 1000){
    flg=0;
    rep(j, n){
      ts = s[j]-'0';
      if((flg==0 && ts == i/100 %10) ||
         (flg==1 && ts == i/10  %10) ||
         (flg==2 && ts == i/1   %10)) {
        flg++;
        if(flg==3) break;
        else continue;
      }
    }
    
    if(flg==3){
      cnt++;
    }
  }
  cout << cnt << endl;  
  return 0;
}


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


void cc_env() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	//
#endif
}

void dfs(int st, vector<int> &visited, vector<int> &inDegree, vector<int> &distance, vector<vector<int> > &graph) {
	if (visited[st] == 0) {
		// cout << st << " " << endl;
		visited[st] = 1;
		for (auto e : graph[st]) {
			distance[e] = max(distance[e], distance[st] + 1);
			--inDegree[e];
			if (inDegree[e] == 0)
				dfs(e, visited, inDegree, distance, graph);
		}
	}

	// for (auto e : distance)
	// 	cout << e << " ";
	// cout << endl;
}


int main() {
	// cc_env();
	// input part
	int N, M, n1, n2;
	cin >> N >> M;

	vector<vector<int> > graph(N + 1);
	vector<int> inDegree(N + 1, 0), visited(N + 1, 0), distance(N + 1, 0);

	for (int i = 0; i < M; i++) {
		cin >> n1 >> n2;
		graph[n1].push_back(n2);
		++inDegree[n2];
	}

	// for (auto e : inDegree)
	// 	cout << e << " ";
	// cout << endl;

	for (int i = 1; i <= N; i++) {
		if (visited[i] == 0 && inDegree[i] == 0)
			dfs(i, visited, inDegree, distance, graph);
	}

	int maxVal = *max_element(distance.begin(), distance.end());
	cout << maxVal << endl;
}


Measured memory_bytes: 17612
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<vector<int>> G(N);
	for (auto i = 0; i < M; ++i)
	{
		int A, B;
		cin >> A >> B;
		--A;
		--B;
		G[A].push_back(B);
		G[B].push_back(A);
	}

	vector<bool> used(N);
	vector<int> ans(N);
	used[0] = true;
	queue<int> q;
	q.push(0);
	while (!q.empty())
	{
		auto u = q.front();
		q.pop();
		for (auto v : G[u])
		{
			if (used[v] != false)
			{
				continue;
			}

			used[v] = true;
			ans[v] = u;
			q.push(v);
		}
	}

	cout << "Yes" << endl;
	for (auto i = 1; i < N; ++i)
	{
		cout << ans[i] + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 10132
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  char c;
  cin>>c;
  if(c>='a' && c<='z') cout<<'a'<<endl;
  else cout<<"A"<<endl;

  return 0;
}


Measured memory_bytes: 3660
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int m, f, r;
	int s;

	while (1) {
		scanf("%d%d%d", &m, &f, &r);
		if (m == -1 && f == -1 && r == -1) break;

		if (m < 0 || f < 0) puts("F");
		else {
			s = m + f;
			if (s >= 80) puts("A");
			else if (s >= 65) puts("B");
			else if (s >= 50) puts("C");
			else if (s < 30) puts("F");
			else puts(r >= 50 ? "C" : "D");
		}
	}
	return 0;
}



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

int main(){
while(1){
	int n,m,l[10000+2][2],d[500+2],ans=0;
	scanf("%d%d",&n,&m);
if(n==0&&m==0)break;	
d[1]=0;
	for(int i=2;i<n+1;i++)d[i]=-1;
	for(int i=0;i<m;i++){
		scanf("%d%d",&l[i][0],&l[i][1]);
		if(l[i][0]==1)d[l[i][1]]=1;
		if(l[i][1]==1)d[l[i][0]]=1;
	}
	for(int i=0;i<m;i++){
		if(d[l[i][0]]==1&&d[l[i][1]]!=1)d[l[i][1]]=2;
		if(d[l[i][1]]==1&&d[l[i][0]]!=1)d[l[i][0]]=2;
	}
	for(int i=2;i<n+1;i++){
		if(d[i]==1||d[i]==2)ans++;
	}
	printf("%d\n",ans);
}
}

Measured memory_bytes: 1252
#include<iostream>
using namespace std;
static const int MAX = 200000;

int main(){

int n, R[MAX];
int min, max;
int max_diff=0;
bool min_flag = false;
int diff;
 cin >> n ;
for(int t=0; t<n; t++){
  cin >> R[t];

 if(t==0){
  min = R[t];
  max = R[t];
 }

 else if (t==1){
  max_diff = R[t] - R[t-1];
   if (R[t] < R[t-1]){
   min_flag = true;
   }
   else {
   min_flag = false;
   }
 }

 if(min_flag == true){
 if( (R[t] - min) > max_diff){
 max_diff = R[t] -min ;
 }
 }

  if(R[t] < min){ 
  min = R[t]; 
  min_flag = true;
  }

 else if(R[t] > max){
  max = R[t];
  max_diff = R[t] - min;
  min_flag = false;
 }


}
cout << max_diff << endl;

return 0;
}











Measured memory_bytes: 3888
n=int(input())
d={}
for i in range(n):
    x=input()
    if(x not in d):
        d[x]=1
    else:
        d[x]+=1
m=int(input())
for i in range(m):
    x=input()
    if(x not in d):
        d[x]=-1
    else:
        d[x]-=1
l=list(d.values())
print(max(max(l),0))


Measured memory_bytes: 62508
def cc068
    n,m = gets.chomp.split(/\s/).map{|x| x.to_i}

    ab = {}
    for i in 1..m
        a,b = gets.chomp.split(/\s/).map{|x| x.to_i}
        if ab.has_key?(a)
            ab[a].push(b)
        else
            ab[a] = [b]
        end
    end

    ab[1].each do |one|
        next unless ab.has_key?(one)

        if ab[one].index(n)
            puts 'POSSIBLE'
            exit
        end
    end

    puts 'IMPOSSIBLE'
end

cc068

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

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

    vector<long long int> B(N-1);
    for(long long int i = 0; i < N-1; ++i) cin >> B[i];

    long long int ans = 0;
    for(long long int i = 1; i < N-1; ++i){
        ans += min(B[i-1], B[i]);
    }
    ans += B[0]+B[N-2];

    cout << ans << endl;
}

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

namespace {
   constexpr int g1 = 1000 * 1000 * 1000, si = 1001 * 1002, si_log = 8 + 10, mod = static_cast<int>(1e9) + 7;
   constexpr long double eps = 1.0e-9;
   int n, m,k;
}

int64_t sol() {
   auto ret = 0 * numeric_limits<int64_t>::max();

   for (int row = 0; row <= n; row++)
      for (int col = 0; col <= m; col++)
      {
         int cnt = row * m + col * n - 2 * row*col;
         if (k == cnt)
            return 1;
      }

   return ret;
}

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

   while (cin >> n >> m >> k)
   {
      //memset(ar, 0, sizeof ar);
      //for (int i = 0; i <= n; ++i) { gr[i].clear(); }
      //for (int i = 1; i <= n; ++i) cin >> ar[i];
      auto s =
         sol();
      cout << (s ? "Yes" : "No") << '\n';
#ifndef _DEBUG
      break;
#endif
   }
   return 0;
}

Measured memory_bytes: 256
//q079.cpp
//Sat Sep  5 11:25:55 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int rui[n+1][n+1];
	rep(i,n+1)rep(j,n+1) rui[i][j] = 0;
	rep(i,m){
		int l,r;
		cin >> l >> r;
		rui[l][r]++;
	}

	rep(i,n)rep(j,n) rui[i+1][j+1] += rui[i+1][j];
	rep(i,n)rep(j,n) rui[j+1][i+1] += rui[j][i+1];

	rep(i,q){
		int p,q;
		cin >> p >> q;
		cout << rui[q][q]-rui[q][p-1]-rui[p-1][q]+rui[p-1][p-1] << endl;
	}

//	printf("%.4f\n",ans);
}

Measured memory_bytes: 4600
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

typedef long long int64;

typedef long double lld;

using namespace std;

lld _abs(lld x) {
    if (x < 0) return -x;
	return x;
}

lld sqr(lld x) {
   return x * x;
}

lld det(const vector<vector<lld>> a) {
	
	return a[0][0] * (a[1][1] * a[2][2] - a[1][2] * a[2][1]) -
	       a[1][0] * (a[0][1] * a[2][2] - a[2][1] * a[0][2]) +
		   a[2][0] * (a[0][1] * a[1][2] - a[0][2] * a[1][1]);
}

pair<lld, lld> find(lld x1, lld y1, lld x2, lld y2, lld x3, lld y3) {
	lld len1 = sqr(x1) + sqr(y1);
	lld len2 = sqr(x2) + sqr(y2);
	lld len3 = sqr(x3) + sqr(y3);	
	vector<vector<lld>> a = { {len1, y1, 1} ,  {len2, y2, 1}, {len3, y3, 1} };
	vector<vector<lld>> b = { {x1, len1, 1} ,  {x2, len2, 1}, {x3, len3, 1} };
	vector<vector<lld>> c = { {x1, y1, 1} ,  {x2, y2, 1}, {x3, y3, 1} };
	lld sx = 0.5 * det(a);
    lld sy = 0.5 * det(b);
	lld A = det(c);
	if (_abs(A) < 1e-9) return {0, 0};
	sx /= A;
	sy /= A;
	return {sx, sy};
	
	
}	

int main() {
	ios_base::sync_with_stdio(0);

    int n;
	cin >> n;
	vector<long double> x(n);
    vector<long double> y(n);
	
	for (int i = 0; i < n; ++i) {
	    cin >> x[i] >> y[i];
	}
	
	long double ans = -1;
	for (int i = 0; i < n; ++i) {
	    for (int j = i + 1; j < n;  ++j) {
		    long double xr = (x[i] + x[j]) / 2;
			long double yr = (y[i] + y[j]) / 2;
			long double res = 0;
			for (int l = 0; l < n; ++l) {
			    res = max(res, sqr(xr - x[l]) + sqr(yr - y[l]));
			}
			if (ans < -0.5 || ans >= res) {
			    ans = res;
			}
			
			
			for (int k = j + 1; k < n; ++k) {
				auto p = find(x[i], y[i], x[j], y[j], x[k], y[k]);
				long double xr = p.first;
				long double yr = p.second;
				long double res = 0;
			
				for (int l = 0; l < n; ++l) {
					res = max(res, sqr(xr - x[l]) + sqr(yr - y[l]));
				}
				if (ans < -0.5 || ans >= res) {
					ans = res;
				}
				
				
			}
			
		}
	}
	cout.precision(15);
	cout << sqrt(ans) << endl;

    return 0;
}


Measured memory_bytes: 256
if ARGV[0]=="LOCAL_DEV"
  define_method("debug") do |var|
    p var
  end
else
  define_method("debug") do |var|
  end
end

 
A, B = STDIN.gets.strip.split.map(&:to_i)
a=A-B*2
 
puts [0,a].max


Measured memory_bytes: 3836
A1,A2,A3 = map(int, input().split(' '))

ls = [0 + abs(A2 - A1) + abs(A1 - A3), 0 + abs(A2 - A3) + abs(A3 - A1)
, 0 + abs(A3 - A1) + abs(A1 - A2), 0 + abs(A3 - A2) + abs(A2 - A1)
      ,0+abs(A1-A2)+abs(A2-A3), 0+abs(A1-A3)+abs(A3-A2)]

print(min(ls))

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath> 
#include <queue>
#include <functional>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//static const int dx[4] = {1, -1, 0, 0};
//static const int dy[4] = {0, 0, 1, -1};

vector<P> v1, v2;
map<P, int> Rank;
map<P, P> Parent;
vector<pair<int,  pair<P, P> > > man;

P find(P a);
bool isSame(P a, P b);
void unite(P a, P b);

int main() {

    int N; cin >> N;
    int x, y;
    for (int i = 0; i < N; i++) {
        scanf("%d %d", &x, &y);
        v1.push_back(P(x, y));
        v2.push_back(P(y, x));
        Rank[P(x, y)] = 0;
        Parent[P(x, y)] = P(x, y);
    }

    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());

    for (int i = 1; i < N; i++) {
        int cost1 = v1[i].first - v1[i-1].first;
        int cost2 = v2[i].first - v2[i-1].first;
        P temp1 = make_pair(v2[i].second, v2[i].first);
        P temp2 = make_pair(v2[i-1].second, v2[i-1].first);
        man.push_back(make_pair(cost1, make_pair(v1[i], v1[i-1])));
        man.push_back(make_pair(cost2, make_pair(temp1, temp2)));
    }

    sort(man.begin(), man.end());
    /*
    for (int i = 0; i < N; i++){ 
        cout << "cost " << man[i].first << " pair " 
            << man[i].second.first.first <<
            ' ' << man[i].second.first.second << ':' << 
            man[i].second.second.first << ' ' <<  
            man[i].second.second.second << '\n';
    }
    */

    int ans = 0;

    for (int i = 0; i < man.size(); i++) {
        if (isSame(man[i].second.first, man[i].second.second))
            continue;
        unite(man[i].second.first, man[i].second.second);
        ans += man[i].first;

    }

    cout << ans << '\n';

}

P find(P a) {
    
    if (a == Parent[a]) return a;
    else {
        return Parent[a] = find(Parent[a]);
    }
}

bool isSame(P a, P b) {
    return find(a) == find(b);

}

void unite(P a, P b) {
    
    P x = find(a);
    P y = find(b);

    if (x == y) return;

    if (Rank[x] < Rank[y]) {
        Parent[x] = y;
    }
    else {
        Parent[y] = x;
        if (Rank[x] == Rank[y])
            Rank[x]++;
    }
}


Measured memory_bytes: 22112
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
 
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
   
using namespace std;
   
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
   
static const double EPS = 1e-8;
   
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

ll gcd(ll a, ll b) {
  return b != 0 ? gcd(b, a % b) : a;
}

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

ll mod_inverse(ll a, ll m){
  ll x, y;
  extgcd(a, m, x, y);
  return (m + x % m) % m;
}

pair<ll, ll> linear_congruence(const vector<ll>& A, const vector<ll>& B,
                                 const vector<ll>& M) {
  ll x = 0, m = 1;
  for(ll i = 0; i < A.size(); i++){
    if(B[i] == -1) continue;
    ll a = A[i] * m, b = B[i] - A[i] * x, d = gcd(M[i], a);
    if(b % d != 0) return make_pair(0, -1);
    ll t = b / d * mod_inverse(a / d, M[i] / d) % (M[i] / d);
    x = x + m * t;
    m *= M[i] / d;
  }
  return make_pair(x % m, m);
}

int main(){
  ll num_of_chopsticks;
  int num_of_divisors;
  int total_days;
  while(~scanf("%lld %d %d",
               &num_of_chopsticks,
               &num_of_divisors,
               &total_days)){
    vector<ll> divisors(num_of_divisors);
    for(int div_i = 0; div_i < num_of_divisors; div_i++){
      scanf("%lld",&divisors[div_i]);
    }
    ll record[101][11];
    for(int day = 0; day < total_days; day++){
      for(int div_i = 0; div_i < num_of_divisors; div_i++){
        scanf("%lld",&record[day][div_i]);
      }
    }

    vector<ll> A(num_of_divisors,1);
    for(int day = 0; day < total_days; day++){
      vector<ll> reminder;
      for(int div_i = 0; div_i < num_of_divisors; div_i++){
        reminder.push_back(record[day][div_i]);
      }

      pair<ll,ll> ans = linear_congruence(A,reminder,divisors);
      num_of_chopsticks -= (num_of_chopsticks - ans.first + ans.second) % ans.second;
      if(num_of_chopsticks < 0 || ans.second == -1){
              num_of_chopsticks = -1;
        break;
      }
    }
    printf("%lld\n",num_of_chopsticks);
  }
}

Measured memory_bytes: 1220