akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <limits.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define NIL -1
#define INF INT_MAX -1
int G[N][N];
int d[N],pi[N],color[N];
int n;
void dijkstra(void){
  int i,u,v,mincost;
  for(u=0;u<n;u++){
    d[u]=INF;
    pi[u]=NIL;
    color[u]=WHITE;
  }
  d[0]=0;
  while(1){
    mincost=INF;
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && d[i]<mincost){
	mincost=d[i];
	u=i;
      }
    }
    if(mincost==INF) break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK && G[u][v]!=INF){
	if(d[u]+G[u][v]<d[v]){
	  d[v]=d[u]+G[u][v];
	  pi[v]=u;
	  color[v]=GRAY;
	}
      }
    }
  }
}
int main(){
  int i,j,k,u,v;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      G[i][j]=INF;
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      scanf("%d",&G[u][v]);
    }
  }
  dijkstra();
  for(i=0;i<n;i++) printf("%d %d\n",i,d[i]);
  return 0;
}

Measured memory_bytes: 640
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <cmath>

using namespace std;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mp make_pair
#define all(a) (a).begin(), (a).end()
typedef long long ll;

struct SegTree{ //0indexed
    vector<ll> nod;
    int size;
    SegTree(int x){
        size=1;
        while(x>size){
            size*=2;
        }
        nod=vector<ll>(size*2-1,LLONG_MAX/2);
    }
    ll update(int k){
        k+=size-1;
        ll ret =nod[k];//最下の処理
        while(k>0){
            k=(k-1)/2;
            ret = min(nod[k],ret); //下から上へ 
        }
        return ret;
    }
    void Update(int k,ll a){
        k+=size-1;
        nod[k]=a;//最下の処理
        while(k>0){
            k=(k-1)/2;
            nod[k]=a; //下から上へ 
        }
    }
    void query(int a,int b,int k,int l,int r,ll x){
        //[a,b)について
        //kは節点の番号,[l,r)はその節点がカバーする範囲
        if(r<=a||b<=l){ //[a,b)と[l,r)が重なって無いとき
            return;
        }
        if(a<=l && r<=b){ //[a,b)が[l,r)を完全に含んでいるとき
            nod[k] = min(nod[k],x);
        }
        else{
            query(a,b,k*2+1,l,(l+r)/2,x);
            query(a,b,k*2+2,(l+r)/2,r,x);
        }
    }
    void deb(){ //全ノードの出力
		for(int i=0;i<size*2-1;i++){
			if(i==size*2-2){
				cout << nod[i] << endl;
			}
			else{
				cout << nod[i] << ' ';
			}
		}
		return;
	}
};

int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<pair<int,int>,int>> da(m);
    rip(i,m,0){
        cin >> da[i].first.first >> da[i].first.second >> da[i].second;
        da[i].first.first--;
    }
    sort(all(da));
    SegTree sg(n);
    sg.query(0,1,0,0,sg.size,(ll)0);
    rip(i,m,0){
        ll now = sg.update(da[i].first.first);
        if(now == LLONG_MAX/2){
            cout << -1 << endl;
            return 0;
        }
        //sg.deb();
        sg.query(da[i].first.first,da[i].first.second,0,0,sg.size,now+da[i].second);
        //sg.deb();
    }
    ll ans = sg.update(n-1); 
    if(ans == LLONG_MAX/2){
        cout << -1 << endl;
        return 0;
    }
    cout << sg.update(n-1) << endl;
    //sg.deb();
}

Measured memory_bytes: 3456
#include <iostream>
using namespace std;
int main()
{
    int x, ans, tmp, i=2, f=0;
    cin >>x;

    if(x==1){
        cout << x <<endl;
        return 0;
    }

    while(1){
        tmp=x;
        for(i=2;i<x;i++){
            ans=1;
            while(tmp>=ans){
                ans=ans*i;
                if(ans==tmp){
                    f=1;
                    break;                
                } 
            }
            if(f==1) break;
        }
        if(f==1) break;
        x--;
    }
    cout << x <<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		long[] map = new long[N];
		for (int i = 0; i < N; i++) {
			map[i] = sc.nextLong();
		}
		
		int ans = 0;
		for (int i = 0; i < N; i++) {
			long val = map[i];
			while(val % 2 == 0) {
				ans++;
				val /= 2;
			}
		}
		
		System.out.println(ans);
	}
	
}


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

#define F                   first
#define S                   second
#define int                 long long int
#define pb                  push_back
#define mp                  make_pair
#define pii                 pair<int,int>
#define vi                  vector<int>
#define mii                 map<int,int>
#define pqb                 priority_queue<int>
#define pqs                 priority_queue<int,vi,greater<int> >
#define mod                 1000000007
#define endl                '\n'
#define rep(i,a,b)            for(int i=a;i<b;i++)
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
    c_p_c();
    int n, maxw;
    cin >> n >> maxw;
    int w[n];
    int v[n];
    int sumv = 0;
    rep(i, 0, n) {
        cin >> w[i] >> v[i];
        //sumv += v[i];
    }
    vi dp(maxw + 1, 0);
    for (int i = 0; i < n; i++) {
        for (int j = maxw - w[i]; j >= 0 ; j--) {//if reversed 0/n knapsack
            dp[j + w[i]] = max(dp[j + w[i]], v[i] + dp[j]);
        }
    }
    int ans = 0;
    for (int i = 0; i <= maxw; i++) {
        ans = max(ans, dp[i]);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N*3);
  
  for (int i=0; i<N*3; i++)
    cin >> vec.at(i);
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  long sum = 0;
  for (int i=1; i<=N*2; i+=2)
    sum += vec.at(i);
  
  cout << sum << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

struct Edge {
	int from, to;
	int cost;
	Edge(int from, int to, int cost) : from(from), to(to), cost(cost) {};
};

int dist[1010];
vector<Edge> edges;

signed main() {
	int N, M;
	cin >> N >> M;

	rep(i, M) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		edges.push_back(Edge(a, b, c));
	}

	rep(i, N) dist[i] = LLONG_MIN;
	dist[0] = 0;

	rep(i, 2 * N + 10) {
		int prev = dist[N - 1];
		for (auto &edge : edges) {
			if (dist[edge.from] == LLONG_MIN) continue;
			dist[edge.to] = max(dist[edge.to], dist[edge.from] + edge.cost);
		}
		if (i >= N + 2) {
			if (dist[N - 1] != prev) {
				cout << "inf" << endl;
				return 0;
			}
		}
	}

	cout << dist[N - 1] << endl;
}


Measured memory_bytes: 384
from collections import deque
n = int(input())

q = deque()
for i in range(n) :
    command = input().split()
    if command[0] == 'insert' :
        q.appendleft(command[1])
    elif command[0] == 'delete' :
        try :
            q.remove(command[1])
        except ValueError :
            pass
    elif command[0] == 'deleteFirst' :
        q.popleft()
    elif command[0] == 'deleteLast' :
        q.pop()
print(*q)


Measured memory_bytes: 69732
import math
#=input()
#=int(input())
a,b,c=map(int,input().split())
#=map(str,input().split())
#=list(map(int,input().split()))
if 4*a*b < (-a-b+c)**2 and a+b<=c:
    print("Yes")
else:
    print("No") 

Measured memory_bytes: 9160
using System;
using System.Linq;
 
namespace workspace{
  class Program{
    static void Main(){
      var tmp = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
      var N = tmp[0];
      var K = tmp[1];
      var price = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
      price.Sort();
      var sum = 0;
      
      for(int i = 0; i<K; i++){
        sum = sum + price[i];
      }
      Console.WriteLine(sum);
    }
  }
}

Measured memory_bytes: 28496
#表計算を行うプログラムを作成。

r,c=gets.split(" ").map(&:to_i)
h = Array.new(r+1).map{Array.new(c+1,0)} 

for i in 0..r-1                                       # 変数 i を1からr-1まで増やして繰り返し処理する。(arrayゼロから始めるから)
    
a= gets.split.map(&:to_i)
    for j in 0..c-1                                   # 変数 i を0からc-1回まで増やして繰り返し処理する。
    h[i][j] =  a[j]                                   # array のループひとつづつ足していく
    h[i][c] += a[j]
    h[r][j] += a[j]
    h[r][c] += a[j]
    end
end
for i in 0..r                                         #本ループをくりかえす   row 
    for j in 0..c                                     #本ループをくりかえす   column
      print " " unless j == 0
      print h[i][j]                                   #全体結果
    end
    puts                                              #段落あける
  end




Measured memory_bytes: 7040
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
double pi=3.1415926535898;
//double pi=acos(-1.0);
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define rep(i,a,b) for(int i=a;i<=int(b);++i)
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define r0         return 0;
#define CC         continue;
#define bb(x)      cerr<< x <<endl;
#define pii        pair<int,int>
#define pis        pair<int,string>
#define vi         vector<int>
#define F          first
#define S          second
//#define max(a,b) a<b?b:a  __builtin_popcount;
//#define min(a,b) a<b?a:b
//freopen("output.txt","w",stdout),freopen("input.txt","r",stdin);
const ll M  = 1e9+7 ;
const int N = 50500;
const int inf = INT_MAX;
const double eps = 1e-6;
//////////////////////    Hi    ^_^  hack me if you can :P
int n,x,mx;
int f[100100];
int main()
{
    cin>>n;
    lop(i,n)
    {
        cin>>x;mx+=++f[x]==1;
    }
    cout << mx - !(mx&1) ;
    r0;
}

/*



https://ideone.com/goT6Vy//http:
codeforces.com/problemset/problem/466/D

, vector < pair <int,int > >, greater <pair <int, int> >
http://codeforces.com/contest/295/submission/17929453
freopen("output.txt","w",stdout);
freopen("input.txt","r",stdin);

ll pwmod(ll a, ll n, ll mod)
{
    ll ret = 1;
    while (n)
    {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}

for (int i=0; i<n; i++)            Hi    ^_^  hack me if you can :P

int mx[]= {0,0,1,-1, 1,1,-1,-1};
int my[]= {1,-1,0,0, 1,-1,1,-1};
bool inside (int i,int j){return (i>=0 && i<n && j>=0 && j<m);}

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void gcd(LL n,LL m,LL &d,LL &xx,LL &yy)
{
    if(!m)
    {
        d=n;
        xx=1;
        yy=0;
    }
    else
    {
        gcd(m,n%m,d,yy,xx);
        yy-=xx*(n/m);
    }
}

int getm(int l,int r)
{
    if(l>r)
        return N;
    if(l==r)
        return 0;
    if(l==r-1)
        return s[l] != s[r];
    if(s[l]==s[r])
        return getm(l+1,r-1);
    else
        return 1+min(getm(l+1,r),getm(l,r-1));
}

int BIT[si], a[si], n;
void update(int x, int delta)
{
    for(; x <= N; x += x&-x)
        BIT[x] += delta;
}
int query(int x)
{
    int sum = 0;
    for(; x > 0; x -= x&-x)
        sum += BIT[x];
    return sum;
}

#define sc(x)      scanf("%d",&x)
#define scl(x)     scanf("%lld",&x)
#define pr(x)      printf("%d ",x)
#define prl(x)     printf("%lld ",x)
#define prln(x)    printf("%d\n",x)
#define prlln(x)   printf("%lld\n",x)
#define scd(x)     scanf("%lf",&x)
#define prd(x)     printf("%.10f\n",x)


*/


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

using namespace std;

int main()
{
  string s;
  cin >> s;
  vector<int> a(26,0);
  for(int i=0; i<s.size(); ++i)
  {
    a[s[i]-'a']++;
  }
  for(int i=0; i<26; ++i) 
  {
    if (a[i]&1)
    {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		System.out.printf("%d %d %.10f\n", a/b,a%b,(double)a/(double)b);
	}
}


Measured memory_bytes: 26604
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

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

    vector<vector<ll>> g(n);

    rep(i, n){
        int u, k;
        cin >> u >> k;

        rep(j, k){
            int v;
            cin >> v;
            v--;
            g[i].push_back(v);
        }
    }

    queue<int> que;
    que.push(0);

    ll dist[n];
    rep(i, n)dist[i] = -1;
    dist[0] = 0;

    bool visited[n] = {};
    visited[0] = true;

    while(!que.empty()){
        int pos = que.front();

        que.pop();

        rep(i, g[pos].size()){
            int child = g[pos][i];

            if(visited[child])continue;
            visited[child] = true;

            dist[child] = dist[pos] + 1;

            que.push(child);
        }
    }

    rep(i, n)cout << i+1 << " " << dist[i] << endl;
}


Measured memory_bytes: 3148
#include<stdio.h>
int main()
{
    int num, rem;
    scanf("%d", &num);

    while(num>0)
    {
        rem = num % 10;

        if(rem == 7)
        {
            printf("Yes\n");
            return 0;
        }
        num = num/10;
    }
        printf("No\n");
  	return 0;
}

Measured memory_bytes: 1656
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		double n=sc.nextDouble();
		double m=sc.nextDouble();
		double d=sc.nextDouble();
		double a=2*(n-d)*(m-1);
		if(d==0){
			a=n*(m-1);
		}
		System.out.println(a/(n*n));
	}
}


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

int main() {
  int a, b, s, t;
  s = 0;
  t = 0;
  int i;
  for (i = 0; i < 4; i++) {
    cin >> a;
    s += a;
  }
  for (i = 0; i < 4; i++) {
    cin >> b;
    t += b;
  }
  cout << max(s, t) << endl;
  return 0;
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define MAXN 10005
using namespace std;
int n,V,a[MAXN],b[MAXN],c[MAXN],d[MAXN];
vector<int> G[MAXN];
int match[MAXN];
bool used[MAXN];
void add_edge(int u,int v)
{
    G[u].push_back(v);
    G[v].push_back(u);
}
bool dfs(int v)
{
    used[v]=true;
    for(int i=0;i<G[v].size();i++)
    {
        int u=G[v][i],w=match[u];
        if(w<0||!used[w]&&dfs(w))
        {
            match[v]=u;
            match[u]=v;
            return true;
        }
    }
    return false;
}
int bipartite_matching()
{
    int res=0;
    memset(match,-1,sizeof(match));
    for(int v=1;v<=V;v++)
    {
        if(match[v]<0)
        {
            memset(used,0,sizeof(used));
            if(dfs(v))
            {
                res++;
            }
        }
    }
    return res;
}
int main()
{
    scanf("%d",&n);
    V=2*n;
    for(int i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]);
    for(int i=1;i<=n;i++) scanf("%d%d",&c[i],&d[i]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            if(a[i]<c[j]&&b[i]<d[j]) add_edge(i,n+j);
    printf("%d\n",bipartite_matching());
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
 
int main(void){
    int n;
    char w[101][11];
    scanf("%d",&n);//単語数を受け取る
    for(int i=0;i<n;i++){
        scanf("%s",w[i]);//単語を受け取る
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(strcmp(w[i],w[j])==0){printf("No");return 0;}//同じ単語があったら弾く
        }
    }
    for(int i=0;i<n-1;i++){
        if(w[i][strlen(w[i])-1]!=w[i+1][0]){printf("No");return 0;}//末尾の文字をチェック
    }
    printf("Yes\n");
}


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

int main()
{
    int h, w;  cin >> h >> w;
    string s;

    rep(i,h) {
        cin >> s;
        cout << s << endl << s << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define MAX 100000
struct Card{char suit;int value;};
struct Card A[MAX],B[MAX];int n;
void merge(int left,int mid,int right){
    int n1=mid-left;
    int n2=right-mid;
    Card L[MAX/2+2],R[MAX/2+2];
    rep(i,0,n1)L[i]=A[left+i];
    rep(i,0,n2)R[i]=A[mid+i];
    L[n1].value=2000000000;R[n2].value=2000000000;
    int i=0,j=0;
    rep(k,left,right){
        if(R[i].value>=L[j].value){
            A[k]=L[j];
            j++;
        }
        else{
            A[k]=R[i];
            i++;
        }
    }
}
void mergesort(int left,int right){
    if(left+1<right){
        int mid=(left+right)/2;
        mergesort(left,mid);
        mergesort(mid,right);
        merge(left,mid,right);
    }
}
int partition(int p,int r){
    int x=B[r].value;
    int i=p-1;
    rep(j,p,r){
        if(B[j].value<=x){
            i++;
            swap(B[i],B[j]);
        }
    }
    swap(B[i+1],B[r]);
    return i+1;
}
void quicksort(int p, int r){
    if(p<r){
        int q=partition(p,r);
        quicksort(p,q-1);
        quicksort(q+1,r);
    }
}
int main(){
    cin>>n;
    rep(i,0,n){
        cin>>A[i].suit>>A[i].value;
        B[i].suit=A[i].suit;
        B[i].value=A[i].value;
    }
    mergesort(0,n);
    quicksort(0,n-1);
    int stable=1;
    rep(i,0,n){
        if(A[i].suit!=B[i].suit)stable=0;
    }
    if(stable)cout<<"Stable"<<endl;
    else cout<<"Not stable"<<endl;
    rep(i,0,n){
        cout<<B[i].suit<<" "<<B[i].value<<endl;
    }
    return 0;
}


Measured memory_bytes: 5356
import scala.io.StdIn._
object Main extends App {
  val n = readInt
  val as = Array.fill(n)(readInt)
  val sorted = as.sorted
  val max = sorted(n - 1)
  val second = sorted(n - 2)

  val pw = new java.io.PrintWriter(System.out)
  as.foreach {a => pw.println(if (a == max) second else max)}
  pw.flush()
}

Measured memory_bytes: 44712
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

int dp[1001][1001];
int h, w, n;
int data[1000][1000];

int main() {
	while (cin >> h >> w >> n, h || w || n) {
		REP(i, h) REP(j, w) scanf("%d", &data[i][j]);
		
		int nx = 0, ny = 0;
		
		fill(dp[0], dp[h + 1], 0);
		dp[0][0] = n;
		REP(i, h) REP(j, w) {
			if (dp[i][j] == 0) continue;
			
			if (dp[i][j] & 1) {
				if (data[i][j]) {
					dp[i][j + 1] += (dp[i][j] + 1) / 2;
					dp[i + 1][j] += dp[i][j] / 2;
				}
				else {
					dp[i + 1][j] += (dp[i][j] + 1) / 2;
					dp[i][j + 1] += dp[i][j] / 2;
				}
			}
			else {
				dp[i][j + 1] += dp[i][j] / 2;
				dp[i + 1][j] += dp[i][j] / 2;
			}
			
			if (nx == j && ny == i) {
				int move = data[i][j];
				if ((dp[i][j] & 1) == 0) move ^= 1;
				
				if (move) nx++;
				else ny++;
			}
		}
		
		
		cout << ny + 1 << " " << nx + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 10952
#include<bits/stdc++.h>
using namespace std;
int c[500001];

int main(){
  int n;
  cin>>n;
  int len=0,mx=0;
  while(n--){
    int x;
    cin>>x;
    mx=max(mx,x);
    x=min(x,500000);
    if(c[0]||len>x||(len==x&&mx>x))cout<<"No"<<endl;
    else{
      while(++c[x]==2)c[x--]=0;
      int llen=max(len,1);
      while(c[llen])llen++;
      len=llen-1;
      cout<<"Yes"<<endl;
    }
  }
  return 0;
}

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

int main() {
	string s;
	cin >> s;
	int ans = 0, curr = 0;
	for(int i=0; i<s.size(); i++) {
		if(s[i] == 'R') {
			curr++;
		}
		else{
			curr = 0;
		}
		ans = max(curr, ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    printf("%lld\n", n * (n - 1ll) / 2);
    return 0;
}

Measured memory_bytes: 256
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	int N, M;
	int[] a, b;
	void Solve()
	{
		var I = G();
		N = I[0];
		M = I[1];
		a = new int[N];
		b = new int[N];
		for (var i = 0; i < N; i++)
		{
			I = G();
			a[i] = I[0];
			b[i] = I[1];
		}
		var s = Convert.ToString(M, 2);
		var ans = Calc(M);
		for (var i = 0; i < s.Length; i++)
			if (s[i] == '1')
			{
				var k = 0;
				for (var j = 0; j < i; j++) if (s[j] == '1') k |= 1 << (s.Length - j - 1);
				for (var j = i + 1; j < s.Length; j++) k |= 1 << (s.Length - j - 1);
				ans = Max(ans, Calc(k));
			}
		WriteLine(ans);
	}
	long Calc(int mask)
	{
		var s = 0L;
		for (var i = 0; i < N; i++) if ((~mask & a[i]) == 0) s += b[i];
		return s;
	}
}


Measured memory_bytes: 18100
#include <bits/stdc++.h>
using namespace std;
long long a,b,x;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin>>x;
    a=100;
    b=0;
    while (a<x)
    {
        a=a+a*1/100;
        b++;
    }
    cout<<b;
    
}

Measured memory_bytes: 3652
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
using namespace std;
int main(){
    int k,n; cin>>k>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    int maxa=k-a[n-1]+a[0];
    //cout<<a[n-1]<<endl;
    //cout<<maxa<<endl;;
    /*if(a[0]!=0){
        if(re<k/2) cout<<re<<endl;
        else cout<<k-re<<endl;
    }
    else{
        for(int i=1;i<n;i++){
            if((a[i]-a[i-1])>maxa){
                maxa=a[i]-a[i-1];
            }
        }
        cout<<k-maxa<<endl;
    }*/
    
    for(int i=1;i<n;i++){
        int m=a[i]-a[i-1];
        if(m>maxa){
            maxa=a[i]-a[i-1];
        }
    }
    cout<<k-maxa<<endl;
    return 0;
}

Measured memory_bytes: 1024
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n,m = map(int,input().split())
ans = 0
if n >= 2:
    ans += combinations_count(n, 2)
if m >= 2:
    ans += combinations_count(m, 2)
print(str( ans ))


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

string s;
int cnt[3];

int main() {
    ios_base::sync_with_stdio(false);
    cin >> s;
    int n = (int)s.size();
    for (char c : s) {
        ++cnt[c - 'a'];
    }
    if (n == 1) {
        cout << "YES" << endl;
        return 0;
    }
    forn(i, 3) forn(j, 3) if (abs(cnt[i] - cnt[j]) > 1) {
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    return 0;
}


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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0;i < n; i++) cin >> a.at(i);
    int mn = 1000000000, mi = 0;
    for (int i = 0;i < n; i++) {
        mn = min(mn,a.at(i));
        mi = max(mi,a.at(i));
    }

    cout << mi - mn << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define md (ll)(1e9+7)
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */

const int M=1e6+6;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

int cnt[5];
double n,dp[302][302][302];

double rec(int c1,int c2,int c3)
{
	if(c1 == 0 && c2 == 0 && c3 == 0)
		return 0.0;
	if(dp[c1][c2][c3] > 0.0)
		return dp[c1][c2][c3];
	dp[c1][c2][c3] = ((c1==0) ? 0 : c1*rec(c1-1,c2,c3))
					+((c2==0) ? 0 : c2*rec(c1+1,c2-1,c3))
					+((c3==0) ? 0 : c3*rec(c1,c2+1,c3-1))
					+ n;
	dp[c1][c2][c3] = dp[c1][c2][c3]/(c1+c2+c3);
	// cout << c1 << " " << c2 << " " << c3 << " " << dp[c1][c2][c3] << "\n";
	return dp[c1][c2][c3];
}

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

	int i,t;

	cin >> n;
	for(i=1;i<=n;++i)
	{
		cin >> t;
		cnt[t]++;
	}

	cout << setprecision(12) << rec(cnt[1],cnt[2],cnt[3]) << "\n";
	return 0;
}

	


Measured memory_bytes: 215296
#include<stdio.h>
int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if (a < b){
		if (b < c)
			printf("Yes\n");
		else
			printf("No\n");
	}
	else
		printf("No\n");
		return 0;
}

Measured memory_bytes: 1008
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

int main(){
	while(true){
		int N;
		cin >> N;
		if(N == 0) break;

		string S;
		cin >> S;
		int yama = 0;
		int card[10]={};
		for(int i=0; i<100; i++){
			card[i%N]++;
			if(S[i] == 'S'){
				yama += card[i%N];
				card[i%N] = 0;
			}
			if(S[i] == 'L'){
				card[i%N] += yama;
				yama = 0;
			}
		}
		sort(card, card+N);

		for(int i=0; i<N; i++){
			cout << card[i] << " ";
		}
		cout << yama << endl;
	}
}


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

using namespace std;

#define ll long long int

int main() 
{
    long int x,a,b,c=0;
    cin>>x;
    while(x>0)
    {
        if(x>=500)
        {
            a=x/500;
            b=x%500;
            c+=(1000*a);
            x=b;
        }
        else if(x>=5)
        {
            a=x/5;
            b=x%5;
            c+=(5*a);
            x=b;
        }
        else
            break;
    }
    cout<<c<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    set<char> se;
    rep(i, n)se.insert(s[i]);
    int ans = 1000;
    for(char c : se){
        string t = s;
        int cnt = 0;
        rep(i, n){
            bool val = true;
            rep(j, t.size())if(t[j] != c)val = false;
            if(val){
                cnt = i;
                break;
            }else{
                string next = "";
                rep(j, t.size()-1){
                    if(t[j] == c || t[j+1] == c)next += c;
                    else next += '?';
                }
                t = next;
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}

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

int main() {
     long long R;
     cin >> R;
     
     cout << R * 2 * 3.141592 << endl;
 }

Measured memory_bytes: 3780
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define int long long

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
int in(){int a;scanf("%d",&a);return a;}
ll lin(){ll a;scanf("%lld",&a);return a;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

int d(int i)
{
    int a=i+i+1+i+2;
    int b=i+7;b=b+b+1+b+2;
    int c=i+14;c=c+c+1+c+2;
    return (a+b+c)%11;
}

int hoge[55]={4,2,0,9,7,1,10,8,6,4,9,7,5,3,1,6,4,2,0,9,3,1,10,8,6,0,9,7,5,3,8,6,4,2,0,5,3,1,10,8,2,0,9,7,5,10,8,6,4,2,7,5,3,1,10};

signed main()
{
    int n, k; cin >> n >> k;

    if (n < 3) {
        cout << 0 << endl;
        return 0;
    }

    if (n < 50) {
        int ans = 0;

        for (int i = 0; i < n-2; ++i) {
            for (int j = 0; j < 5; ++j) {
                if (hoge[(i*5+j)%55] == k) {
                    ans++;
                }
            }
        }

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

    int temp = 0;
    for (int i = 0; i < 11; ++i) {
        for (int j = 0; j < 5; ++j) {
            if (hoge[(i*5+j)%55] == k) {
                temp++;
            }
        }
    }

    int ans = temp*((n-2)/11);

    int aa=(n-2)%11;

    for (int i = 0; i < aa; ++i) {
        for (int j = 0; j < 5; ++j) {
        if (hoge[(i*5+j)%55] == k) {
            ans++;
        }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    vector<int> v(3);
    REP(i,3) cin >> v[i];
    int k; cin >> k;
    cout << accumulate(ALL(v),0) - max({v[0],v[1],v[2]}) + max({v[0],v[1],v[2]}) * pow(2,k) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;

int n,m;
ll a[100100];
vector<int> G[100100];
int used[100100];
vector<ll> ve;

void dfs(int s){
    used[s]=1;
    ve.push_back(a[s]);
    for(int t:G[s]){
        if(!used[t]){
            dfs(t);
        }
    }
    return;
}

int main(){
    cin >> n >> m;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<m;i++){
        int x,y; cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    if(n-1==m){
        cout << 0 << endl;
        return 0;
    }
    if(n<2*(n-m-1)){
        cout << "Impossible" << endl;
        return 0;
    }
    vector<ll> v;
    ll ans=0; int cnt=0;
    for(int i=0;i<n;i++){
        if(!used[i]){
            ve.clear();
            dfs(i);
            sort(ve.begin(),ve.end());
            ans+=ve[0];
            cnt++;
            for(int j=1;j<ve.size();j++){
                v.push_back(ve[j]);
            }
        }
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size()&&cnt<2*(n-1-m);i++,cnt++){
        ans+=v[i];
    }
    cout << ans << endl;
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();

            if (x[2] >= x[0] && x[2] <= x[1])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }        
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n, a, b, c, d;
  string s;
  cin >> n >> a >> b >> c >> d >> s;
  a--; b--; c--; d--;

  bool f;
  // a < c < b < d or a < b < c < d
  if (c < d) {
    f = 1;
    rep(i, d-b) {
      if (s[b+i] == '#' && s[b+i+1] == '#') {
        f = 0;
      }
    }
    rep(i, c-a) {
      if (s[a+i] == '#' && s[a+i+1] == '#') {
        f = 0;
      }
    }
  // a < b < d < c
  } else {
    f = 0;
    for (ll i = b; i <= d; i++) {
      if (s[i-1] == '.' && s[i] == '.' && s[i+1] == '.') {
        f = 1;
      }
    }
  }

  if (f) {
    puts("Yes");
  } else {
    puts("No");
  }
}



Measured memory_bytes: 592
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    ll A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;
    if (abs(A - B) <= T*(V - W)) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, string> P;
typedef tuple<int, string, string> T;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

string s;

string solve() {
    return s.substr(0, 3);
}

void input() {
    cin >> s;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 3048
n=int(input())
A=list(map(int,input().split()))
four=list(filter(lambda x:x%4==0,A))
even=list(filter(lambda x:x%2==0,A))
odd=list(filter(lambda x:x%2==1,A))
# print(len(even))
# print(len(odd))
# print(len(four))

#全ての成分が偶数
if len(even)==len(A):
  print('Yes')
  exit()
#4の倍数が奇数の半分以上ある（切り下げ）かつ2の倍数が偶数個かつ元が偶数個
if len(four)>=len(odd)/2 and (len(even)-len(four))%2==0:
  if (len(even)-len(four))%2>0:
    print('Yes')
    print('aa')
    exit()
# #4の倍数が奇数の半分以上ある（切り上げ）かつ4の倍数が奇数個あるかつ2の倍数が奇数個あるかつ元が奇数個
if len(four)>=len(odd)/2 and len(four)%2!=0 and len(A)%2!=0:
  print('Yes')
  exit()
if len(four)>=len(odd)/2 and len(four)%2==0 and len(A)%2==0:
  print('Yes')
  exit()
else:
  print('No')

Measured memory_bytes: 14480
s = input()
t = input()

dp = [[0]* len(s) for i in range(len(t))]
dp[0][0] = 0

for j in range(len(t)):
    for i in range(len(s)):
        if s[i] == t[j]:
            if i == 0 or j == 0:
                dp[j][i] = 1
            else:
                dp[j][i] = dp[j-1][i-1] + 1
        
        else:
            dp[j][i] = max(dp[j][i-1], dp[j-1][i])


ans = " "
j = len(t) - 1 
i = len(s) - 1 

while True:
    if j == 0:
        if dp[0][i] == 1:
            ans += t[0]
        break
    if i == 0:
        if dp[j][0] == 1:
            ans += s[0]           
        break
        
    else:
        if dp[j][i] == dp[j-1][i]:
            j -= 1
        elif dp[j][i] == dp[j][i-1]:
            i -= 1
        else:
            ans += t[j]
            j -= 1
            i -= 1

print(ans[::-1])

#for i in range(len(t)):
#    print(dp[i])

Measured memory_bytes: 112476
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vector<int> a(n + 1);
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}

	vector<int> total_balls(n + 1), has_ball(n + 1);
	int m = 0;
	for (int i = n; i > 1; --i) {
		if (a[i]) {
			if (total_balls[i] % 2 == 0) {
				++total_balls[i];
				has_ball[i] = 1;
				++m;
			}
		} else {
			if (total_balls[i] & 1) {
				++total_balls[i];
				has_ball[i] = 1;
				++m;
			}
		}

		if (has_ball[i]) {
			++total_balls[1];
			for (int j = 2; j * j <= i; ++j) {
				if (i % j == 0) {
					++total_balls[j];
					int k = i / j;
					if (k != j) {
						++total_balls[k];
					}
				}
			}
		}
	}

	if (total_balls[1] % 2 != a[1] % 2) {
		++total_balls[1];
		has_ball[1] = 1;
	}

	cout << m + (has_ball[1] != 0) << "\n";
	for (int i = 1; i <= n; ++i) {
		if (has_ball[i]) {
			cout << i << " ";
		}
	}

	cout << "\n";

	return 0;

}

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

int n, w, ans;

int main() {
  cin >> n >> w;
  vector<int> weight(n);
  vector<int> value(n);
  for (size_t i = 0; i < n; i++) {
    cin >> weight.at(i) >> value.at(i);
  }
  vector<vector<long int>> dp(n + 1,vector<long int>(100001, -1));
  dp.at(0).at(0) = 0;
  for (int i = 0; i < n ;i++) {
    for (int j = 0; j < 100001; j++){
      if (dp.at(i).at(j) != -1) {
        if (dp.at(i + 1).at(j) == -1) {
          dp.at(i + 1).at(j) = dp.at(i).at(j);
        }else{
          dp.at(i + 1).at(j) = min(dp.at(i + 1).at(j), dp.at(i).at(j));
        }
        if (dp.at(i + 1).at(j + value.at(i)) == -1) {
          dp.at(i + 1).at(j + value.at(i)) = dp.at(i).at(j) + weight.at(i);
        }else{
          dp.at(i + 1).at(j + value.at(i)) = min(dp.at(i + 1).at(j + value.at(i)), dp.at(i).at(j) + weight.at(i));
        }
      }
    }
  }
  for (size_t i = 100000; i >= 0; i--) {
    if (dp.at(n).at(i) != -1 and dp.at(n).at(i) <= w) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    int A[N];
    for(int i = 0; i < N; ++i) cin >> A[i];
    
    int counter = 0;
    bool isOK = 0;

    for(int i = 0; i < N; ++i){
        if(A[i]%2 == 0){
            if(A[i]%3 == 0 || A[i]%5 ==0)counter++;
            else break;
        }else counter++;
    }
    if(counter == N) isOK = 1;

    if(isOK) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace std; 

// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;

# define ll long long int
#define M 1000000007
#define pb push_back
#define ss second
#define ff first
#define inf 1000000000000000


 

													//nestedcode


bool is_composite[1000005];
ll lp[1000005];
vector<ll> prime;
void sieve (int n) {
	std::fill (is_composite, is_composite + n, false);
	for (int i = 2; i < n; ++i) {
		if (!is_composite[i]) {
			prime.push_back (i);
			lp[i] = i;
		}	for (int j = 0; j < prime.size () && i * prime[j] < n; ++j) {
			is_composite[i * prime[j]] = true;
			lp[i * prime[j]] = prime[j];
			if (i % prime[j] == 0) break;
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll i,d,g,n,fl = 0,z;
    cin>>n;
    ll a[n+5];
    map<ll,ll> m;
    sieve(1000005);
    for(i=0;i<n;i++){
    	cin>>a[i];
    	d = a[i];
    	while(d > 1){
    	
    		if(m[lp[d]] == 1){
    			fl = 1;
    			break;
			}
			m[lp[d]] = 1;
			z = lp[d];
			while(lp[d] == z)
			d /= lp[d];
		}
    	
	}
	g = 0;
	for(i=0;i<n;i++){
		g = __gcd(g,a[i]);
	}
	
	if(g == 1 && fl == 0){
		cout<<"pairwise coprime";
		return 0;
	}
	if(g == 1){
		cout<<"setwise coprime";
		return 0;
	}
	cout<<"not coprime";
}


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

int d[175][175];
int xx[6] = {1,1,-1,-1,0,0};
int yy[6] = {1,0,-1,0,1,-1};


int main(){

  int t, n;
  while(cin >> t >> n && (t||n)){
    memset(d,0,sizeof(d));

    for(int i = 0; i < n; i++){
      int x, y;
      cin >> x >> y;
      d[y+75][x+75] = 1;
    }

    int x, y;
    cin >> x >> y;
    d[y+75][x+75] = 1;
    int cnt = 1;

    queue<pair<int, pair<int, int> > > q;
    q.push(make_pair(t, make_pair(x+75, y+75)));
    int ttc = 0;

    while(!q.empty()){
      pair<int, pair<int, int> > cq = q.front();
      q.pop();
      if(cq.first == 0) continue;
      int tc = cq.first;
     for(int i = 0; i < 6; i++){
       int nx = xx[i] + cq.second.first, ny = yy[i] + cq.second.second;
       if(d[ny][nx] != 1){
         d[ny][nx] = 1;
         cnt++;
         q.push(make_pair(tc-1,make_pair(nx,ny)));
       }
     }
    }

    cout << cnt << endl;

  }



}

Measured memory_bytes: 1344
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {

		Scanner sc = new Scanner(System.in);

		while (sc.hasNextInt()) {
			boolean[] check = new boolean[11];
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			check[a] = check[b] = check[c] = true;
			double sum = .0;
			for (int i = 1; i < check.length; i++) {
				if (!check[i]) sum += (a + b + i) <= 20 ? 0.142857 : 0;
			}
			System.out.println(sum >= .5 ? "YES" : "NO");
		}

	}

}

Measured memory_bytes: 17204
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define Ma7moud_7amdy                 \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define Open_Sesame Open()
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define clr(arr, x) memset(arr, x, sizeof arr)
#define endl "\n"
#define watch(x) cout << #x << " = " << x << endl;
#define RT(x) return cout << (x), 0;
#define Accepted 0
typedef long long ll;
typedef vector<int> vi;
const int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
void Open()
{
#ifndef ONLINE_JUDGE 
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
const int mod = ll(1e9 + 7), N = 1e5 + 500;
//“Nobody but you have to believe in your dreams to make them a reality.” ― Germany Kent
ll w[N], v[N], dp[101][N];

int main()
{
	Ma7moud_7amdy;
	Open_Sesame;
	int n, c;
	cin >> n >> c;
	for (int i = 0; i < n; i++) {
		cin >> w[i] >> v[i];

	}
	for (int i = n - 1; i >= 0; i--) {
		for (int cap = 0; cap <= c; cap++) {
			dp[i][cap] = dp[i + 1][cap];

			if (cap >= w[i])
				dp[i][cap] = max(dp[i][cap], dp[i + 1][cap - w[i]] + v[i]);
		}

	}
	cout << dp[0][c];
}

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

int main (){

    string S,tmp="abcdefghijklmnopqrstuvwxyz";
    cin >> S;
    map<char,int>m;
    for(long long i = 0; i < S.size(); i++) {
        m[S[i]]++;
    }

    for(int i = 0; i < 26; i++) {
        if(m[tmp[i]] == 0) {
            cout << tmp[i] << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


Measured memory_bytes: 512