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

using namespace std;

template<typename T>
class SegTree {
public:
    explicit SegTree(int n, T def) : N(calcN_(n)), def(def), mVal(2*calcN_(n)-1, def) {}
    void update(int idx, T value){
        int i = N + idx - 1;
        update_(mVal[i], value);
        while(i > 0){
            i = (i-1)/2;
            mVal[i] = operate(mVal[2*i+1], mVal[2*i+2]);
        }
    }
    T get(int l, int r){
        l = max(0, l);
        r = min(N, r);
        int offset = N;
        T res = def;
        while(offset > 0){
            if(l >= r) break;
            if(l&1){ res = operate(res, mVal[offset+l-1]); l++; }
            if(r&1){ res = operate(res, mVal[offset+r-2]); }
            l /= 2;
            r /= 2;
            offset /= 2;
        }
        return res;
    }
private:
    int calcN_(int n){
        int res = 1;
        while(res < n) res *= 2;
        return res;
    }
    void update_(T& data, T val) { data = val; }
    T operate(T a, T b) { return min(a, b); }
    const int N;
    const T def;
    vector<T> mVal;
};

int main(){
    int n, q;
    while(cin >> n >> q){
        const int INF = 0x7FFFFFFF;
        SegTree<int> seg(n, INF);
        for(int i=0;i<q;i++){
            int c, x, y; cin >> c >> x >> y;
            if(c == 0){
                seg.update(x, y);
            } else {
                cout << seg.get(x, y+1) << endl;
            }
        }
    }
}



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

public class Main {
	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		int n = in.readInt(); 
		int m = in.readInt();
	    pair p[] = new pair[n]; 
	    for(int i = 0; i<n; i++) {
	    	long a = in.readLong();
	    	long b = in.readLong();
	    	p[i] = new pair(a,b);
	    }
	    Arrays.sort(p);
	    long sum = 0; 
	    for(pair i : p) {
	    	if(i.second >= m) {
	    		sum += (m * i.first); 
	    		break; 
	    	}
	    	else {
	    		m -= i.second; 
	    		sum += (i.second * i.first); 
	    	}
	    }
	    System.out.println(sum); 
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}
class pair implements Comparable<pair> {
	long first; 
	long second; 

	pair(long a, long b) {
		this.first = a;
		this.second = b;
	}
    public long getFirst() {
    	return first; 
    }
    public long getSecond() {
    	return second; 
    }
	public String toString() {
		return first + " " + second;
	}

	public boolean equals(Object o) {
		return o instanceof pair && ((pair) o).first == first && ((pair) o).second == second;
	}

	public int compareTo(pair a) {
		return Long.compare(first, a.first); 
	}
}

Measured memory_bytes: 31276
#include <iostream>
#define int long long

using namespace std;

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

  int a,b,k,i;
  cin >> a >> b >> k;
  for (i = min(a,b); i >= 1; i--) {
    if (a%i == 0 && b%i == 0) {
      k--;
    }
    if (k == 0) {
      cout << i << "\n";
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
from collections import *
from functools import *
from itertools import *
import operator as op

def main():
    #n = int(input())
    n, m = map(int, input().split())
    #xs = list(map(int, input().split()))
    #xs = [ input().split() for _ in range(n) ]
    xs = [ list(map(int, input().split()))[1:] for _ in range(m) ]
    ps = list(map(int, input().split()))
    def pick(i, ofst):
        return (i >> ofst) & 1
    ans = 0
    for i in range(2**n):
        if any([ p ^ reduce(op.xor, [ pick(i, x-1) for x in xs[j]]) for j, p in enumerate(ps) ]):
            pass
        else:
            ans += 1
            pass
        pass
    print(ans)
    pass


if __name__ == "__main__":
    main()
    pass


Measured memory_bytes: 3828
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
const int inf=INT_MAX;
const int nmax=2e5+5;
const int mod=1e9+7;
typedef long long ll;
using namespace std;
int n,i;
ll a[nmax],sum,sum1,mn=inf;
int main() 
{
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>n;
    for(i=1;i<=n;i++)cin>>a[i],sum+=a[i];
    for(i=1;i<n;i++)
	{
		sum1+=a[i];
		mn=min(mn,abs(sum-2*sum1));
	}
	cout<<mn<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std;
using ll = long long;

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

int main(){
    ll N;
    cin >> N;
    ll A[N];
    for(ll i=0; i<=N; i++){
        cin >> A[i];
    }
    ll answer = A[0];
    for(ll j=1; j<N; j++){
        answer = gcd(answer,A[j]);
    }
    cout<< answer <<endl;
    return 0 ;
}

Measured memory_bytes: 1024
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Sun Dec  9 21:38:16 2018
//
package main

import "fmt"

func gcd(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

func main() {
	var N int
	fmt.Scan(&N)

	var ans int
	for i := 0; i < N; i++ {
		var a int
		fmt.Scan(&a)
		ans += a - 1
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
int main() {
  int n;
  cin >> n;
  Bint sum = 1;
  long long m = 1e18;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }

  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    sum *= a.at(i);

    if (sum > m) {
      cout << -1;
      return 0;
    }
  }
  cout << sum;
  return 0;
}


Measured memory_bytes: 4108
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define _Pi 3.1415926535
#define _MOD = 1e9+7;
using namespace std;
typedef long long ll;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> h(100000);
    rep(i,n) cin >> h[i];
    
    vector<int> cost(100000,INT_MAX);
    cost[0] = 0;

    for(int i = 0; i < n; ++i){
       for(int j = 1; j <= k; ++j){
           cost[i+j] = min(cost[i+j],cost[i]+abs(h[i+j]-h[i]));
       }
    }

    cout << cost[n-1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli x,a;
    cin>>x>>a;
    out((x<a?0:10));
}

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

ll a, b, c, d;

inline ll read(){
	ll s = 0, w = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9'){
		if (ch == '-') w *= -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9'){
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * w;
}

inline ll gcd(ll n, ll m){
	return m ? gcd(m, n % m) : n;
}

inline void work(){
	a = read(), b = read(), c = read(), d = read();
	ll lcm = c * d / gcd(c, d);
	printf("%lld\n", (b - a + 1) - (b / c - (a - 1) / c) - (b / d - (a - 1) / d) + (b / lcm - (a - 1) / lcm));
}

int main(){
	work();
	return 0;
}

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

namespace ABC083C {
    class Program {
        static void Main(string[] args) {
            long[] input = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
            long X = input[0];
            long Y = input[1];
            int answer = 0;
            while(X <= Y) {
                answer++;
                X = X * 2;
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13268
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main {
    public static void main(String[] args) throws Exception{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// ??\????????????????????????
            String line = null;
            while((line = br.readLine()) != null){
            	String lines[] = line.split(" ");
            	int x = Integer.parseInt(lines[0]);
            	int y = Integer.parseInt(lines[1]);
            	if(x == 0 && y == 0)break;
            	System.out.println(y>x ? x+" "+y : y+" "+x);
            }
    }
}

Measured memory_bytes: 27180
#include<bits/stdc++.h>
using namespace std;
int main(){
  long int k,n;
  cin>>k>>n;
  long int a[n];
  for(int i=1;i<=n;i++){
  	cin>>a[i];
}
long int mx = 0;
    for(int i = 1; i < n; ++i) {
        long int nw = a[i + 1] - a[i];
        if(mx < nw) mx = nw;
    }
 
    long int nw = a[1] + k- a[n];
    if(mx < nw) mx = nw;
 
    cout << k - mx << "\n";
 
    return 0;
}

Measured memory_bytes: 1792
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

long long a;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> a;
    cout << a + a * a + a * a * a << "\n";
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int a[n];
    int i;
    for(i=0;i<n;i++)
      cin>>a[i];
    sort(a,a+n);
    double avg=a[0];
    for(i=1;i<n;i++){
        avg = (avg+a[i])/2;
    }
    cout<<avg<<endl;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int &i: a) cin >> i;
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    for(int i = 2; i < n; i++) {
        int j = 1;
        dp[i] = INT_MAX;
        while (j <= k and (i - j) >= 0) {
            dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
            j++;
        } 
    }
    cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <string>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int a,b,c; cin >> a >> b >> c;
    map <int, int> mp;
    for(int i = 0; ; ++i){
        int tmp = a*i%b;
        if(mp.count(tmp))break;
        else mp[tmp] = 1;
    }
    cout << (mp.count(c) ? "YES" : "NO") << endl; return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main(void){
    int length;
    char *string;
    int k;

    scanf("%d",&length);
    string=(char *)malloc(sizeof(char)*length);
    scanf("%s",string);
    scanf("%d",&k);
    int i;
    for(i=0;i<length;i++){
        if(string[i]!=string[k-1]){
            string[i]='*';
        }
    }
    printf("%s",string);
    return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	static int N;
	static int K;
	static String[] candles;
	static long total = Integer.MAX_VALUE;
	public static void main(String[] args) throws Exception {
//		long startTime = System.currentTimeMillis();
//      String url = Main.class.getResource("").getPath();
//      System.setIn(new FileInputStream(url + "test.txt"));
        BufferedReader bufReader = new BufferedReader(new InputStreamReader(System.in));
        String line = bufReader.readLine();
        String[] lineArr = line.split(" ");
        N = Integer.parseInt(lineArr[0]);
        K = Integer.parseInt(lineArr[1]);
        line = bufReader.readLine();
        candles = line.split(" ");
    	
        double startIndex = -1;
    	
    	//第一个数大于等0
    	if (0 <= Integer.parseInt(candles[0])){
    		total = Integer.parseInt(candles[K-1]);
    	}
    	//第一个数小于0
    	else{
    		if (0 >= Integer.parseInt(candles[candles.length-1])){
    			total = - Integer.parseInt(candles[candles.length - K]);
    		}
    		else{
    			//第一个数小于0， 最后一个数大于0
    			for (int i=1; i<candles.length-1; i++){
    	        	if (0 == Integer.parseInt(candles[i])){
    	        		startIndex = i;
    	        		break;
    	        	}
    				if (Double.parseDouble(candles[i])*Double.parseDouble(candles[i+1]) < 0){
    	        		startIndex = i + 0.5;
    	        		break;
    	        	}
    	        }
    			int begin = (int)(startIndex - K) < 0 ? 0 : (int)(startIndex - K) + 1
    					, end = (int)startIndex + ((startIndex+"").indexOf(".5") > -1 ? K :K-1) > N-1 ? N-1 : (int)startIndex + ((startIndex+"").indexOf(".5") > -1 ? K :K-1);
    			for (int i=begin; i+K-1 <= end; i++){
    				long result = 0;
    				
    				if (i < startIndex && i+K-1 > startIndex){
    					long a = Integer.parseInt(candles[i+K-1]) - 2*Integer.parseInt(candles[i]);
    					long b = 2*Integer.parseInt(candles[i+K-1]) - Integer.parseInt(candles[i]);
    					result = Math.min(a, b);
    				}
    				if (i >= startIndex){
    					result = Integer.parseInt(candles[i+K-1]);
    				}
    				if (startIndex >= i+K-1){
    					result = - Integer.parseInt(candles[i]);
    				}
    				total = Math.min(total, result);
    			}
    		}
    	}
    	System.out.println(total);
//    	long endTime = System.currentTimeMillis();
//      System.out.println(endTime - startTime);
	}
}


Measured memory_bytes: 47316
D[13][3]={{1,0,0},{0,1,0},{0,0,1},{1,1,0},{1,0,1},{0,1,1},{1,-1,0},{1,0,-1},{0,1,-1},{1,1,1},{-1,1,1},{1,-1,1},{1,1,-1}};
M[9][9][9],H[9][9],q[2];main(n,m,p,I,x,y,z,j,c,d,J){for(;scanf("%d%d%d",&n,&m,&p),n;){
	for(memset(M,I=0,sizeof(M)),memset(H,I=0,sizeof(H)),c=1;I++<p;c*=-1){
		scanf("%d%d",&x,&y);
		if(H[x][y]==0)H[x][y]=1;
		M[x][y][z=H[x][y]++]=c;
		for(d=0;d<13;d++){
			for(j=0;j<2;j++)for(q[j]=0;;q[j]+=2*j-1)if(M[x+D[d][0]*q[j]][y+D[d][1]*q[j]][z+D[d][2]*q[j]]!=c)break;
			if(q[1]-q[0]-1>=m){printf(c==1?"Black %d\n":"White %d\n",I);goto next;}
		}
	}
	puts("Draw");
next:
	for(;I++<p;)scanf("%d%d",&x,&y);
}exit(0);}

Measured memory_bytes: 612
import java.util.Scanner;

// bit全探索を用いた解法
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s=sc.next();
        int end=(1<<(s.length()-1));
        long ret=0;
        // bit部分のループ
        for(int i=0;i<end;i++){
            // 式を生成しながら計算
            long tmp=Character.getNumericValue(s.charAt(0));
            for(int j=1;j<s.length();j++){
                // 手前に+を入れる時
                if((i&(1<<(j-1)))>0){
                    ret+=tmp;
                    tmp=Character.getNumericValue(s.charAt(j));
                }
                // +を入れない時
                else{
                    tmp=tmp*10+Character.getNumericValue(s.charAt(j));
                }
            }
            ret+=tmp;
        }
        System.out.println(ret);
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;
const int N_MAX = 100001;
const int modint = 1000000007;

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }

int main() {
  ll a, b,c,d;
  cin >> a >> b >> c >> d;
  ll x[4];
  x[0] = a*c;
  x[1] = a*d;
  x[2] = b*c;
  x[3] = b*d;
  ll ans = max(x[0],max(x[1],max(x[2],x[3])));
  cout << ans << endl;
}



Measured memory_bytes: 3592
#include <cstdio>
#include <iostream>
#include <cmath>

using namespace std;

struct Point {
  double x;
  double y;
};

static void CreateTriangle(const Point& p1, const Point& p2, int n) {
  if (n <= 0)
    return;

  static const double kCos60 = cos(60.0 * M_PI / 180.0);
  static const double kSin60 = sin(60.0 * M_PI / 180.0);

  Point s;
  s.x = (2 * p1.x + p2.x) / 3.0;
  s.y = (2 * p1.y + p2.y) / 3.0;

  Point t;
  t.x = (p1.x + 2 * p2.x) / 3.0;
  t.y = (p1.y + 2 * p2.y) / 3.0;

  Point u;
  const double dx = t.x - s.x;
  const double dy = t.y - s.y;
  u.x = s.x + dx * kCos60 - dy * kSin60;
  u.y = s.y + dx * kSin60 + dy * kCos60;

  CreateTriangle(p1, s, n - 1);
  printf("%f %f\n", s.x, s.y);
  CreateTriangle(s, u, n - 1);
  printf("%f %f\n", u.x, u.y);
  CreateTriangle(u, t, n - 1);
  printf("%f %f\n", t.x, t.y);
  CreateTriangle(t, p2, n - 1);
}

int main() {
  int n;
  scanf("%d", &n);

  Point p1;
  p1.x = 0;
  p1.y = 0;

  Point p2;
  p2.x = 100.0;
  p2.y = 0;

  printf("%f %f\n", p1.x, p1.y);
  CreateTriangle(p1, p2, n);
  printf("%f %f\n", p2.x, p2.y);

  return 0;
}

Measured memory_bytes: 1220
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int n, m, x;
vector<int> c;
vector<vector<int>> a;
vector<int> mm;
int ans = 100000000;
void dfs(int num){
    if(num==n){
        vector<int> t(m);
        int tmp = 0;
        for (int i = 0; i < mm.size(); i++)
        {
            tmp += c[mm[i]];
            for (int j = 0; j < m; j++)
            {
                t[j] += a[mm[i]][j];
            }
        }
        for (int i = 0; i < m; i++)
        {
            if(t[i]<x) tmp = ans;
        }
        ans = min(ans, tmp);
        
        return;   
    }
    for (int i = 0; i < 2; i++)
    {
        if(i){
            mm.push_back(num);
            dfs(num+1);
            mm.pop_back();
        }else{
            dfs(num+1);
        }

    }
    
}
int main() {
    cin >> n >> m >> x;
    c.resize(n);
    a.resize(n);
    for (int i = 0; i < n; i++)
    {
        a[i].resize(m);
        cin >> c[i];
        for (int j = 0; j < m; j++)
        {
            cin >> a[i][j];
        }
    }
    dfs(0);
    if(ans==100000000)ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 3640
a, b, c = map(int, input().split())

sum_out = 0

for i in range(1, a+1):
    d = str(i)
    keta = len(d)

    sum_a = 0
    for j in range(keta):
        sum_a += int(d[j])

    if b <= sum_a & sum_a <= c:
        sum_out += i

print(sum_out)


Measured memory_bytes: 2940
#include<stdio.h>

int main(){
int a,b,c,i,d;

do{

scanf("%d %d %d",&a,&b,&c);

}while(a>b);

for(d=a,i=0;d<=b;d++){

if(c%d==0){i++;}

}

printf("%d\n",i);

return 0;
}

Measured memory_bytes: 596
for(i=require("fs").readFileSync("/dev/stdin","utf8").split(/\s/),j=1;i[0]-j+1;j++){for(a=b=0,k=10;k--;)(l=+i[10*j-k])>a?a=l:l>b?b=l:a=11;console.log(a-11?'YES':'NO')}

Measured memory_bytes: 7644
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

int main(){
  int A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0;
  string st;
  cin >>st;
  A=st.size();
   if(A%2==0){
    for(int i=0;i<A/2;i++){
      if(st[i]!=st[A-i-1]){
        B++;
      }
    }
  }
  else{
    for(int i=0;i<A/2;i++){
      if(st[i]!=st[A-i-1]){
        B++;
      }
    }
  }
 
  cout << B << endl;
  
  return 0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
MAX_count = 0
index = 0
count = 0

while (index < N-1):

    if (H[index] >= H[index+1]):
        count += 1
    else:
        count = 0
    
    index += 1
    MAX_count = max(MAX_count, count)


print(MAX_count)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    string S;cin>>S;
    int L=S.size();
    if(S[0]!='A'){
        cout<<"WA"<<endl;return 0;
    }
    int c_count=0;
    for(int i=2;i<L-1;i++){
        if(S[i]=='C')c_count++;
    }
    if(c_count!=1){
        cout<<"WA"<<endl;return 0;
    }
    for(int i=1;i<L;i++){
        if((S[i]<'a'||'z'<S[i]) && S[i]!='C'){
            cout<<"WA"<<endl;return 0;
        }
    }
    cout<<"AC"<<endl;return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

typedef long long int_type;
const int MAX_N = 1005;
int_type base = 1007;
int_type mod = 1000000007;
vector<int_type> pow1(MAX_N,1);
void pow_init() {
    for(int i=1;i<MAX_N;++i) {
        pow1[i] = pow1[i-1] * base % mod;
    }
}

struct RollingHash {

    vector<int_type> hash;

    RollingHash(){}

    void init(const string &s) {
        int n=s.size();
        hash.assign(n+1,0);
        for (int i=0;i<n;++i) {
            hash[i+1] = (hash[i]+s[i]) * base % mod;
        }
    }

    int_type get(int l, int r) {
        int_type t = (hash[r] - hash[l] * pow1[r-l] % mod + mod) % mod;
        return t; 
    }

};

int main() {
    pow_init();
    int N; cin >> N;
    vector<string> S(N);
    REP(i,N) cin >> S[i];
    REP(i,N) S[i] = S[i] + S[i];
    vector<string> T(2*N);
    REP(i,2*N)REP(j,N) T[i] += S[j][i];
    vector<RollingHash> yoko(N);
    vector<RollingHash> tate(2*N);
    REP(i,N) yoko[i].init(S[i]);
    REP(i,2*N) tate[i].init(T[i]);
    int ans = 0;
    REP(i,N){
        bool flag = true;
        REP(k,N) if(yoko[k].get(i,i+k)!=tate[i+k].get(0,k)) flag = false;
        if(flag) ans ++;
    }
    cout << ans*N << endl;
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
typedef long long int ll;

using namespace std;
const double PI = 3.14159265358979323846;

int main()
{

    ll N, M;

    cin >> N;

    char moji;

    vector<char> jisho(26);

    int moji_count = 0;

    for (moji = 'a'; moji <= 'z'; moji++)
    {

        jisho[moji_count] = moji;

        moji_count++;
    }

    M = N - 1;

    ll unit = 1;

    ll total_unit = 0;

    ll count = 0;

    string kasu;

    while (1)
    {
        unit = unit * 26;
        count++;

        total_unit += unit;

        if (total_unit >= N)
        {

            ll M = N - (total_unit - unit) - 1;

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

                ll b = M % 26;

                kasu.push_back('a' +b);
                M = M / 26;
            }

            break;
        }
    }

    reverse(kasu.begin(), kasu.end());

    cout << kasu << endl;

    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
using namespace std;
int Nr[100001];
int Nm[100001];
int main()
{
	int A, B, M;
	scanf("%d%d%d", &A, &B, &M);
	for (int i = 1; i <= A; i++)
		cin >> Nr[i];
	for (int i = 1; i <= B; i++)
		cin >> Nm[i];
	int min = 1000000000;
	for (int i = 1; i <= M; i++)
	{
		int x, y, a;
		cin >> x >> y >> a;
		if (min > Nr[x] + Nm[y] - a)
			min = Nr[x] + Nm[y] - a;
	}
	sort(Nr + 1, Nr + 1 + A);
	sort(Nm + 1, Nm + 1 + B);
	if (min > Nr[1] + Nm[1])
		min = Nr[1] + Nm[1];
	cout << min;
	return 0;
}

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

struct StAnsHist
{
  StAnsHist() : m_nProblmNo(0), m_sJudge("") { }

  int    m_nProblmNo;
  string m_sJudge;
};

void fnInput(int& rnProblmSiz, vector<StAnsHist>& rvoAnsHist)
{
  int nSubmitSiz;
  cin >> rnProblmSiz >> nSubmitSiz;
  rvoAnsHist.resize(nSubmitSiz);

  for(StAnsHist& roAnsHist : rvoAnsHist)
    cin >> roAnsHist.m_nProblmNo >> roAnsHist.m_sJudge;
}
  
void fnAnserCheck(int nProblmSiz, const vector<StAnsHist>& cnrvoAnsHist, 
                  int& rnRightAns, int& rnPenalty)
{
  vector<int> vnWACnt(nProblmSiz + 1);
  set<int> stRightAns;

  rnRightAns = 0;
  rnPenalty = 0;

  for (StAnsHist oAnsHist : cnrvoAnsHist)
    if (oAnsHist.m_sJudge == "AC")
      stRightAns.insert( oAnsHist.m_nProblmNo );
    else
      if (!stRightAns.count( oAnsHist.m_nProblmNo ))
        vnWACnt[ oAnsHist.m_nProblmNo ]++;

  rnRightAns = stRightAns.size();

  for (int nRightAns : stRightAns)
    rnPenalty += vnWACnt[nRightAns]; 
}
  
int main()
{
  int nProblmSiz;
  vector<StAnsHist> voAnsHist;
  fnInput(nProblmSiz, voAnsHist);

  int nRightAns, nPenalty;
  fnAnserCheck(nProblmSiz, voAnsHist, nRightAns, nPenalty);

  cout << nRightAns << " " << nPenalty;
  return 0;
}

Measured memory_bytes: 11520
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a==b)
    {
        for(int i=1;i<=a;i++)
        {
            printf("%d",a);
        }
    }
    else
    {
        int max=a>b?a:b,min=a>b?b:a;
        for(int i=1;i<=max;i++)
        {
            printf("%d",min);
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include <vector>
using namespace std;
int main(){
	int n,k;
	cin >> n >> k;
	vector <int> arr;
	for (int i = 0; i < n; ++i)
	{
		int tmp;
		cin >> tmp;
		arr.push_back(tmp);
	}
	int tong = 0;
	for (int i = 0; i < k; ++i)
	{
		int dem=0;
		int MIN = arr[0];
		for (int i = 1; i < arr.size(); ++i)
		{
			if(arr[i]<MIN){
				MIN = arr[i];
				dem = i;
			}
		}
		tong += MIN;
		arr.erase(arr.begin()+ dem);
	}
	cout<<tong;
}

Measured memory_bytes: 3136
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n; cin>>n; 
    int res[n];
    for (int i=1;i<=n;i++){
        int a; cin>>a;
        res[a]=i;
    }
    for (int i=1;i<=n;i++) cout << res[i] << " ";
    cout << endl;
}

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


Measured memory_bytes: 4308
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author hakamada
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC111_2 solver = new ABC111_2();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC111_2 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int NN = in.nextInt();
            String[] N = String.valueOf(NN).split("");
            String leftone = N[0];

            if ((leftone.compareTo(N[1]) == 0) & (leftone.compareTo(N[2]) == 0)) {
                out.println(N[0] + N[0] + N[0]);
                return;
            }

            while (true) {
                NN += 1;
                N = String.valueOf(NN).split("");
                if ((N[0].compareTo(N[1]) == 0) && (N[1].compareTo(N[2]) == 0)) {
                    out.println(NN);
                    return;
                }
            }
        
        
        
/*
        for (int i = 1; i < 3; i++) {
            if (Integer.parseInt(leftone) > Integer.parseInt(N[i])) {
                out.println(N[0] + N[0] + N[0]);
                return;
            }
        }
        leftone = String.valueOf(Integer.parseInt(leftone) + 1);
        out.println(leftone+leftone+leftone);
        return;
        */
        }

    }
}



Measured memory_bytes: 22996
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

require "prime"

n = input_n

if Prime.prime?(n)
  puts 1
  exit
end

if n == 1
  puts 0
  exit
end

cnt = 0
div = Prime.prime_division(n)
div.each do |a, b|
  100.times do |i|
    b -= i
    if b < 0
      cnt += i - 1
      break
    end
  end
end
puts cnt


Measured memory_bytes: 14424
#include "bits/stdc++.h"
using namespace std;

#define ul unsigned long int
#define ull unsigned long long
#define li long long int

int main()
{
  string s,o,ns;
  ul q,p[2];
  cin>>s>>q;
  for (ul i=0;i<q;i++) {
    cin>>o>>p[0]>>p[1];
    if (o=="print") {
      cout<<s.substr(p[0],p[1]-p[0]+1)<<endl;
    } else if (o=="reverse") {
      ns = s.substr(p[0], p[1] - p[0] + 1);
      reverse(ns.begin(),ns.end());
      s = s.substr(0, p[0]) + ns + s.substr(p[1] + 1);
    }
    else if (o == "replace") {
      cin >> ns;
      s = s.substr(0, p[0]) + ns + s.substr(p[1]+1);
    }
  }

  return 0;
}



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

using namespace std;


#define M_DEBUG if(0)


int main() {
	string s="";
	cin >> s ;
	assert(s.size() >= 1 && s.size() <= 100);

	string answer="Yes";
	int current_step = 1;  // 0 : even step. 1: odd step
	for (char c : s) {
		// cout << "is_odd: " << current_step << ", char: " << c << endl;
		assert(c == 'R' || c == 'L' || c == 'U' || c == 'D');
		if (current_step) {
			if (c == 'L') { // R, U, D でない
				answer="No";
			}
		} else {
			if (c == 'R') { // L, U, D でない
				answer="No";
			}
		}
		current_step = !(current_step);
	}
	cout << answer << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
INF = 10 ** 9
MOD = 10 ** 9 + 7
from collections import deque
sys.setrecursionlimit(100000000)

def main(): 
    n,m = map(int,input().split())
    L = [[] for _ in range(n)]
    R = [[] for _ in range(n)]
    for _ in range(m):
        l,r,d = map(int,input().split())
        l -= 1
        r -= 1
        L[l].append((r,d))
        R[r].append((l,d))
    
    visited = [True] * n
    X = [0] * n

    def dfs(i):
        ans = True
        for r in L[i]:
            j, d = r
            if visited[j]:
                X[j] = X[i] + d
                visited[j] = False
                ans = (ans&dfs(j)) 
            else:
                if X[j] - X[i] != d:
                    ans = False
                    break
        for l in R[i]:
            j,d = l
            if visited[j]:
                X[j] = X[i] - d
                visited[j] = False
                ans = (ans&dfs(j))
            else:
                if X[i] - X[j] != d:
                    ans = False
                    break
        return ans
    
    ans = True
    for i in range(n):
        if visited[i]:
            visited[i] = False
            ans = (ans&dfs(i))
    
    if ans:
        print('Yes')
    else:
        print('No')        
  
if __name__=='__main__':
    main()

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

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;

        while( (line = br.readLine()) != null ){
            char[] input = line.toCharArray();

            for(int i = 0; i < 26; i++){
                
                for(int j = 0; j < input.length; j++){
                    if(Character.isLowerCase(input[j])){
                        int a = (input[j] + 1 - 'a') % 26;
                        input[j] = (char)('a' + a);
                    }
                }

                String result = String.valueOf(input);
                
                if(result.indexOf("this") >= 0 || result.indexOf("the") >= 0 || result.indexOf("that") >= 0){
                    System.out.println(result);
                    break;
                }

            }


        }
        
    }
}

Measured memory_bytes: 24064
main(){int a,b,c,d,n,t;while(scanf("%d",&n)!=-1){t=0;for(a=0;a<=9;a++)for(b=0;b<=9;b++)for(c=0;c<=9;c++)for(d=0;d<=9;d++)if(a+b+c+d==n)t++;printf("%d\n",t);}return 0;}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-
import sys
from collections import deque
import copy

N,M,Q=map(int, sys.stdin.readline().split())
X=[ map(int, sys.stdin.readline().split()) for _ in range(Q) ]

qq=deque()
for m in range(1,M+1):
    q=deque()
    q.append([m])
    flag=True
    while flag:
        fro=q.popleft()
        if N<len(fro):break
        last=fro[-1]
        for to in range(last,M+1):
            if N<len(fro+[to]):
                q.append(fro)
                qq+=q
                flag=False
                break
            q.append(fro+[to])

ans=float("-inf")
for L in qq:
    temp_ans=0
    for a,b,c,d in X:
        if L[b-1]-L[a-1]==c:
            temp_ans+=d
    ans=max(ans,temp_ans)
print ans


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

using namespace std;



#define FOR(i,bg,ed) for(int i=bg;i<ed;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

#define fi first
#define se second
#define pb push_back

pair<string,vector<string>> parse(string s){
    vector<string> ret(1,"");
    for(auto &it:s){
        if(it==':'||it==',')
            ret.pb("");
        else if(it=='.')break;
        else ret.back()+=it;
    }
    string key = ret.front();
    reverse(ALL(ret));
    ret.pop_back();
    reverse(ALL(ret));
    //cout<<key<<":";for(auto &it:ret)cout<<it;cout<<endl;
    return {key,ret};
}
int main(){
    int n;
    while(cin>>n,n){
        map<string,vector<string>> g;
        string tmp;
        vector<string> v;
        string st;cin>>st;
        tie(tmp,v) = parse(st);
        set<string> now(ALL(v));
        REP(i,n-1){
            string s;
            cin>>s;
            string key;
            vector<string> group;
            tie(key,group) = parse(s);
            g[key]=group;
        }
        bool update=true;
        set<string> used;
        while(update){
            //for(auto &it:now)cout<<it<<",";cout<<endl;
            update=false;
            set<string> nxt;
            for(auto &it:now)
                if(g.count(it)){
                    update=true;
                    if(used.count(it)==0){
                        used.insert(it);
                        for(auto &i:g[it])
                            nxt.insert(i);
                    }
                }
                else{
                    nxt.insert(it);
                }
            swap(now,nxt);
        }
        cout<<now.size()<<endl;
    }
    return 0;
}

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

int main()
{
    int n, l;
    scanf("%d%d", &n, &l);
    vector<string> s(n);
    for(int i = 0; i < n; i++)cin>>s[i];
    sort(s.begin(), s.end());
    for(int i = 0; i < n; i++)cout << s[i];
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





int main() {
    vector<bool> is_sosu(60000, true);
    is_sosu[0] = false;
    is_sosu[1] = false;
    for(ll i = 2; i <= 55000; i++){
        if(!is_sosu[i]) continue;
        for(ll j = i * 2; j <= 55000; j += i){
            is_sosu[j] = false;
        }
    }
    
    ll n;
    while(scanf("%lld", &n) != EOF){
        for(ll i = n - 1; i >= 0; i--){
            if(is_sosu[i]){
                cout << i << " ";
                break;
            }
        }
        for(ll i = n + 1; i <= 55000; i++){
            if(is_sosu[i]){
                cout << i << endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using Pair = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;

/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/

int main(){
  int H,W,K;
  cin >> H >> W >> K;
  vector<vector<char>> c(H,vector<char>(W));
  rep(i,H) rep(j,W){
    cin >> c[i][j];
  }
  int black = 0;
  int ans = 0;
  for(int i=0;i<(1<<H);i++){
    for(int j=0;j<(1<<W);j++){
      int cnt = 0;
      for(int h=0;h<H;h++){
        for(int w=0;w<W;w++){
          if(i&(1<<h) || j&(1<<w)) continue;
          if(c[h][w] == '#') cnt++;
        }
      }
      if(cnt == K) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604
from collections import deque
import math

n = int(input())

#引き出せる金額の準備
a1 = [1]
a6 = [6**x for x in range(1, int(math.log(10**6, 6))+1)]
a9 = [9**x for x in range(1, int(math.log(10**6, 9))+1)]
b = a1+a6+a9
b.sort()

# n円引き出すための引き出し回数
dp = [-1] *(n+1)
dp[0]  = 0

# 探索キューを初期値ゼロで用意
d = deque([0])

# キューがなくなるまでループ
for _ in range(10**12):
    # キューが無いなら終了
    if len(d) == 0:
        break
        
    # キューから取り出し
    tmp = d.pop()
    
    # +1回で引き出せる範囲をDPにメモ
    for x in b:
        if tmp+x > n:
            break
        if dp[tmp+x] == -1:
            dp[tmp+x] = dp[tmp]+1
            d.appendleft(tmp+x)

print(dp[n])

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

typedef long long ll;

#define INF 1000000000001
#define N 101
#define VALUE 100001
int n, weight;
ll w[N], v[N], dp[VALUE], mx;

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

        cin >> n >> weight;
        for (int i = 1; i <= n; i++) {
                cin >> w[i] >> v[i];

                mx += v[i];
        }

        for (int i = 1; i <= mx; i++)
                dp[i] = INF;

        for (int j = 1; j <= n; j++)
                for (int i = mx; i >= v[j]; i--)
                        dp[i] = min(dp[i], dp[i-v[j]] + w[j]);

        for (int i = mx; i >= 0; i--)
                if (dp[i] <= weight) {
                        cout << i << '\n';

                        return 0;
                }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100000
#define MAX_M 100000
const int INF = 1e9;

int fib(int n){
  vector<long long> dp(n+1);
  dp[0]=1;
  dp[1]=1;
  for(int i=2;i<=n;i++){
    dp[i]=dp[i-1]+dp[i-2];
  }
  return dp[n];
}

int main(){
  int n;
  cin>>n;
  cout<<fib(n)<<endl;
}



Measured memory_bytes: 3080
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// use std::io::{stdout, Write, BufWriter};
// use std::cmp::min;

fn main() {
    input! {
        n: usize,
        d: i32,
        x: i32,
        a: [i32; n],
    }
    let s: i32 = a.into_iter().map(|a| multiples(0..(d - 1), a)).sum();
    println!("{}", s + x);
}

// 区間r(両端含む)に含まれるnの倍数の個数を求める
use std::ops::Range;
fn multiples<T>(r: Range<T>, n: T) -> T
where T: Copy
    + std::ops::Add<Output = T>
    + std::ops::Sub<Output = T>
    + std::ops::Div<Output = T>
    + std::convert::From<u8>
{
    (r.end / n) - (((r.start + n - T::from(1u8))/ n) - T::from(1u8))
}


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

int main() {
    char s[101] = { 0 }, t[101] = { 0 };
    int i, j;
    int sl, tl;
    scanf("%s %s", s, t);
    sl = strlen(s);
    tl = strlen(t);

    for (i = 0; i < sl - 1; i++) {
        for (j = i + 1; j < sl; j++) {
            if (s[i] > s[j]) {
                char tmp;
                tmp = s[i];
                s[i] = s[j];
                s[j] = tmp;
            }
        }
    }

    for (i = 0; i < tl - 1; i++) {
        for (j = i + 1; j < tl; j++) {
            if (t[i] < t[j]) {
                char tmp;
                tmp = t[i];
                t[i] = t[j];
                t[j] = tmp;
            }
        }
    }

    if (strcmp(s, t) < 0) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

char s[1'100'000];

int solve(const string& s) {
  vector<int> v(s.size());
  for (int i = 0; i < (int)s.size(); i++) {
    v[i] = s[i] - '0';
  }

  while (v.size() > 1) {
    int last = v.back();
    v.pop_back();
    for (int i = (int)v.size() - 1; i >= 0; i--) {
      int next = abs(v[i] - last);
      last = v[i];
      v[i] = next;
    }
  }
  return v[0];
}

int main() {
#ifdef LOCAL
  freopen("b.in", "r", stdin);
  freopen("b.out", "w", stdout);
#endif

  int n;
  while (scanf("%d", &n) == 1) {
    scanf("%s", s);
#ifdef LOCAL
    string init = s;
    int correct = solve(init);
#endif
    for (int i = 0; i < n; i++) {
      s[i]--;
    }
    int mul = 1;
    if (find(s, s + n, '1') == s + n) {
      mul = 2;
      for (int i = 0; i < n; i++) {
        if (s[i] == '2') {
          s[i] = '1';
        }
      }
    }

    int ans = 0;

    for (int i = 0; i < n; i++) {
      if (((~(n - 1)) & i) == 0) {
        if (s[i] == '1') {
          ans ^= 1;
        }
      }
    }
#ifdef LOCAL
    if (ans * mul != correct) {
      eprintf("%s %d %d\n", init.c_str(), ans * mul,correct);
      assert(0);
    }
#endif

    printf("%d\n", ans * mul);
  }


  return 0;
}


Measured memory_bytes: 1280
#include<cstdio>

using namespace std;

int main(){
	int x,y;
	scanf("%d %d",&x,&y);
	if(x == 2 && y == 2) printf("Yes\n");
	else if((x == 4 || x == 6 || x == 9 || x == 11) && (y == 4 || y == 6 || y == 9 || y == 11))
		printf("Yes\n");
	else if((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) && (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12))
		printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 128
a, b, k = map(int, input().split())
al = list()
bl = list()

for i in range(a):
  if a % (i+1) == 0:
    al.append(i+1)
for i in range(b):
  if b % (i+1) == 0:
    bl.append(i+1)

com = sorted(list(set(al) & set(bl)), reverse=True)
print(com[k-1])

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

int main (int argc,char **argv)
{
	char a[11],b[11],c[11];
	int d,e,f;

	scanf("%s%s%s",a,b,c);
	d = strlen(a);
	e = strlen(b);
	f = strlen(c);

	if ((a[d-1] == b[0]) && (b[e-1] == c[0]))
	{
		printf("YES\n");
	}

	else 
	{
		printf("NO\n");
	}

	return 0;

}


Measured memory_bytes: 128