akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
 
using namespace std;
typedef long long ll;
 
const int    INF = 1000000000;
const int    MOD = 1000000007;
const double EPS = 1e-8;
 
int main(){
    int Q, L;
    /* 00.51sec 
    while(scanf("%d %d", &Q, &L) != EOF && Q > 0){
        deque<int> deq;
        for(int q, x; Q--;){
            scanf("%d %d", &q, &x);
            while(deq.size() > L) deq.pop_front();
            if(q == 0) deq.push_back(x);
            if(q == 1) deq.erase(deq.begin() + x - 1);
            if(q == 2) printf("%d\n", deq[x - 1]);
            if(q == 3) deq.erase(find(deq.begin(), deq.end(), x));
        }
        puts("end");
    }
    */
    while(scanf("%d %d", &Q, &L) != EOF && Q > 0){
        vector<int> vec;
vec.reserve(Q);
        for(int q, x; Q--;){
            scanf("%d %d", &q, &x);
            while(vec.size() > L) vec.erase(vec.begin());
            if(q == 0) vec.push_back(x);
            if(q == 1) vec.erase(vec.begin() + x - 1);
            if(q == 2) printf("%d\n", vec[x - 1]);
            if(q == 3) vec.erase(find(vec.begin(), vec.end(), x));
        }
        puts("end");
    }
    return 0;
}

Measured memory_bytes: 1448
X,Y = map(int,input().split())

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def combi(n,r,mod=10**9+7):
    fac = [0]*(n+1)
    fac[0] = 1
    fac[1] = 1
    for i in range(2,n+1):
        fac[i] = fac[i-1] * i % mod
    return( ( fac[n] * modinv(fac[r]) )%mod * modinv(fac[n-r]) % mod)

if (X+Y) % 3 != 0 or X > 2*Y or Y > 2*X:
    print(0)
else:
    n = X - (X + Y)//3
    m = (X + Y)//3 - n
    print(combi(n+m,m))

Measured memory_bytes: 43632
# include <stdio.h>
# include <stdbool.h>
# include <stdlib.h>

int main()

{
    int a,b ;
    scanf("%d%d",&a,&b);
    if (b*2>=a)
    {
        printf("0");

    }
    else
    {
        printf("%d",a-b-b);
    }
    
    system("pause");
    return 0;

}

Measured memory_bytes: 376
#include <stdio.h>
const int SIZE = 100; 
int data[100]; 
int sp= 0;
int empty(){ 
	return sp<= 0;
}
int size(){ 
	return sp; 
}
int isfull(){
	return sp>= SIZE; 
}
int top(){ 
	return data[sp-1]; 
}
void pop(){ 
	sp--; 
}
void push(int v){ 
	data[sp] = v; 
	sp++; 
}

int main(){
	int n,i,cnt=0,out[100];
	while(scanf("%d",&n)!=EOF){
  		if(! isfull()) {
			if(n!=0){
   				push(n);
			}else{
				out[cnt]=top();
				pop();
				cnt++;
			}
  		}
 	}
	for(i=0;i<cnt;i++){
		printf("%d\n",out[i]);
	}
 	return 0;
}

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

const int INF = (int)1e9;

struct State {
  int pos, cost;
  State(int pos_, int cost_) : pos(pos_), cost(cost_) { }
  bool operator >(const State &s) const {
    return cost > s.cost;
  }
};

struct Edge {
  int to, cost;
};

typedef vector<vector<Edge>> Graph;

int shortest_path(const Graph &G, const int from, const int to) {
  const int n = G.size();
  int d[n];
  fill(d, d + n, INF);
  d[from] = 0;
  priority_queue<State, vector<State>, greater<State>> Q;
  Q.emplace(from, 0);
  while(!Q.empty()) {
    State s = Q.top(); Q.pop();
    if(s.cost > d[s.pos]) continue;
    d[s.pos] = s.cost;
    if(s.pos == to) break;
    for(Edge e : G[s.pos]) {
      if(d[e.to] > d[s.pos] + e.cost) {
        d[e.to] = d[s.pos] + e.cost;
        Q.emplace(e.to, d[e.to]);
      }
    }
  }
  return d[to];
}

int main() {
  int N, K; cin >> N >> K;
  vector<pair<int, int>> taxis(N);
  for(int i = 0; i < N; ++i) {
    cin >> taxis[i].first >> taxis[i].second;
  }
  vector<vector<int> > adj(N);
  for(int i = 0; i < K; ++i) {
    int a, b; cin >> a >> b;
    a--, b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }

  Graph G(N);

  for(int i = 0; i < N; ++i) {
    int d[N];
    fill(d, d + N, INF);
    d[i] = 0;
    queue<int> Q;
    Q.push(i);
    while(!Q.empty()) {
      int x = Q.front(); Q.pop();
      if(d[x] == taxis[i].second) break;
      for(int next : adj[x]) {
        if(d[next] == INF) {
          d[next] = d[x] + 1;
          Q.push(next);
        }
      }
    }
    for(int j = 0; j < N; ++j) {
      if(j == i) continue;
      if(d[j] == INF) continue;
      Edge e;
      e.to = j;
      e.cost = taxis[i].first;
      G[i].push_back(e);
    }
  }

  cout << shortest_path(G, 0, N - 1) << endl;
}

Measured memory_bytes: 125868
#include<iostream>

const int K = 10000;

// Countingsort
void countingsort(int A[], int B[], int n)
{
	int C[10001];
	// Initialize
	for (int i = 0; i <= K; i++)
		C[i] = 0;
	// Count frequency
	for (int i = 0; i < n; i++)
		C[A[i]]++;
	// Calculate cumulative sum
	for (int i = 1; i <= K; i++)
		C[i] = C[i] + C[i - 1];
	for (int i = n - 1; i >= 0; i--) {
		B[C[A[i]] - 1] = A[i];
		C[A[i]]--;
	}
}

// MAIN FUNCTION
int main()
{
	// Input
	int n;
	int A[2000000];
	std::cin >> n;
	A[0] = 0;
	for (int i = 0; i < n; i++) {
		std::cin >> A[i];
	}

	// Counting sort
	int B[2000000];
	countingsort(A, B, n);
	for (int i = 0; i < n; i++) {
		if (i)
			std::cout << " ";
		std::cout << B[i];
	}
	std::cout << std::endl;
	return 0;
}

Measured memory_bytes: 18764
#include <iostream>
#include <vector>
using namespace std;
long long f(vector<int>a, int sign){
  long long ans = 0;
  if(sign>0 && a.at(0)<=0){
    ans += -a.at(0)+1;
    a.at(0) += -a.at(0)+1;
  }
  if(sign<0 && a.at(0)>=0){
    ans += a.at(0)+1;
    a.at(0) -= a.at(0)+1;
  }
  long long sum = a.at(0);
  for(int i=1; i<a.size(); i++){
    if(sum>0 && a.at(i)+sum>=0){
      ans += a.at(i)+sum+1;
      a.at(i) -= a.at(i)+sum+1;
    }
    if(sum<0 && a.at(i)+sum<=0){
      ans += -(a.at(i)+sum-1);
      a.at(i) += -(a.at(i)+sum-1);
    }
    sum += a.at(i);
  }
  return ans;
}
    
int main(){
 int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin >> a.at(i);
  }
  cout << min(f(a,1),f(a,-1));
}

Measured memory_bytes: 4560
a, b, x = map(int, input().split())
from math import atan,pi
if x<= a*a*b/2:
    print(90-atan((x*2/b/a)/b)*180/pi)
elif x==a*a*b:
    print(0)
else:
    print(90-atan(a/((a*a*b-x)*2/a/a))*180/pi)
    

Measured memory_bytes: 38384
package main

import (
	"fmt"
)

func min(x int, y int) int {
	var res int

	if x < y {
		res = x
	} else {
		res = y
	}

	return res
}

func main() {
	var A, B, C, D int
	fmt.Scan(&A, &B, &C, &D)

	ans := min(A, B) + min(C, D)

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <stdio.h>

int main(int argc, char *argv[])
{
        int a, b, r;
        char op;

        while (1) {
                scanf("%d %c %d", &a, &op, &b);
                if (op == '?') break;

                switch (op) {
                case '+':
                        r = a + b;
                        break;

                case '-':
                        r = a - b;
                        break;

                case '*':
                        r = a * b;
                        break;

                case '/':
                        r = a / b;
                        break;
                }

                printf("%d\n", r);
        }

        return 0;
}

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

public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static long mod = (long) (1e9+7);
	static long cf = 998244353;
    static final long MAX = (long) 1e15;
   // public static List<Integer>[] edges;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int m = sc.nextInt();
		if(n <= 9 && m <= 9) out.println(n*m);
      else out.println(-1);
		out.close();
	}
}


Measured memory_bytes: 23252
def H(h, x, y, cx, cy):
    return h + abs(x-cx) + abs(y-cy)
def Hr(h, x, y, cx, cy):
    return max(h-abs(x-cx)-abs(y-cy),0)


N = int(input())
x = [list(map(int, input().split())) for i in range(N)]
for cx in range(0, 101):
    for cy in range(0, 101):
        judge = True
        m = [l for l in range(N) if x[l][2]!=0][0]
        H0 = H(x[m][2], x[m][0], x[m][1], cx, cy)
        for n in range(len(x)):
            Hn = H(x[n][2], x[n][0], x[n][1], cx, cy)
            #print(Hn)
            if(x[n][2] != 0):
                if(Hn == H0):
                    judge = judge and True
                else:
                    judge = judge and False
        if(judge):
            for n in range(len(x)):
                if(x[n][2] == 0):
                    Hm = Hr(H0, x[n][0], x[n][1], cx, cy)
                    if(Hm == 0):
                        judge = judge and True
                    else:
                        judge = judge and False
                
            if(judge):
                print(cx, cy, H0)


Measured memory_bytes: 3064
#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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;

void solve(int a){cout<<( a?"Yes":"No")<<endl;}
int main(){
	int n,m,c;
	cin >>n>>m>>c;
	int ans=0;
	vector<int>b(m+1,0);
	int bef=0;
	int total=0;
	for(int i=0;i<m;i++){
		cin >>b[i];
	}
	for(int i=0;i<n;i++){
		total=0;
		for(int j=0;j<m;j++){
			cin >>bef;
			total+=((b[j])*bef);
		}
		if(total +c>0){
			ans++;
		}
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define INF 10000000

int A[100][100];

int prim(int);

int main(){
  int i, j, n;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      scanf("%d", &A[i][j]);
      if(A[i][j] == -1) A[i][j] = INF;
    }
  }

  printf("%d\n", prim(n));
  
  return 0;
}

int prim(int n){
  int u, minv, i, j, sum;
  int d[100], p[100], flag[100];
  
  for(i = 0; i < n; i++){
    d[i] = INF;
    p[i] = -1;
    flag[i] = 0;
  }

  d[0] = 0;

  while(1){
    minv = INF;
    u = -1;
    for(i = 0; i < n; i++){
      if(minv > d[i] && flag[i] != 2){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1) break;
    flag[u] = 2;
    for(i = 0; i < n; i++){
      if(flag[i] != 2 && A[u][i] != INF){
	if(d[i] > A[u][i]){
	  d[i] = A[u][i];
	  p[i] = u;
	  flag[i] = 1;
	}
      }
    }
  }
  sum = 0;
  for(i = 0; i < n; i++){
    if(p[i] != -1) sum += A[i][p[i]];
  }
  return sum;
}



Measured memory_bytes: 2108
import sys

N=int(sys.stdin.readline().rstrip())
AList=list(map(int,sys.stdin.readline().split()))
BList=list(map(int,sys.stdin.readline().split()))
CList=list(map(int,sys.stdin.readline().split()))

beforeBuffet=-1
sutisfier=0
for i in range(N):
  buffet=AList[i]
  sutisfier+=BList[buffet-1]
  if buffet-beforeBuffet==1:
    sutisfier+=CList[buffet-2]
  beforeBuffet=buffet
print(sutisfier)
  

Measured memory_bytes: 38740
#include<stdio.h>
int main(){
	int i, j;
	int buff;
	int m[10];
	for (i = 0; i < 10; i++) {
		scanf("%d", &m[i]);
	}
	for (i = 0; i < 3; i++) {
		buff = m[i];
		for (j = i+1; j < 10; j++) {
			if (m[i] < m[j]) {
				buff = m[i];
				m[i] = m[j];
				m[j] = buff;
			}
		}
	}
	for (i = 0; i < 3; i++) {
		printf("%d\n", m[i]);
	}
	return 0;
}


Measured memory_bytes: 2692
#include<bits/stdc++.h>
using namespace std;
int flag;
string a,b;
int main(){
	cin>>a>>b;
	int size=a.size();
	if(a.size()!=b.size()){
	    size--;
		flag=1;	
	}
	for(int i=0;i<size;i++){
		cout<<a[i]<<b[i];
	}
	if(flag)cout<<a[size];
	cout<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int z=0;
		int p[]=new int[N];
		int max=0;
		int y=0;
		int plus=0;
		while(z<N){
			p[z]=stdIn.nextInt();
			if(p[z]>max){
				y=z;
				max=p[z];
			}
			z++;
		}z=0;
		while(z<N){
			if(y==z)
				plus+=p[z]/2;
			else
				plus+=p[z];
			z++;
		}
		System.out.println(plus);
	}
}


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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
  
  
  int x,k,d;
  cin>>x>>k>>d;
  x=abs(x);
  int memo=abs(x)/d;
  if(k<=memo){
    cout<<abs(x)-k*d<<endl;
  }
  else{
    int ans=x-memo*d;
    if((k-memo)%2==0){
      cout<<ans<<endl;
    }
    else{
      cout<<min(ans+d,abs(ans-d))<<endl;
    }
  }
  
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
  int repeat = 1;
  // cin >> repeat;
  while(repeat--) solve4ts();
}

/*

g++ -std=c++1z code.cpp
./a.out

*/

Measured memory_bytes: 7792
#include<bits/stdc++.h>
using namespace std;
int k,ans;
int main()
{
    scanf("%d",&k);int j = 0,o = 0;
    for (int i = 1;i <= k;i++)
    {
        if(i % 2 == 0)o++;
        else j++;
    }
    printf("%d",j*o);
    return 0;
    
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const double EPS = 1.0e-10;

class Point
{
public:
    double y, x;
    Point(){
        y = x = 0.0;
    }
    Point(double y0, double x0){
        y = y0;
        x = x0;
    }
    Point operator+(const Point& p) const{
        return Point(y + p.y, x + p.x);
    }
    Point operator-(const Point& p) const{
        return Point(y - p.y, x - p.x);
    }
    Point operator*(double a) const{
        return Point(y * a, x * a);
    }
    Point operator/(double a) const{
        return Point(y / a, x / a);
    }
    double length() const{
        return sqrt(y * y + x * x);
    }
    double dist(const Point& p) const{
        return sqrt(pow(y - p.y, 2) + pow(x - p.x, 2));
    }
};

class Edge
{
public:
    int to;
    double cost;
    Edge(){};
    Edge(int to0, double cost0){to = to0; cost = cost0;}
};

double solve(const vector<vector<Edge> >& edges)
{
    int n = edges.size();
    vector<bool> used(n, false);
    vector<double> minCost(n, -1.0);
    double ret = 0.0;
    
    for(int i=0; i<n; ++i){
        if(used[i])
            continue;

        priority_queue<pair<double,int> > q;
        q.push(make_pair(0.0, i));

        while(!q.empty()){
            pair<double, int> p = q.top();
            q.pop();
            int v = p.second;
            if(used[v])
                continue;
            ret += p.first;
            used[v] = true;
            for(unsigned i=0; i<edges[v].size(); ++i){
                Edge e = edges[v][i];
                if(!used[e.to] && e.cost > minCost[e.to] + EPS){
                    minCost[e.to] = e.cost;
                    q.push(make_pair(e.cost, e.to));
                }
            }
        }
    }

    return ret;
}

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

    vector<Point> p(n);
    for(int i=0; i<n; ++i)
        cin >> p[i].x >> p[i].y;

    vector<vector<Edge> > edges(n);
    double sum = 0.0;
    for(int i=0; i<m; ++i){
        int a, b;
        cin >> a >> b;
        -- a;
        -- b;

        double cost = p[a].dist(p[b]);
        sum += cost;
        edges[a].push_back(Edge(b, cost));
        edges[b].push_back(Edge(a, cost));
    }

    double ret = sum - solve(edges);
    printf("%.10f\n", ret);

    return 0;
}

Measured memory_bytes: 3404
#include<iostream>
using namespace std;
int main(){
    int n, q, t, c = 0;
    cin >> n;
    int S[n];
    for (int i = 0; i < n; i++) cin >> S[i];
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> t;
        int range[3] = {0, n-1, n};
        while (true) {
            int a = (range[2]-1)/2 + range[0];
            if (S[a] == t) { c++; break; }
            else if (range[2] == 1) break;
            else if (range[2] == 2) { if (S[range[1]] == t) c++; break;}
            else if (S[a] < t) { range[0] = a+1; range[2] = range[1]-range[0]+1; }
            else { range[1] = a-1; range[2] = range[1]-range[0]+1; }
        }
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 3476
#include "bits/stdc++.h"
using namespace std;
int main(){
   int x,y;
   cin >>x>>y;
   for (int i = 0; i<=x; ++i){
       for (int j =0;j<=x; ++j){
           if (4*i + 2*j == y && i +j == x) {
               cout << "Yes";
               return 0;
           }
       }
   }
   cout << "No";
}

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

int main(){
	int g;
	vector<int> v;
	while(cin>>g){
		v.clear();
		for(int i=0;i<10;i++)
			if(g&1<<i)v.push_back(1<<i);
		cout<<v[0];
		for(int i=1;i<v.size();i++)
			cout<<' '<<v[i];
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1208
if __name__ == "__main__":
    n = int(input().strip().split()[0])
    for i in range(n):
        data = list(map(int,input().strip().split()))
        c = max(data)
        data.remove(c)
        a,b = data
        if a **2 + b ** 2 == c**2 :print("YES")
        else:print("NO")

Measured memory_bytes: 7728
def answer(w: int, a: int, b: int) -> int:
    b_a = abs(b - a)
    if b_a <= w:
        return 0
    return b_a - w


def main():
    w, a, b = map(int, input().split())
    print(answer(w, a, b))


if __name__ == '__main__':
    main()

Measured memory_bytes: 9116
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <cassert>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>
#include <functional>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

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

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    string str;
    cin >> str;
    int N = str.size();

    string str1;
    string str2;
    for (int i = 0; i < (N-1)/2; i++) str1 += str[i];
    for (int i = (N+1)/2; i < N; i++) str2 += str[i];

    reverse(str1.begin(), str1.end());
    if (str1 != str2) {
        cout << "No" << endl;
        return 0;
    }

    int M = str1.size();
    for (int i = 0; i < M; i++) {
        if (str1[i] != str1[M-1-i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    int L = str2.size();
    for (int i = 0; i < L; i++) {
        if (str2[i] != str2[L-1-i]) {
            cout << "No" << endl;
            return 0;
        }
    }

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

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

namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int a = int.Parse(input[1]);
            int b = int.Parse(input[2]);
            int ans = 0;
            for (int i = 1; i <= n; i++)
            {
                int sd = SumDigit(i);
                if (a <= sd && sd <= b)
                {
                    ans += i;
                }
            }
            Console.WriteLine(ans);
        }
        static int SumDigit(int x)
        {
            int sum = 0;
            while (x > 0)
            {
                sum += x % 10;
                x /= 10;
            }
            return sum;
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
typedef unsigned long long int ull;
//--main function
int main(){
	int a[100001]={0};
	int n,q,b,c;
	ull s=0;
	cin>>n;
	vi v(n);
	REP(i,0,n-1){
		cin>>v[i];
		s+=v[i];
		a[v[i]]++;
	}
	cin>>q;
	REP(i,1,q){
		cin>>b>>c;
		s=s + ((c-b)*a[b]);
		a[c]=a[c]+a[b];
		a[b]=0;
		cout<<s<<"\n";
	}
	
	return 0;

//   TimeTaken();
}


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

int N;
string S;

void solve(){
    if(N%2 != 0) cout << "No" << endl;
    else{
        if(S.substr(0, N/2) == S.substr(N/2, N)) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

int main(){
    cin >> N >> S;
    solve();
    return 0;
}

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

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int k;
int q;
long long d[N];
int main()
{
    #ifdef FILEs
        freopen("input.txt", "r", stdin);
        /// freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);

    cin >> k >> q;
    for(int i = 1; i <= k; i ++){
        cin >> d[i];
    }
    while(q --){
        long long n, x, m;
        cin >> n >> x >> m;
        x %= m;
        long long s = 0;
        long long res = n - 1;
        for(int i = 1; i <= k; i ++){
            int q = (n - 1 - i + k) / k;
            s += (q * (d[i] % m));
            if(d[i] % m == 0){
                res -= q;
            }
        }
        long long last = x + s;
        res -= last / m;
        cout << res << "\n";
    }
}



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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    vector<int> count(N, 0);

    for (int i = 0; i < N; i++) {
        count.at(A.at(i) - 1)++;
    }
    sort(count.begin(), count.end());
    int type = 0;
    for(int i = 0; i < N; i++) {
        if (count.at(i) > 0) type++;
    }
    int res = 0;
    for(int i = 0; i < N; i++) {
        if (type <= K) break;
        if (count.at(i) > 0) {
            res += count.at(i);
            type--;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include <cstdio>
#include<cstring>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility>
#define LEN 100005
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
ll LGCD(ll x, ll y) {if (x % y == 0) return y;else return LGCD(y, x % y);}
ll LLCM(ll x, ll y) {return x * y / LGCD(x, y);}

int GCD(int x, int y) {if (x % y == 0) return y;else return GCD(y, x % y);}
int LCM(int x, int y) {return x * y / GCD(x, y);}
ll dp[10000][10000];
ll combination(ll n, ll r) {
         if (n == r){dp[n][n] = 1;}
	else if (r == 0) {return dp[n][0] = 1;}
	else if (r == 1) {return dp[n][1]=n;}
	else {dp[n][r]=dp[n - 1][r - 1] % 1000000007 + dp[n - 1][r] % 1000000007;
	return dp[n][r]=combination(n - 1, r - 1) % 1000000007 + combination(n - 1, r) % 1000000007;}
}
int main() {
	int N,K;
	int count,ans;
	count = 0;
	cin >> N>>K;
	vector<int>h(N);
	for (int i = 0;i < N;i++)
	{
		cin >> h.at(i);

	}
	for (int i = 0;i < N;i++)
	{
		if (h.at(i)>=K) { count++; }
	}
	
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 640
def myAnswer(A:list,B:list,N:int) -> str:
   bingo=[[0,0,0] for i in range(3)]
   for b in B:
      for i,a in enumerate(A):
         if(b in a):
            bingo[i][a.index(b)] = 1
            break
   tate=[0,0,0]
   for n,b in enumerate(bingo):
      if(sum(b) == 3):
         return "Yes"
      for i in range(3):
         tate[i] += b[i]
   if(3 in tate): return "Yes"
   if(bingo[1][1] == 1):
      if((bingo[0][0] == 1 and bingo[2][2] == 1) or (bingo[0][2]==1 and bingo[2][0]==1)):
         return "Yes"
   return "No"

def modelAnswer():
   tmp=1
def main():
   A=[]
   B=[]
   for _ in range(3):
      A.append(list(map(int,input().split())))
   N = int(input())
   for _ in range(N):
      B.append(int(input()))
   print(myAnswer(A[:],B[:],N))

if __name__ == '__main__':
   main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *max_element(all(a));}

template<class T>void puta(T&&t){cout<<t<<endl;}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void OUT(bool b){tf(b,"YES","NO");}
void Out(bool b){tf(b,"Yes","No");}
void out(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m,s,t;
	cin>>n>>m>>s>>t;
	vector<vector<pll>> yen(n+1);
	vector<vector<pll>> snuuk(n+1);
	rep(i,m){
		ll a,b,c,d;
		cin>>a>>b>>c>>d;
		yen[a].emplace_back(b,c);
		yen[b].emplace_back(a,c);
		snuuk[a].emplace_back(b,d);
		snuuk[b].emplace_back(a,d);
	}
	vl cost_y(n+1,1);
	vl cost_s(n+1,1);
	priority_queue<pll> q;
	q.emplace(0,s);
	while(!q.empty()){
		ll cost,point;
		tie(cost,point)=q.top();
		q.pop();
		if(cost_y[point]!=1)continue;
		cost_y[point]=cost;
		for(auto&e:yen[point]){
			ll to,need;
			tie(to,need)=e;
			if(cost_y[to]==1){
				q.emplace(cost-need,to);
			}
		}
	}
	q.emplace(0,t);
	while(!q.empty()){
		ll cost,point;
		tie(cost,point)=q.top();
		q.pop();
		if(cost_s[point]!=1)continue;
		cost_s[point]=cost;
		for(auto&e:snuuk[point]){
			ll to,need;
			tie(to,need)=e;
			if(cost_s[to]==1){
				q.emplace(cost-need,to);
			}
		}
	}
	vl ans(n+1,0);
	rep(_,n){
		int i=n-_;
		ans[i]=max(ans[i+1],1000000000000000ll+cost_y[i]+cost_s[i]);
	}
	range(i,1,n+1)puta(ans[i]);
	return 0;
}

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

#define ll long long
const int N = 3e5 + 5, MOD = 1e9 + 7;

vector<int> adj[N];
int dp[N][15], candidate[N][15], color[N];

int solve(int u, int d){
	if(d > 10)	return 0;
	if(dp[u][d] != -1)	return dp[u][d];
	dp[u][d] = candidate[u][d];
	dp[u][d] = max(dp[u][d], solve(u, d + 1));
	for(auto v : adj[u]){
		dp[u][d] = max(dp[u][d], solve(v, d + 1));
	}
	//cout<<u<<" "<<d<<" --> "<<dp[u][d]<<endl;
	return dp[u][d];
}

int main(){
	memset(dp, -1, sizeof(dp));
	int n, m, q, u, v, dist, c;
	cin>>n>>m;
	while(m--){
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	cin>>q;
	for(int i = 1; i <= q; i++){
		cin>>u>>dist>>c;
		candidate[u][dist] = i;
		color[i] = c;
	}


	for(int i = 1; i <= n; i++){
		for(int j = 10; j >= 0; j--){
			solve(i, j);
		}
	}

	for(int i = 1; i <= n; i++){
		int ans = 0;
		for(int j = 0; j <= 10; j++){
			ans = max(ans, dp[i][j]);
		}
		cout<<color[ans]<<endl;
	}
}

Measured memory_bytes: 36472
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n, n) {
    vvi v(n);
    rep(i, n) {
      int m;
      cin >> m;
      while (m--) {
        int p;
        cin >> p;
        v[i].pb(p);
      }
    }
    int k;
    cin >> k;
    vi w(k);
    rep(i, k) cin >> w[i];
    sort(all(w));
    int c = 0, p;
    rep(i, v.size()) {
      vi r;
      sort(all(v[i]));
      set_difference(all(w), all(v[i]), back_inserter(r));
      if (r.size() == 0) {
        c++;
        p = i;
      }
    }
    cout << (c == 1 ? p + 1 : -1) << endl;
  }
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define MOD 1000000007 
#define MAX 100005
#define loop(i,a,b) for(long long int i=a;i<b;i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
typedef long long int ll;
using namespace __gnu_pbds;
using namespace std;
//using namespace boost::multiprecision;

#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>

ll fact[MAX],inv_fact[MAX];

ll modular_expo(ll x,ll n)
{
	ll ans = 1;
	while(n)
	{
		if(n&1)
		ans = (ans * x)%MOD;
		x = (x*x)%MOD;
		n = n>>1;
	}
	return ans%MOD;
}

void fun()
{
	fact[0] = 1;
	for(ll i=1;i<MAX;i++)
	fact[i] = (fact[i-1] * i)%MOD;
	inv_fact[MAX-1] = modular_expo(fact[MAX-1],MOD-2);
	for(ll i=MAX-2;i>=0;i--)
	inv_fact[i] = (inv_fact[i+1] * (i+1))%MOD;
}


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

//fun();

ll t=1;
//cin>>t;

while(t--)
{
	ll n,a;
	cin>>n>>a;
	
	cout<<n*a<<"\n";
}



return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

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

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

int main(void) {
    string s;
    int n;
    int count=0;

    cin>>n>>s;
    FOR(i,0,n-2){
        if(s[i]==s[i+1]){
            s[i]='A';
        }
    }
    FOR(i,0,n-1){
        if(s[i]!='A'){
            count++;
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N;
  cin >> N;
  string S;

  int k = 1;
  while (N != 0)
  {
    long long num = pow(-2, k);
    if (abs(N) % abs(num) != 0)
    {
      S += '1';
      N -= num / (-2);
    }
    else
    {
      S += '0';
    }
    k++;
  }
  if (S.size() == 0)
    S += '0';
  reverse(S.begin(), S.end());
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int tate;
	int yoko;
	int i, j;
	while (1)
	{
		scanf("%d %d", &tate, &yoko);
		if (tate == 0 && yoko == 0)
		{
			return 0;
		}
		for (i = 0; i < tate; i++)
		{
			for (j = 0; j < yoko; j++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <vector>
using namespace std;
vector<int> df, ds, used, use;
vector<vector<int>> G;
void dfsf(int i){
    for(int j:G[i]){
        if(used[j] == 0){
            df[j] = df[i] + 1;
            used[j] = 1;
            dfsf(j);
        }
    }
}
void dfss(int i){
    for(int j:G[i]){
        if(use[j] == 0){
            ds[j] = ds[i] + 1;
            use[j] = 1;
            dfss(j);
        }
    }
}
int main(){
    int N;
    cin >> N;
    G.resize(N);
    for(int i = 0; i < N - 1; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    df.resize(N, 0);
    ds.resize(N, 0);
    used.resize(N, 0);
    used[0] = 1;
    dfsf(0);
    use.resize(N, 0);
    use[N - 1] = 1;
    dfss(N - 1);
    int cnt = 0, cnt2 = 0;
    for(int i = 0; i < N; i++){
        if(df[i] <= ds[i]) cnt++;
        else cnt2++;
    }
    //for(int i = 0; i < N; i++) cout << df[i] << ' ' << ds[i] << endl;
    if(cnt <= cnt2) cout << "Snuke" <<endl;
    else cout << "Fennec" << endl;
}

Measured memory_bytes: 14772
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:usize){n;list:(i64,i64)});
    list.into_iter()
        .map(|(x, y)| y - x + 1)
        .sum::<i64>()
        .to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "1\n24 30" => "7",
    test2: "2\n6 8\n3 3" => "4",
}


Measured memory_bytes: 4352
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] arr = new int[n+1];
      for(int i = 1; i <= n; i++)
        arr[i] = sc.nextInt();
      int[] res = new int[n+1];
      
      int resCnt = 0;
      for(int i = n; i > 0; i--) {
        int cnt = 0;
        for(int j = i*2; j <= n; j += i)
          cnt += res[j];
        if(cnt % 2 != arr[i]) {
          res[i] = 1;
          resCnt++;
        }
      }
      System.out.println(resCnt);
      if(resCnt != 0)
      for(int i = 1; i <= n; i++) {
        if(res[i] > 0)
            System.out.print(i+ " ");
      }
      System.out.println();
  }
}

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

int main(){
  int n;
  cin >> n;
  int a=n/100;
  int b=n%100;
  int mmyy=1,yymm=1;
  
  mmyy*=(a<=12&&a!=0);
  yymm*=(b<=12&&b!=0);
  
  if(mmyy*yymm) cout << "AMBIGUOUS" << endl;
  else if(mmyy==1&&yymm==0) cout << "MMYY" << endl;
  else if(yymm==1&&mmyy==0) cout << "YYMM" << endl;
  else cout << "NA" << endl;
}

Measured memory_bytes: 256
n = int(input())
ip = []

for i in range(n):
  a = int(input())
  ip.append(a)
  for j in range(a):
    x,y = map(int,input().split())
    ip.append([x,y])

max = 0    
for i in range(n) :
  max += 2**i

ans = 0
for i in range(0,max+1) :
  s = [2 for _ in range(n)]
  bit = i
  count = 0
  index = 0
  check = 0
  for j in range(n) :
    if bit%2 == 1 :
      if s[j] == 0 :
        check = 1
        break
      s[j] = 1
    else :
      if s[j] == 1 :
        check = 1
        break
      s[j] = 0
    bit = bit//2
    for k in range(ip[index]) :
      if s[j] == 1 :
        if ip[index+1+k][1] == 1 :
          if s[ip[index+1+k][0]-1] == 0 :
            check = 1
            break
          s[ip[index+1+k][0]-1] = 1
        elif ip[index+1+k][1] == 0 :
          if s[ip[index+1+k][0]-1] == 1 :
            check = 1
            break
          s[ip[index+1+k][0]-1] = 0
    if check == 1 :
      break
    index += ip[index] + 1
  if ans < s.count(1) and check ==0 :
    ans = s.count(1)

print(ans)

Measured memory_bytes: 3064
#include<cstdio>
using namespace std;
int main(){
  int n,x,num[4],l;
  scanf("%d %d",&n,&x);
  l=1;
  if(x==1||x==2*n-1)
    printf("No\n");
  else{
    printf("Yes\n");
    if(n==2)
      printf("1\n2\n3\n");
    else{
      if(x!=2){
        num[0]=x-1;
        num[1]=x;
        num[2]=x+1;
        num[3]=x-2;
      }
      else{
        num[0]=x+1;
        num[1]=x;
        num[2]=x-1;
        num[3]=x+2;
      }
      for(int i=0;i<2*n-1;i++){
        if(i>=n-2&&i<=n+1)
          printf("%d\n",num[i-n+2]);
        else
          for(;l<=2*n-1;l++)
            if(num[0]!=l&&num[1]!=l&&num[2]!=l&&num[3]!=l){
              printf("%d\n",l);
              l++;
              break;
            }
      }
    }
  }
}

Measured memory_bytes: 1408
using System;
class Code_01
{
    public static void Main()
    {
        string Data = Console.ReadLine();
        string[] Datas = Data.Split(' ');
        string sEnemyHP = Datas[0];
        string sPower = Datas[1];
        int Answer = 0;
        int EnemyHP = int.Parse(sEnemyHP);
        int Power = int.Parse(sPower);
        if (EnemyHP >= Power)
        {
            if (EnemyHP % Power != 0)
            {
                Answer++;
            }

            Answer += EnemyHP / Power;
        }
        else
        {
            Answer++;
        }
       
       
        Console.WriteLine(Answer);
    }
}

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

int main(){
  int N;
  cin>>N;
  
  vector<int> A1(N),A2(N);
  
  for(int i=0;i<N;i++)
    cin>>A1.at(i);
  for(int i=0;i<N;i++)
    cin>>A2.at(i);
  
  int res=0;
  
  for(int i=0;i<N;i++){
    int count=0;
    for(int j=0;j<i+1;j++)
      count+=A1.at(j);
    for(int j=i;j<N;j++)
      count+=A2.at(j);
    
    res=max(res,count);
  }
  
  cout<<res;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<l_l,ll> lll;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
ll dp[3010][3010];
int main(){
    ll n;cin>>n;
    vl a(n);rep(i,n)cin>>a[i];
    rep(i,n+2){
        rep(j,n+2){
            dp[i][j]=LINF;
        }
    }
    rep(i,n+1){
        dp[i][i]=0;
    }
    for(int len=1;len<=n;len++){
        rep(i,n){
            if(i+len>n)continue;
            int j=i+len;
            if(len%2==1^n%2==1){
                dp[i][j]=min(dp[i+1][j]-a[i],dp[i][j-1]-a[j-1]);
            }
            else dp[i][j]=max(dp[i+1][j]+a[i],dp[i][j-1]+a[j-1]);
        }
    }
    cout<<dp[0][n]<<endl;
    return 0;
}

Measured memory_bytes: 74176
#abc 166
#b
n,k = map(int, input().split())
ln = list(range(1,n+1))
di = 0
linei = []
for i in range(k):
    di = int(input())
    linei = list(map(int, input().split()))
    for j in linei:
        if j in ln:
            ln.remove(j)
print(len(ln))

Measured memory_bytes: 9192
#include<iostream>
#include<vector>
#include<stack>
#include<cstring>
using namespace std;
typedef long long ll;

ll getAns(string &s) {
  int i=0;
  int n = s.length();
  ll ans = 0;
  ll cl = 0, cr = 0, c1,c2;
  while (i<n && s[i]=='>') {
    ++cl;
    ++i;
  }
  ans += ((cl+1)*cl)/2;
  while (i<n) {
    cl = cr = 0;
    while(i<n && s[i] == '<') {
      ++i;
      ++cl;
    }
    while(i<n && s[i] == '>') {
      ++i;
      ++cr;
    }
    c1 = min(cl,cr);
    c2 = max(cl,cr);
    ans += ((c2+1)*c2)/2;
    ans += ((c1-1)*c1)/2;
  }
  return ans;
}

int main() {
  string s;
  cin>>s;
  cout<<getAns(s)<<endl;
  return 0;
}


Measured memory_bytes: 900
#include <stdio.h>
#include <math.h>

int main() {
	long long int a,b,c;
	scanf("%lld%lld%lld", &a,&b,&c);
	long long int d=c-a-b;
	if((d>0)&&(4*a*b<d*d))
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}


Measured memory_bytes: 128