akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		long[] num = new long[n];
		for(int i=0; i<n; i++){
			num[i] = sc.nextLong();
		}
		
		long ans1 = plusFirst(n,num);
		long ans2 = minusFirst(n,num);
		System.out.println(Math.min(ans1,ans2));		
		return;
	}
	
	public static long plusFirst(int n, long[] num){
		long sum = num[0];
		long ret = 0;
		if(sum <= 0){
			ret = 1-sum;
			sum = 1;
		}
		
		for(int i=1; i<n; i++){
			sum += num[i];
			if(i%2==1 && sum>=0){
				ret += sum+1;
				sum = -1;	
			}else if(i%2==0 && sum<=0){
				ret += 1-sum;
				sum = 1;
			}
		}
		return ret;
	}
	
	public static long minusFirst(int n, long[] num){
		long sum = num[0];
		long ret = 0;
		if(sum >= 0){
			ret = 1+sum;
			sum = -1;
		}
		
		for(int i=1; i<n; i++){
			sum += num[i];
			if(i%2==1 && sum<=0){
				ret += 1-sum;
				sum = 1;	
			}else if(i%2==0 && sum>=0){
				ret += 1+sum;
				sum = -1;
			}
		}
		return ret;
	}
}




class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 24324
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int P = sc.nextInt();
        String S = sc.next();
        long sum=0;
        if(P == 2 || P == 5){
            for(int i=S.length()-1;i>=0;i--){
                int num = S.charAt(i)-'0';
                if(num % P == 0){
                    sum += i+1;
                }
            }
            System.out.println(sum);
            return;
        }


        Map<Integer, Long> mp = new HashMap<>();
        int[] mods = new int[S.length()+1];
        int m10 = 1;
        mods[S.length()] = 0;
        mp.put(0, 1L);
        for(int i=S.length()-1;i>=0;i--){
            int num = S.charAt(i)-'0';
            mods[i] = m10 * num % P + mods[i+1];
            mods[i] %= P;
            m10 *= 10;
            m10 %= P;
            mp.put(mods[i],mp.computeIfAbsent(mods[i], (k)->0L)+1);
        }
        for(Integer t:mp.keySet()){
            sum += mp.get(t)*(mp.get(t)-1)/2;
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 39028
import std.stdio,std.array,std.conv,std.string;
void main(){
  int n=readln().chomp().to!int;
  string k=to!string(n);
  
  int m=0;
  for(int i=0;i<k.length;i++){
    m+=to!int(k[i])-48;
  }
  
  if(n%m==0) writeln("Yes");
  else writeln("No");
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args)  {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if(a<=b){
            System.out.println(a);
        }
        else{
            System.out.println(a-1);
        }
    }
}

Measured memory_bytes: 35672
#include <iostream>
#include <complex>
#include <cstdio>

using namespace std;

typedef complex<double> Point;

const int N = 40;

int n, m;
double dp[N+1][N][N];
double triArea[N][N][N];
double point[N];

double getAreaTri(Point a, Point b, Point c){
  b -= a;
  c -= a;
  return abs(b.real()*c.imag() - b.imag()*c.real()) / 2.0;
}

void makeTable(){
  for(int i=0;i<n;++i){
    for(int j=i+1;j<n;++j){
      for(int k=j+1;k<n;++k){
	triArea[i][j][k] = getAreaTri(Point(cos(2.0*point[i]*M_PI), sin(2.0*point[i]*M_PI)),
				    Point(cos(2.0*point[j]*M_PI), sin(2.0*point[j]*M_PI)),
				    Point(cos(2.0*point[k]*M_PI), sin(2.0*point[k]*M_PI)));
      }
    }
  }
}

double solve(){
  double res = 0.0;
  makeTable();
  fill(dp[0][0], dp[N+1][0], 0.0);
  for(int k=2;k<m;++k){
    for(int i=0;i<n-2;++i){
      for(int j=i+1;j<n-1;++j){
	for(int t=j+1;t<n;++t){
	  dp[k+1][i][t] = max(dp[k+1][i][t], dp[k][i][j] + triArea[i][j][t]);
	}
      }
    }
  }
  for(int i=0;i<n;++i){
    for(int j=0;j<n;++j){
      res = max(res, dp[m][i][j]);
    }
  }
  return res;
}

main(){
  while(cin >> n >> m && (n || m)){
    for(int i=0;i<n;++i){
      cin >> point[i];
    }
    printf("%6f\n", solve());
  }
  return 0;
}

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

	public static void main(String[] args) {
	

		Scanner s = new Scanner(System.in);


		int a = s.nextInt();
		int b = s.nextInt();
		int N = s.nextInt();

		int i=0;
		while(i<N){
			int ss=s.nextInt();
			int f=s.nextInt();
			
			if(!            ((b<=ss)||(f<=a))         ){
				System.out.println(1);
				return;
			}
			
			i = i+1;
		}
		
		System.out.println(0);


	}
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N-1);
    for(int i=0;i<N;i++) cin >> A[i];
    for(int i=0;i<N;i++) cin >> B[i];
    for(int i=0;i<N-1;i++) cin >> C[i];
    auto res = accumulate(B.begin(), B.end(), (int)0);
    for(int i=0;i<N-1;i++){
        if(A[i+1]-A[i]==1) res += C[A[i]-1];
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

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

    ll N; cin >> N;
    ll B[N]; REP(i,N-1) cin >> B[i];

    ll ans = B[0] + B[N-2];
    FOR(i, 1, N-1) {
        ans += min(B[i-1], B[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>


using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)


using namespace std;



int main() {
	int a;
	int b;
	int c;
	int d;
	int e;
	int f;

	cin >> a >> b >> c >> d >> e >> f;

	int min_op = 1000000;
	double max_con = 0;
	int max_total = 0;
	int max_suger = 0;

	for (int ca = 0; ca <= 30; ca++) {
		for(int cb = 0; cb <= 30; cb++) {
			if (ca == 0 && cb == 0) {
				continue;
			}
			for(int cc = 0; cc <= 3000; cc++) {

					int total = ca * 100 * a + cb * 100 * b 
						+ cc * c;

					if (total > f) {
						break;
					}


					if (cc * c > e * (ca * a + cb * b)) {
						break;
					}

					int cd1 = (f - total) / d; 
					int cd2 = (e * (ca * a + cb * b) - cc * c) / d;
					int cd = max(min(cd1, cd2), 0); 

					total += cd * d;

					int suger =  cc * c + cd * d;		

					double cur_con =  (double) suger /  (double) total;
					int op = ca + cb + cc + cd;
					if (cur_con > max_con) {

						max_con = cur_con;
						min_op = op;
						max_total = total;
						max_suger = suger;

					}
					if (cur_con == max_con && min_op > op) {

						max_con = cur_con;
						min_op = op;
						max_total = total;
						max_suger = suger;
					}
				//}
			}

		}
	} 
	cout << max_total << " " << max_suger << endl;

	return 0;

}

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

int search(vector<ll> a, int n, ll key){
    int i = 0;
    a[n] = key;
    while(a[i]!=key) i++;
    return i != n;
}
  

int main(){
  
  
  int n,q;
  ll key;
  cin >> n;
  vector<ll> s(10001);
  rep(i,n) cin >> s[i];
  cin >> q;
  int sum=0;
  rep(i,q){
    cin >> key;
    if(search(s,n,key)) sum++;
  }
  
  cout << sum << endl;
    
  return 0;
}
                                        
  
  
  
     






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

int main() {
	int W,a,b;
	cin>>W>>a>>b;
	int ans=0;
	if((a<=b&b<=a+W)|(a<=b+W&b+W<=a+W))ans=0;
	else{
		ans=min(abs(b-(a+W)),abs((b+W)-a));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt()-1;
        char[] s = sc.next().toCharArray();
        if(s[k] == 'A'){
            s[k] = 'a';
        }else if(s[k] == 'B'){
            s[k] = 'b';
        }else{
            s[k] = 'c';
        }
        System.out.println(new String(s));
        
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 25396
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= c && c <= b){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  std::vector<long> a(87);
  a[0]=2;a[1]=1;
  for (int i = 2; i < 87; i++) {
    /* code */
    a[i]=a[i-1]+a[i-2];
  }
  int n;
  std::cin >> n;
  std::cout << a[n] << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int a ,b;
    cin >> a >> b;
    int max = a-b;
    while (a*b > max or a-b > max or a+b > max){
        if (a*b > max) max = a*b;
        else if (a-b > max) max = a-b;
        else if (a+b > max) max = a+b;
    }
    cout << max;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  for(int i=0;i<N;i++){
    string S;
    cin>>S;
    if(S=="Y"){
      cout<<"Four"<<endl;
      break;
    }
    if(i==N-1&&S=="W")cout<<"Three"<<endl;
    if(i==N-1&&S=="G")cout<<"Three"<<endl;
    if(i==N-1&&S=="P")cout<<"Three"<<endl;
  }
}
    


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll N, K, A[212345];

int main() {

	cin >> N >> K;
	rep(i,N) cin >> A[i];

	double ok=1123456789.0, ng=0;

	while(ceil(ok) != ceil(ng)){
		double mid = (ok + ng) / 2.0;
		ll cnt = 0;
		rep(i, N) {
			cnt += ceil(A[i] / mid) - 1;
		}
		if (cnt <= K) ok = mid;
		else ng = mid;
	}

	cout << (ll)ceil(ok) << endl;

	return 0;
}

Measured memory_bytes: 5300
#include <iostream>
#include <map>
#include <vector>
#include <utility>
using namespace std;

int p[80][80];
map<int, vector<pair<int, int>>> mp;
void judge(int i, int t, int u){
    if(p[t][u]==0){
        mp[i+1].push_back(make_pair(t, u));
        p[t][u]=i+2;
    }
}
void bfs(int i, int x, int y){
    judge(i, x-1, y);
    judge(i, x+1, y);
    judge(i, x, y-1);
    judge(i, x, y+1);
}
int main() {
	int H, W, ans=0; cin >> H >> W;
	string S;
	for(int i=0; i<=H+1; ++i){
	    if(i>H || i==0){
	        for(int j=0; j<=W+1; ++j) p[i][j]=-1;
	    }
	    else{
	        cin >> S;
	        p[i][0]=p[i][W+1]=-1;
	        for(int j=0; j<W; ++j){
	            if(S[j]=='#') p[i][j+1]=-1;
	            else ++ans;
	        }
	    }
	}
	mp[0].push_back(make_pair(1, 1));
	p[1][1]=1;
	int h, w;
	for(int i=0; mp[i].size()>0; ++i){
	    mp[i+1].clear();
	    for(int j=0; j<mp[i].size(); ++j){
	        h=mp[i][j].first, w=mp[i][j].second;
	        if(h==H && w==W){
	            cout << ans-p[h][w] << endl;
	            return 0;
	        }
	        bfs(i, h, w);
	    }
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a>=-1000 && a<=1000 && b>=-1000 && b<=1000)
    {
        if(a>b)
        {
            printf("a > b\n");
        }
        else if(a<b)
        {
            printf("a < b\n");
        }
        else
        {
            printf("a == b\n");
        }

    }
    return 0;
}

Measured memory_bytes: 1796
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
   int n;
   cin >> n;
   
   vector<pair<string,int>> st(n);
   rep(i,n)
   {
      cin >> st[i].first>>st[i].second;
   }
   string s;
   cin >> s;
   int ans = 0;
   bool is = false;
   rep(i,n)
   {

      if(is)
      {
         ans += st[i].second;
      }
      if(st[i].first==s)is= true;
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 101

int main(){
  int num,i,j,k,v,list[N][N];
  
  scanf("%d",&num);
  
  for(i=1; i<=num; i++){
    for(j=1; j<=num; j++){
      list[i][j] = 0;
    }
  }

  for(i=1; i<=num; i++){
    scanf("%d%d",&k,&j);
    for(j; j>0; j--){
      scanf("%d",&v);
      list[k][v] = 1;
    } 
  }

  for(i=1; i<=num; i++){
    for(j=1; j<num; j++){
      printf("%d ",list[i][j]);
    }
    printf("%d\n",list[i][j]);
}

  return 0;
}

Measured memory_bytes: 632
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int N;
int A[2005];
vector <int> G[2005];
vector <int> V[2005];
bool Use[2005];
void Read()
{
    cin >> N;
    for(int i = 1; i <= N; i++)
        cin >> A[i];
    sort(A + 1, A + N + 1);
}
int GCD(int a, int b)
{
    int r = a % b;
    while(r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
void precalcG()
{
    for(int i = 1; i <= N; i++)
    {
        for(int j = i + 1; j <= N; j++)
        {
            if(GCD(A[i], A[j]) != 1)
            {
                G[i].push_back(j);
                G[j].push_back(i);
            }
        }
    }
    for(int i = 1; i <= N; i++)
    {
        G[0].push_back(i);
    }
    for(int i = 1; i <= N; i++)
    {
        sort(G[i].begin(), G[i].end());
    }
}
vector <int> Merge(vector <int> a, vector <int> b)
{
    int i = 0, j = 0;
    vector <int> res;
    while(i < a.size() && j < b.size())
    {
        if(a[i] > b[j])
        {
            res.push_back(a[i]);
            ++i;
        }
        else
        {
            res.push_back(b[j]);
            ++j;
        }
    }
    while(i < a.size())
    {
        res.push_back(a[i]);
        ++i;
    }
    while(j < b.size())
    {
        res.push_back(b[j]);
        ++j;
    }
    return res;
}
void DFS(int node, int father)
{
    Use[node] = 1;
    for(int i = 0; i < G[node].size(); i++)
    {
        int neighb = G[node][i];
        if(neighb == father)
            continue;
        if(Use[neighb] == 1)
            continue;
        DFS(neighb, node);
        V[node] = Merge(V[node], V[neighb]);
    }
    reverse(V[node].begin(), V[node].end());
    V[node].push_back(node);
    reverse(V[node].begin(), V[node].end());
}

int main()
{
    Read();
    precalcG();
    DFS(0, -1);
    for(int i = 1; i < V[0].size(); i++)
    {
        cout << A[V[0][i]] << " ";
    }
    cout << "\n";
    return 0;
}


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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using P = pair<int,int>;

// code starts
int main()
{
  int a,b,c;
  int k;
  cin >> a >> b >> c >> k;
  int t = 0;
  while(a >= b)
  {
    b *= 2;
    t++;
  }
  while(b >= c)
  {
    c *= 2;
    t++;
  }
  if(t <= k) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int ans = 0;
	
		int a;
		cin >> a;
		int b, c, d;
		b = a / 100;
		c = (a / 10)%10;
		d = a % 10;
		if (b == 1) ans++;
		if (c == 1) ans++;
		if (d == 1) ans++;
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[],int n,int left, int mid, int right) {
  int n1 = mid -left;
  int n2 = right - mid;
  for(int i=0;i<n1;i++) L[i] = A[left + i];
  for(int i=0;i<n2;i++) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  int i=0, j=0;
  for(int k=left; k<right; k++) {
    cnt++;
    if(L[i]<=R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[],int n,int left,int right) {
  if(left+1 < right) {
    int mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int main(void) {
  int A[MAX], n, i;
  cnt = 0;

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

  mergeSort(A, n, 0, n);
  for(i=0;i<n;i++) {
    if(i)cout << " ";
    cout << A[i];
  }
  cout << endl;

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 6984
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    string n;
    cin >> n;
    bool cond = false;
    for (char c : n) {
        if (c == '7') {
            cond = true;
        }
    }
    cout << (cond ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n;
	cin >> n;
	string s;
	cin >> s;
	int r[n], g[n], b[n];
	for(int i = 0; i < n; i++) {
		if(i == 0) {
			r[i] = (s[i] == 'R');
			g[i] = (s[i] == 'G');
			b[i] = (s[i] == 'B');
		}
		else {
			r[i] = r[i - 1] + (s[i] == 'R');
			g[i] = g[i - 1] + (s[i] == 'G');
			b[i] = b[i - 1] + (s[i] == 'B');
		}
	}
	int ans = 0;
	for(int j = 1; j < n - 1; j++) {
		for(int k = j + 1; k < n; k++) {
			if(s[j] != s[k]) {
				set<char> st;
				st.insert(s[j]);
				st.insert(s[k]);
				if(st.find('R') == st.end()) {
					ans += r[j - 1];
					if(2 * j - k >= 0 && s[2 * j - k] == 'R') {
						ans--;
					}
				}
				else if(st.find('G') == st.end()) {
					ans += g[j - 1];
					if(2 * j - k >= 0 && s[2 * j - k] == 'G') {
						ans--;
					}
				}
				else {
					ans += b[j - 1];
					if(2 * j - k >= 0 && s[2 * j - k] == 'B') {
						ans--;
					}
				}
			}
		}
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 3752
// AOJ 0311: Kaguya
// 2017.10.31

#include <stdio.h>
#include <math.h>

#define M_PI 3.1415926535897932384626433832795

#define dt 0.01

int main()
{
	double t, m, t_end;
	double dR, dTm, dTk, dWm0, dWm, dWk, ans;
	double cm, sm, ck, sk, xm, ym, zm, xk, yk, zk, xk_leng2, dot, d, s; 

	scanf("%lf %lf", &m, &t_end);
	dR   = 1800.0; 		//????????????
	dTm  = 380000.0; 		//????????¬??¢??????
	dTk  = dR + 100.0; 	//??????????????¬??¢??????
	dWm0 = m*M_PI/180.0; 
	dWm  = 2.0*M_PI/(2500000/60.0);
	dWk  = 2.0*M_PI/(120.0); 
	for (ans = 0, t = 0; t + 0.5*dt < t_end; t += dt) {
		cm = cos(dWm * t + dWm0);
		sm = sin(dWm * t + dWm0);
		ck = cos(dWk * t);
		sk = sin(dWk * t);
		xm = dTm*cm;
		ym = dTm*sm;
		zm = 0.0;
		xk = xm - dTk*sk; 
		yk = ym; 
		zk = zm + dTk*ck; 
		xk_leng2 = xk*xk + yk*yk + zk*zk; 
		dot = xk*xm + yk*ym + zk*zm; 
		d = dot*dot - xk_leng2*(dTm*dTm - dR*dR); 
		if (d > 0.0) {
			s = (dot + sqrt(d))/xk_leng2;
			if (s < 1.0) ans += dt;
		}
	}
	printf("%lf\n", ans);
}

Measured memory_bytes: 2112
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>

using namespace std;
typedef long long ll;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if ((c>=a)&&(c<=b))cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int[] l = {a,b,a+b};
        for (int i:l) {
            if (i%3==0) {
                System.out.println("Possible");
                sc.close();
                return;
            }
        }
        System.out.println("Impossible");
        sc.close();
    }
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

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

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, l;
    cin >> n >> l;
    vi a(n);
    rep(i, n) a[i] = l + i;
    int s = 0;
    rep(i, n) s += a[i];
    int ans = 1e9;
    rep(i, n) {
        int t = s - a[i];
        if (abs(t-s) < abs(ans-s)) ans = t;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine();
        String[] inputArray = input.split(" ");
 
        if(inputArray.length == 2){
            int a = Integer.parseInt(inputArray[0]);
            int b = Integer.parseInt(inputArray[1]);
            if(a < b){
                System.out.println("a < b");
            }
            else if(b < a){
                System.out.println("a > b");
            }
            else if(a == b){
                System.out.println("a == b");
            }
        }
        else{
            System.out.println("2つの整数を入力してください");
        }
    }
}


Measured memory_bytes: 26244
#include <iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1<<21);

enum Color {
  WHITE, GRAY, BLACK
};

int M[MAX][MAX];
int d[MAX];
int p[MAX];
Color color[MAX];
int n;

void init() {
  for (int i = 0; i < n; i++) {
    color[i] = WHITE;
    d[i] = INFTY;
  }
}

void prim() {
  init();
  d[0] = 0;
  p[0] = -1;

  while (true) {
    int mincost = INFTY;
    int u;
    for (int i = 0; i < n; i++) {
      if (color[i] != BLACK && d[i] < mincost) {
        mincost = d[i];
        u = i;
      }
    }
    if (mincost == INFTY) break;

    color[u] = BLACK;
    for (int v = 0; v < n; v++) {
      if (M[u][v] != -1 && color[v] != BLACK) {
        if (M[u][v] < d[v]) {
          d[v] = M[u][v];
          p[v] = u;
          color[v] = GRAY;
        }
      }
    }
  }
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> M[i][j];
    }
  }
  prim();
  int result = 0;
  for (int i = 0; i < n; i++) {
    result += d[i];
  }
  cout << result << endl;
  return 0;
}



Measured memory_bytes: 3136
#include <iostream>
#include <string>

#define NONE "UNRESTORABLE"

using namespace std;

int main()
{
    string S, S_, T;

    cin >> S_ >> T;

    int SLen = S_.length();

    int lim = S_.length() - T.length();
    int TLen = T.length();
    S = NONE;
    for (int i = 0; i <= lim; i++)
    {
        string s = S_;
        s.replace(i, TLen, T);
        bool isVlaid = true;
        for (int j = 0; j < SLen; j++)
        {
            if (S_[j] != '?' && S_[j] != s[j])
            {
                isVlaid = false;
                break;
            }
        }

        if (isVlaid == true && (S == NONE || s < S))
        {
            S = s;
            //cout << S << endl;
        }
    }

    std::replace(S.begin(), S.end(), '?', 'a');

    cout << S << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <functional>
#include <cmath>
#include <typeinfo>

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> r(n);

	for (int i = 0; i < n; ++i) cin >> r.at(i);
	
	int maxv = -2000000000;
	int minv = r.at(0);

	for (int i = 1; i < n; ++i) {
		maxv = max(maxv, r.at(i) - minv);
		minv = min(minv, r.at(i));
	}

	cout << maxv << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10, mod = 1e9 + 7;
char s[N];
int a[N],n;
int main(){
    scanf("%d%s",&n,s);
    for(int i=2*n-1;i>=0;i--){
        a[i] = (s[i]=='B')^((2*n-1-i)&1);
    }
//    for(int i=0;i<2*n;i++) cout<<a[i]; cout<<endl;
    int ans = 1, l = 0, r = 0;
    for(int i=2*n-1;i>=0;i--){
        if(a[i]==0){
            ans = 1ll * ans * max(r-l,0) % mod;
        }
        l += 1 - a[i], r += a[i];
    }
    if(l!=r) ans = 0;
    while(n){
        ans = 1ll * ans * n % mod;
        n--;
    }
    cout<<ans<<endl;
}


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

using namespace std;

int main()
{
	int r, c;
	cin >> r >> c;
	vector<vector<int>> sheet(r + 1, vector<int>(c + 1));

	for (int row = 0; row < r; row++){
		for (int column = 0; column < c; column++){
			cin >> sheet[row][column];
		}
	}

	for (int row = 0; row < r; row++) {
		sheet[row][c] = 0;
		for (int column = 0; column < c; column++) {
			sheet[row][c] += sheet[row][column];
		}
	}

	for (int column = 0; column < c + 1; column++) {
		sheet[r][column] = 0;
		for (int row = 0; row < r; row++) {
			sheet[r][column] += sheet[row][column];
		}
	}

	for (int row = 0; row < r + 1; row++) {
		for (int column = 0; column < c + 1; column++) {
			if (column) cout << " ";
			cout << sheet[row][column];
		}
		cout << endl;
	}

	return 0;
}



Measured memory_bytes: 3128
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,p,a,sum=0,k,b,c,d,cnt=0,q,l,r;

      bool flag=false;

      string str;


     cin>>n;

     double aa;

     double t,m;


     cin>>t>>m;

     double ans=0.0;

     ll pos=-1;

     for(i=1; i<=n; i++)
     {
         cin>>a;


         double s=t-(a*.006);

         double dis=abs(m-s);

        // cout<<dis<<endl;

         if(i==1)
            ans=dis,pos=i;

         else if(ans>dis)
         {
             ans=dis;
             pos=i;
         }

     }

     cout<<pos<<endl;








}



Measured memory_bytes: 3696
#include <stdio.h>

int main(void)
{
	int i;
	//tempはデータの入れ替え用、remainderは剰余を格納
	int x, y, temp, remainder;

	//x、yを入力
	scanf("%d %d", &x, &y);

	//x >= yにする
	if(x < y){
		temp = x;
		x = y;
		y = temp;
	}

	//ユークリッドの互除法
	while(x % y != 0){
		remainder = x % y;
		x = y;
		y = remainder;
	}

	//結果を出力
	printf("%d\n", y);

	return 0;
}


Measured memory_bytes: 2112
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
int main(void){
    char s[11],t[12];
    scanf("%s%s",s,t);
    int a=strlen(s);
    if(strncmp(s,t,a)==0)
    printf("Yes");
    else
    {
        printf("No");
    }
    
    return 0;
}

Measured memory_bytes: 1752
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int A = in.nextInt();
		int B = in.nextInt();
		
		if ( 13 <= A ) {
			System.out.println(B);
		} else if (A <= 5){
			System.out.println(0);
		} else {
			System.out.println(B/2);
		}

		

		in.close();
	}
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
bool Check(string input){
    
    if(input.size()%2 == 1){
        return false;
    }
    else{
        int len = input.size() / 2;
        for(int i=0;i<len;i++){
            if(input[i] != input[i+len]) return false;
        }
        return true;
    }
}
int main(void){
    
 string S;
 cin >> S;
 int N = S.size();
 
 for(int i=N-1;i>=0;i--){
    if(Check(S.substr(0,i))){cout << S.substr(0,i).size() << endl; return 0;}
 } 
}

Measured memory_bytes: 3660
#create date: 2020-07-11 21:18

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def popcount(m):
    res = 0
    while m:
        if m & 1:
            res += 1
        m //= 2
    return res
def f(m):
    cnt = 0
    while m:
        #print("test", m)
        m = m % popcount(m)
        cnt += 1
    return cnt

def main():
    n = ni()
    x = ns()
    pop0 = x.count("1") + 1
    pop1 = x.count("1") - 1
    y0 = 0; y1 = 0
    for i, xi in enumerate(x):
        r = n - i - 1
        if xi == "1":
            y0 += pow(2, r, pop0)
            y0 %= pop0
            if pop1 != 0:
                y1 += pow(2, r, pop1)
                y1 %= pop1

    for i, xi in enumerate(x):
        r = n - i - 1
        if xi == "0":
            m = (y0 + pow(2, r, pop0)) % pop0
            print(f(m) + 1)
        else:
            if pop1 == 0:
                print(0)
                continue
            m = (y1 - pow(2, r, pop1)) % pop1
            print(f(m) + 1)

if __name__ == "__main__":
    main()

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> vec_in (H, vector<char>(W));//入力配列
  vector<vector<char>> vec_su (H+2, vector<char>(W+2,'#')); //一回り大きい配列．

  //入力値
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      cin >> vec_su.at(i+1).at(j+1);
    }
  }
  
  //出力
  for (int i=0; i<H+2; i++) {
    for (int j=0; j<W+2; j++) {
      cout << vec_su.at(i).at(j);
    }
    cout << endl;
  }
}

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

struct Block {
  Block() : xl(0), xr(0), m(0), mg(0) {}

  int xl, xr;
  int m, mg;
};

void check(Block &b, vector<vector<char> > &q,
           int y, int x, char n, int ly) {
  if (q[y][x] == '.') {
    return;
  }

  if ((q[y][x] & 191) != n && ly == y + 1) {
    b.xl = min(x, b.xl);
    b.xr = max(x, b.xr);
    return;
  }

  if (q[y][x] & 64) {
    return;
  }

  if (q[y][x] != n && ly == y - 1) {
    Block c;
    c.xl = c.xr = x;
    check(c, q, y, x, q[y][x], y);

    double g = (double)c.mg / c.m - 0.5;
    if (g <= c.xl - 1 || g >= c.xr) {
      throw -1;
    }

    b.m += c.m;
    b.mg += c.mg;

    return;
  }

  if (q[y][x] != n) {
    return;
  }

  b.m++;
  b.mg += x;
  q[y][x] |= 64;

  check(b, q, y, x - 1, n, y);
  check(b, q, y, x + 1, n, y);
  check(b, q, y - 1, x, n, y);
  check(b, q, y + 1, x, n, y);
}

int main() {
  int w, h;
  while (cin >> w >> h, w != 0) {
    vector<vector<char> > q(h + 2);

    for (int i = 0; i < h + 2; i++) {
      q[i].resize(w + 2);
      fill(q[i].begin(), q[i].end(), '.');
    }

    for (int x = 1; x <= w; x++) {
      q[0][x] |= 64;
    }

    for (int y = h; y >= 1; y--) {
      for (int x = 1; x <= w; x++) {
        cin >> q[y][x];
      }
    }

    Block dummy;
    for (int x = 1; x <= w; x++) {
      if (q[1][x] != '.') {
        try {
          check(dummy, q, 1, x, '-', 0);
          cout << "STABLE" << endl;
        } catch (int i) {
          cout << "UNSTABLE" << endl;
        }
        break;
      }
    }
  }

  return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001001001001ll;

int N,M;
int A[1111],b[1111];

signed main(){
	cin>>N>>M;
	rep(i,M){
		int n;
		cin>>A[i]>>n;
		rep(j,n){
			int c;cin>>c;c--;
			b[i]|=1ll<<c;
		}
	}

	vint dp(1<<N,INF);
	dp[0]=0;
	rep(i,M){
		for(int j=(1ll<<N)-1;j>=0;j--){
			chmin(dp[j|b[i]],dp[j]+A[i]);
		}
	}
	int ans=dp[(1ll<<N)-1];
	if(ans==INF){
		cout<<"-1"<<endl;
	}
	else{
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> c(n);
  for(int i=0; i<n; i++) {
    cin >> v.at(i);
  }
  for(int i=0; i<n; i++) {
    cin >> c.at(i);
  }
  int x,ans=0;
  for(int i=0; i<n; i++) {
    x = v.at(i)-c.at(i);
    if(0 < x) {
      ans += x;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include <stdio.h>
int main(void)
{
    int x, i = 1;
    do
    {
        scanf("%d", &x);
        if(x == 0)
        {
            break;
        }
        printf("Case %d: %d\n", i, x);
        i++;
    }
    while(x != 0);
    return 0;
}


Measured memory_bytes: 1980
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        long N = scanner.nextLong();
        int n = (int)Math.sqrt(N);
        int X = 0;
        
        for(int i=1; i<=n; i++){
            if(N%i==0){
                X = i;
            }
        }
        
        N /= X;
        
        int valLenN = String.valueOf(N).length();
        int valLenX = String.valueOf(X).length();
        
        if(valLenX<=valLenN){
            System.out.println(valLenN);
        }else{
            System.out.println(valLenX);
        }
        
        
    }
}


Measured memory_bytes: 35688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=a;i<b;i++)

ll mod = 998244353;
class SegmentTree {
private:
    int n;
    vector<ll> node, lazy;
    vector<bool> flag_lazy;
public:
    SegmentTree(int N) {
        n = 1;
        while (n < N) n *= 2;
        node.resize(2 * n - 1, 0);
        lazy.resize(2 * n - 1, 0);
        flag_lazy.resize(2 * n - 1, false);
    }

    void update(int i, int l, int r) {
        if (!flag_lazy[i]) return;
        node[i] += lazy[i];
        node[i] %= mod;
        if (r - l > 1) {
            lazy[2 * i + 1] += lazy[i] / 2;
            lazy[2 * i + 2] += lazy[i] / 2;
            flag_lazy[2 * i + 1] = true;
            flag_lazy[2 * i + 2] = true;
        }
        flag_lazy[i] = false;
        lazy[i] = 0;
    }

    void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        update(k, l, r);
        if (b <= l || r <= a) return;
        
        if (a <= l && r <= b) {
            lazy[k] += ((r - l) * (x));
            flag_lazy[k] = true;
            update(k, l, r);
        } else {
            add(a, b, x, 2 * k + 1, l, (l + r) / 2);
            add(a, b, x, 2 * k + 2, (l + r) / 2, r);
            node[k] = (node[2 * k + 1] + node[2 * k + 2]) % mod;
        }
    }

    ll query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        update(k, l, r);
        if (b <= l || r <= a) return 0;        
        if (a <= l && r <= b) return node[k] % mod;

        ll sum_l = query(a, b, 2 * k + 1, l, (l + r) / 2);
        ll sum_r = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return (sum_l + sum_r) % mod;
    }

    void disp() {
        for (int i : node) {
            cout << i << " ";
        }
        cout << "\n";
    }

};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int L[K], R[K];
    for (int i = 0; i < K; i++) {
        cin >> L[i] >> R[i];
    }

    SegmentTree st(N + 1);
    st.add(1, 2, 1);
    
    for (int i = 1; i < N; i++) {
        ll x = st.query(i, i + 1);
        for (int j = 0; j < K; j++) {
            int l = i + L[j];
            int r = i + R[j] + 1;
            
            //st.add(min(l, N + 1), min(r, N + 1), x);
            st.add(l, r, x);
        }
        //cout << x << "\n";
    }

    cout << st.query(N, N + 1) << "\n";

    return 0;
}

Measured memory_bytes: 11384
#include <stdio.h>

main(){
  int i,j=0;
  char b[21],a[21];
  scanf("%s",b);
  j=strlen(b);
   for(i=0;i<j;i++){
     a[i]=b[j-i-1];
}
   a[j]='\0';
   printf("%s\n",a);
return 0; 
}

Measured memory_bytes: 0
from math import floor,ceil,sqrt,factorial,log
import fractions
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

def lcm(x, y):
    return (x*y) // fractions.gcd(x,y)

a, b = MI()

print(lcm(a,b))

Measured memory_bytes: 13664
#include <bits/stdc++.h>
using namespace std;
char s[200002];
int main(){
    int n, cnt = 0;
    scanf("%d", &n);
    scanf("%s", s+1);
    for(int i=1;i<=n;i++){
        if(s[i] == 'W') cnt++;
    }
    int ans = 0;
    for(int i=n;i>=n-cnt+1;i--){
        if(s[i] == 'R') ans++;
    }
    printf("%d\n", ans);
}

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

int main() {
    int n,l;
    cin>>n>>l;int a[n],s=0,su=0,mi=100000000,m;
    for(int i=0;i<n;i++){
    a[i]=l+i;s+=a[i];su+=a[i];}
    for(int i=0;i<n;i++)
    {
        if(abs(a[i])<=mi)
        {
            mi=abs(a[i]);
            m=i;
        }
    }
    cout<<s-a[m]<<endl;
	return 0;
}

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

int main()
{
    ll n;
    cin>>n;
    ll ans=0,i=0;
    while(n)
    {
        ans += pow(2,i);
        i++;
        n = n>>1;
    }
    cout<<ans<<endl;
}

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

int main() {
  ll X,N;
  cin>>X>>N;
  ll a[102];
  rep(i,102){
    a[i]=0;
  }
  rep(i,N){
    ll a1;
    cin>>a1;
    //a[i]=0;
    a[a1]=1;
    
  }
  for(int i=0;i<100;i++){
    if(a[X-i]==0){
      cout<<X-i;
      break;
    }
    if(a[X+i]==0){
      cout<<X+i;
      break;
    }
    
  }
  
}



Measured memory_bytes: 3592
#include<iostream>

using namespace std;

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

  bool flag = false;
  for (int i = 0; i < S.length(); i++) {
    if (i % 2 == 0) {
      if (S[i] == 'L') {
        flag = true;
      }
    } else {
      if (S[i] == 'R') {
        flag = true;
      }
    }
  }

  if (flag) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 100000000000000009
#define MOD 1000000007
#define int long long
using P = pair<int,int>;
signed main(){
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  rep(i,tx-sx) cout << 'R';
  rep(i,ty-sy) cout << 'U';
  rep(i,tx-sx) cout << 'L';
  rep(i,ty-sy) cout << 'D';
  cout << 'D';
  rep(i,tx-sx+1) cout << 'R';
  rep(i,ty-sy+1) cout << 'U';
  cout << 'L';
  cout << 'U';
  rep(i,tx-sx+1) cout << 'L';
  rep(i,ty-sy+1) cout << 'D';
  cout << 'R';
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF=0x3fffffff;
const ll MOD=1000000007;
const ll MODD=998244353;
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
 
 
int main()
{
  int a;
  cin >> a;
  cout << 3*a*a << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
typedef pair<int, int> P;

typedef long long ll;
const int MOD = 1000000007;

    bool cmp(const P &A, const P &B){
        return (A.second < B.second);
    }


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

int main(){  
    int N,K;
    cin >> N >> K;
    if((N-1)*(N-2)/2 < K) {
        cout << -1;
        return 0;
    }else{
        int M = N - 1 + ((N-2)*(N-1)/2 - K);
        cout << M << "\n";
        int i = 2;
        while(M > 0 && i <= N){
            cout << "1 " << i << "\n";
            M--;
            i++;
        }
        int index = 1;
        while(M > 0){
            i = 2;
            while(M > 0 && i+index <= N){
                cout << i << " " << i+index << "\n";
                i++;
                M--;
            }
            index++;
        }
    }
}


Measured memory_bytes: 256