akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.

		char[] s = next().toCharArray();
		char[] ds = new char[s.length * 2];
		System.arraycopy(s, 0, ds, 0, s.length);
		System.arraycopy(s, 0, ds, s.length, s.length);

		long k = (long)ni();
		long result = 0;

		long singlesum = 0;
		char stmp = s[0];			
		for(int i = 1; i < s.length; i++) {
			if(s[i] == stmp) {
				singlesum++;
				s[i] = '!';
			}
			stmp = s[i];
		}
		
		long doublesum = 0;
		char dtmp = ds[0];
		for(int i = 1; i < ds.length; i++) {
			if(ds[i] == dtmp) {
				doublesum++;
				ds[i] = '!';
			}
			dtmp = ds[i];
		}
		
		if(s[0] != s[s.length -1]) {
			result = singlesum * k;
		} else {
			if(ds[0] != ds[ds.length - 1]) {
				result = doublesum*(k/2);
				if(k % 2 != 0)result += singlesum;
			}else {
				result += (doublesum - singlesum) * (k - 1);
				result += singlesum;
			}
		}
		
		System.out.println(result);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		} 
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 22868
A, B, C, D, E, F = map(int, input().split())

W = set()
for a in range(0, F+1, 100*A):
    for b in range(0, F+1-a, 100*B):
        W.add(a+b)

S = set()
for c in range(0, F+1, C):
    for d in range(0, F+1-c, D):
        S.add(c+d)

rate = -1
for w in W:
    for s in S:
        if 0 < w+s <= F and s <= (E/100)*w:
            if s/(w+s) > rate:
                rate = s/(w+s)
                ans = w+s, s
                
print(ans[0], ans[1])

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

/*#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;*/

/*#include <ext/pb_ds/assoc_container.hpp>   // Policy_based_Data_Structure 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define fbo find_by_order
#define ook order_of_key*/


#define ll long long int
#define bigint int64_t
#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define MOD 1000000007
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int main(){
    IOS;
    //io_set();
    ll n, k, a, b, c;
    cin >> n >> k >> a >> b >> c;
    string s;
    cin >> s;
    ll ans = 0;
    vector < char > v;
    rep(j, n){
      if(j < k){
        if(s[j] == 'r'){
          ans += c;
          v.pb('p');
        }
        else if(s[j] == 's'){
          ans += a;
          v.pb('r');
        }
        else if(s[j] == 'p'){
          ans += b;
          v.pb('s');
        }
      }
      else{
        if(s[j] == 'r'){
          if(v[j-k] == 'p'){
            if(j + k < n && s[j+k] == 'p')
              v.pb('r');
            else
              v.pb('s');
          }
          else{
            ans += c;
            v.pb('p');
          }
        }
        else if(s[j] == 's'){
          if(v[j-k] == 'r'){
            if(j + k < n && s[j+k] == 'r')
              v.pb('s');
            else
              v.pb('p');
          }
          else{
            ans += a;
            v.pb('r');
          } 
        }
        else if(s[j] == 'p'){
          if(v[j-k] == 's'){
            if(j + k < n && s[j+k] == 's')
              v.pb('p');
            else
              v.pb('r');
          }
          else{
            ans += b;
            v.pb('s');
          }
        }
      }
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 
 
using namespace std;
long long mod = 1e9 + 7;
long long INF = 1e7;
double EPS = 1e-12;
typedef long long int lld;
long double tick(){static clock_t oldt; clock_t newt=clock();
    long double diff=1.0L*(newt-oldt)/CLOCKS_PER_SEC; oldt = newt; return diff; }
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
inline lld sc() { lld a; scanf("%lld", &a); return a; }
inline int scd() { int a; scanf("%d", &a); return a; }
inline double scf() { double a; scanf("%lf",&a); return a; }
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) (c).begin(), (c).end()
#define sz(a) ((int)a.size())
#define Error(x...) { cout << "(" << #x << ")" << " = ( "; printIt(x); }
template <typename T1> void printIt(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) { cout << t1 << " , "; printIt(t2...); }
#define errorpair(a) cout<<#a<<" = ( "<<((a).first)<<" , "<<((a).second)<<" )\n";
#define mset(a, v) memset(a, v, sizeof(a))
#define popcount __builtin_popcountll

typedef pair<lld,lld> PA;

lld powP(lld x, lld y) {
    lld ans = 1, po = x % mod;
    while(y > 0) {
        if(y & 1) ans = ans * po % mod;
        y >>= 1; po = po * po % mod;
    }
    return ans;
}
 
bool bitSet(lld n, lld bit){
    if((n & (1LL << bit)) != 0) return true;
    else return false;
}
 
lld findGcd(lld a, lld b){
    while(a != 0) { lld temp = b % a; b = a; a = temp; }
    return b;
}

#define lim 300010
#define lim2 200010
#define qqqqqq 210
// Ab :)
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

// vector<lld> G[lim];
// string S[lim];
lld A[lim],Height[lim],C[lim];

int main(){
    lld n = sc(), m = sc();
    rep(i,1,n) Height[i] = sc();
    while(m--) {
        lld a = sc(), b = sc();
        A[b] = max(A[b], Height[a]);
        A[a] = max(A[a], Height[b]);
    }
    int ans = 0;
    rep(i,1,n) ans += (Height[i] > A[i]);
    prdL(ans);
    return 0;
}


Measured memory_bytes: 5404
#include<bits/stdc++.h>
#define st first
#define nd second

using ll = long long ;
using namespace std;
using pii = pair<int,int>;
const int N = 5e5 + 10;
int a[N], ft[N], lv[N], n, ans[N];
int query(int pos){
	int sum = 0;
	for(;pos > 0; pos -= pos & -pos){
		sum += ft[pos];
	}
	return sum;
}
void update(int pos, int val){
	for(; pos <= n; pos += pos & -pos){
		ft[pos] += val;
	}

}
struct Q {
	int l;
	int r;
	int id;
	bool operator < (const Q &o){
		return r < o.r;
	}
}qq[N];
int main(){
	int  q;
	scanf("%d %d", &n, &q);
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
	}	
	for(int i = 1; i <= q; i++){
		scanf("%d %d", &qq[i].l, &qq[i].r);
		qq[i].id = i;
	}
	sort(qq + 1, qq + q + 1);
	int it = 1;
	for(int i =1; i <= n; i++){
		if(lv[a[i]] != 0) update(lv[a[i]], -1);
		lv[a[i]] = i;
		update(i, 1);
		for(;it <= q && qq[it].r == i; it++){
			ans[qq[it].id] = query(i) - query(qq[it].l - 1);
		}
		if(it > q) break;
	}
	for(int i = 1; i <= q;i ++){
		printf("%d\n", ans[i]);
	}


}

Measured memory_bytes: 17448
#include <iostream>
#include <string>
#include <cstring>

using namespace std;

#define N_MAX 2000
#define Y_MAX (2*10000000)
int N;
int Y;
bool table[Y_MAX/1000+10];
bool use5[Y_MAX/1000+10];

int main(void){
	memset(table,0,sizeof(table));
	memset(use5,0,sizeof(use5));

	cin >> N;
	cin >> Y;

	table[Y/1000] = true;
	for(int i=Y/1000 -4; i>=N; i--){
		if (table[i+9]){
			table[i] = true;
			use5[i] = false;
		} else if (table[i+4]){
			table[i] = true;
			use5[i] = true;
		}
	}

	if (!table[N]){
		cout << "-1 -1 -1" << "\n";
		return 0;
	}

	int a,b,c = 0;
	c = Y/1000;
	for (int i=N;;){
		if (i == Y/1000) break;
		if (use5[i]){
			i+=4;
			c-=5; b++;
		}else{
			i+=9;
			c-=10; a++;
		}
	}
	if (c < 0) {
		cout << "-1 -1 -1" << "\n";
		return 0;
	}
	
	cout << a << " " << b << " " << c << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
priority_queue<ll> mxq;
priority_queue<ll,vector<ll>,greater<ll> > miq;
ll a[300000],aa[100001],bb[100001],fsum,bsum;
int main(void){
	ll n,i,nn,mx;
	cin>>n;
	nn=n*3;
	for(i=0;i<nn;i++) cin>>a[i];
	fsum=0;
	for(i=0;i<n;i++) miq.push(a[i]),fsum+=a[i];
	aa[0]=fsum;
	bsum=0;
	for(i=nn-1;i>=2*n;i--) mxq.push(a[i]),bsum+=a[i];
	bb[n]=bsum;
	for(i=n;i<2*n;i++){
		fsum+=a[i];
		miq.push(a[i]);
		fsum-=miq.top(); miq.pop();
		aa[i-n+1]=fsum;
	}
	for(i=n*2-1;i>=n;i--){
		bsum+=a[i];
		mxq.push(a[i]);
		bsum-=mxq.top(); mxq.pop();
		bb[i-n]=bsum;
	}
/*	for(i=0;i<=n;i++) cout<<aa[i]<<' ';
	cout<<endl;
	for(i=0;i<=n;i++) cout<<bb[i]<<' ';
	cout<<endl;*/
	mx=LLONG_MIN;
	for(i=0;i<=n;i++) mx=max(mx,aa[i]-bb[i]);
	cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 5876
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
ll M = MOD;
vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

int main(){
    ll s;
    cin >> s;
    ll co = s / 3,a = s % 3;
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
    ll ans = 0;
    while (co > 0){
        ans += comb(co - 1 + a,co-1);
        ans %= M;
        co--;
        a += 3;
    }
    cout << ans << endl;
}

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

vector<string> s;
bool in(string& x){
	for(int i=0; i<s.size(); i++){
		if(s[i]==x){
			return true;
		}
	}
	return false;
}
bool shiritori(string& x){
	if(s.size()==0){
		return true;
	}
	if(s.back().back()==x.front()){
		return true;
	}else{
		return false;
	}
}
int main(){
	int n;
	string x;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> x;
		if(in(x) || !shiritori(x)){
			cout << "No" << endl;
			return 0;
		}
		s.push_back(x);
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
N, T = [int(num) for num in input().split()]
d = {}
for _ in range(N):
    c, t = [int(num) for num in input().split()]
    d[c] = t

c = None
for cost, minutes in d.items():
    if minutes <= T:
        if c is None:
            c = cost
            continue

        if c > cost:
            c = cost

if c is None:
    print('TLE')
else:
    print(c)


Measured memory_bytes: 3060
N = int(input())
pns = [2]
for i in range(3, 1500):
    for pn in pns:
        if i % pn == 0:
            break
    else:
        pns.append(i)

print(' '.join([str(pn) for pn in pns if pn % 10 == 1][:N]))

Measured memory_bytes: 3316
fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val list = readLine()!!.split(" ").map{it.toInt()}
    var flag = true

    for(i in list.indices) {
        if(list[i]%2 == 0) {
            if(list[i]%3 == 0 || list[i]%5 == 0) {

            } else {
                flag = false
            }
        }
    }
    if(flag){
        println("APPROVED")
    } else {
        println("DENIED")
    }
}

Measured memory_bytes: 37784
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;

int ans ;

int n,k,s;

void dfs(int id,int tot,int sum){
    if(tot>k) return;
    if(sum<s&&(s-sum<id)) return;
    if(tot==k&&sum==s){
        ans++;
        return;
    }
    if(id>n||sum>s) return;
    dfs(id+1,tot+1,sum+id);
    dfs(id+1,tot,sum);
}

int main()
{
    while(~scanf("%d%d%d",&n,&k,&s)){
        if(n==0&&k==0&&s==0) break;
        ans=0;
        dfs(1,0,0);
        printf("%d\n",ans);
    }
    return 0;
}

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

int main(){
  int n,for_n=1,pre_n=1;

  cin >> n;
  for(int i=0;i<=n;i++){
    if((i==0) || (i==1)){
      continue;
    }else{
      int swp=for_n;

      for_n += pre_n;
      pre_n = swp;
    }
  }
  cout << for_n << endl;
}


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

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    vector<int> a(n, 0);
    int b = 0;
    long long ret = -1;
    for(int i=0; i<n; ++i){
        ++ a[b];
        if(s[i] == '(')
            ++ b;
        else
            -- b;
        ret += a[b];
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 1532
// luogu-judger-enable-o2
//Program written by Liu Zhaozhou ~~~
#include <bits/stdc++.h>

#define lowbit(x) x & -x
#pragma GCC optimize("Ofast,inline")

using namespace std;

namespace Base {
	inline char gc(void)
	{
		static char buf[100000], *p1 = buf, *p2 = buf;
		return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++;
	}

	#define gc() getchar()

	template <class T>
	inline void read(T &x)
	{
		T flag = (T) 1; x = 0; static char ch = gc();
		for (; ch > '9' || ch < '0'; ch = gc())
			flag = ch == '-' ? -1 : 1;
		for (; ch >= '0' && ch <= '9'; ch = gc())
			x = (x << 1) + (x << 3) + (ch & 15);
		x *= flag; return;
	}
	
	inline void readstr(string&x) {
		x = ""; static char ch;
		while (isspace(ch = gc()));
		while (x += ch, !isspace(ch = gc()));
	}

	inline void readstr(char *s) {
		do *s = gc(); while ((*s == ' ') || (*s == '\n') || (*s == '\r'));
		do *(++s) = gc(); while ((~*s) && (*s != ' ') && (*s != '\n') && (*s != '\r'));
		*s = 0; return;
	}

	inline void printstr(string x, int num = 0, char ch = '\n') {
		for (int i = num; i < x.size(); ++i)
			putchar(x[i]); putchar(ch);
	}

	inline void readch(char&x) {while (isspace(x = gc()));}

	template <class T>
	inline void write(T x)
	{
		if (x < 0) putchar('-'), x = -x;
		if (x > 9) write(x / 10);
		putchar(x % 10 + '0'); return;
	}
    
	template <class T> inline void writeln(T x) {write(x); puts("");}
	template <class T> inline void writeln(T x, char c) {write(x); putchar(c);}
	template <class T> inline void writeln(char c, T x) {putchar(c); write(x);}

	template <class T> inline void chkmax(T &x, const T y) {x > y ? x = x : x = y;}
	template <class T> inline void chkmin(T &x, const T y) {x < y ? x = x : x = y;}
	template <class T> inline T max(const T&x, const T&y, const T&z) {
		return x > y ? (x > z ? x : z) : (y > z ? y : z);
	}
	
	typedef long long ll;
	typedef unsigned long long ull;
	typedef long double ld;

	#define Ms(arr, opt) memset(arr, opt, sizeof(arr))
	#define Mp(x, y) make_pair(x, y)

	inline void file(string str) {
		freopen((str + ".in").c_str(), "r", stdin);
		freopen((str + ".out").c_str(), "w", stdout);
	}
}

using namespace Base;

char str[1000005];

signed main(void) {
	//file("");
	readstr(str); putchar(str[0]);
	write(strlen(str) - 2);
	putchar(str[strlen(str) - 1]);
	return 0;
}

/**/



Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef long double db;
    typedef pair<int,int> pii;
    typedef vector<int> vi;
    #define de(x) cout << #x << "=" << x << endl
    #define rep(i,a,b) for(int i=a;i<(b);++i)
    #define all(x) (x).begin(),(x).end()
    #define sz(x) (int)(x).size()
    #define mp make_pair
    #define pb push_back
    #define fi first
    #define se second
    const int N = 1e5+5;
    const int mod=1000000007;
    char str[10000];
    char str2[10000];
    int main()
    {
    int n,i=0,flag=0;
    scanf("%d",&n);
    scanf("%s",str);
    scanf("%s",str2);
    int len=strlen(str);
    long long ans=0;
    if(str[0]==str[1])
    {
        ans=6;
    i=2;
    flag=1;
    }
    else {
            ans=3;
    flag=2;
    i=1;
    }
    while(i<len)
    {
    if(flag==2)
    {
    if(str[i]!=str[i+1])
    {
    ans=(ans*2)%mod;
    i++;
    flag=2;
    }
    else if(str[i]==str[i+1])
    {
    flag=1;
    ans=(ans*2)%mod;
    i+=2;
    }
    }
    else if(flag==1)
    {
    if(str[i]!=str[i+1])
    {
    ans=(ans*1)%mod;
    i++;
    flag=2;
    }
    else if(str[i]==str[i+1])
    {
    flag=1;
    ans=(ans*3)%mod;
    i+=2;
    }
    }
    }
    cout<<ans<<endl;
    }


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

using namespace std;

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef long long ll;
typedef pair<int, int> pii;

const int N = 105;
const int V = 1e5 + 5;
int dp[2][V];
int w[N], v[N];
int n, W;


int main() {

#ifndef ONLINE_JUDGE
//    freopen("in.in", "r", stdin);
    //freopen("out.in", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> W;
    range(i, 1, V - 1)dp[n & 1][i] = W + 2;

    loop(i, n)cin >> w[i] >> v[i];

    rloop(i, n - 1) {
        loop(j, V) {
            dp[i & 1][j] = dp[i & 1 ^ 1][j];
            if (j >= v[i])dp[i & 1][j] = min(dp[i & 1][j], dp[i & 1 ^ 1][j - v[i]] + w[i]);
        }
    }

    int ans = 0;
    rloop(i, V - 1) {
        if (dp[0][i] <= W) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication33
{
    class Program
    {
        static void Main()
        {
            while (true)
            {
                string r = Console.ReadLine();
                if (r == null) break;
                string[] a = r.Split();
                for (int b = 2; b < a.Length; b++)
                {
                    if (a[1] == null) break;
                    if (!char.IsDigit(a[b][0]) && a[b].Length == 1)
                    {
                        switch (a[b][0])
                        {
                            case '+': a[b - 2] = (decimal.Parse(a[b - 2]) + decimal.Parse(a[b - 1])).ToString(); break;
                            case '*': a[b - 2] = (decimal.Parse(a[b - 2]) * decimal.Parse(a[b - 1])).ToString(); break;
                            case '-': a[b - 2] = (decimal.Parse(a[b - 2]) - decimal.Parse(a[b - 1])).ToString(); break;
                            default: a[b - 2] = (decimal.Parse(a[b - 2]) / decimal.Parse(a[b - 1])).ToString(); break;
                        }
                        for (int i = b - 1; i < a.Length; i++)
                        {
                            try { a[i] = a[i + 2]; }
                            catch { a[i] = null; }
                        }
                        b = 1;
                    }
                    if (a[1] == null) break;
                }
                Console.WriteLine(a[0]);
            }
        }
    }
}

Measured memory_bytes: 9888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    
    int ans = 0;
    for(int i = 0; i <= a; i++){
        for(int j = 0; j <= b; j++){
            for(int k = 0; k <= c; k++){
                int total = i * 500 + j * 100 + k * 50;
                if(total == x)
                    ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    string s;
    cin>>s;
    int i,ans=0;
    for (i=0;i<s.size()-1;i++)
    {
        if (s[i]!=s[i+1])
            ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <string.h>
#include <algorithm>
#include <bitset>
#include <iostream>
#include <sstream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
inline string toString(const T &a) {
  ostringstream oss;
  oss << a;
  return oss.str();
};

typedef long long ll;

int main() {
  ll Q;
  cin >> Q;
  vector<ll> L(Q);
  vector<ll> R(Q);
  for (ll i = 0; i < Q; i++) {
    cin >> L[i] >> R[i];
  }

  ll N = 100000;
  // ll N = 10;

  vector<bool> isPrime(N + 1, true);
  // 0と1は素数ではない
  isPrime[0] = false;
  isPrime[1] = false;
  // 2からスタート
  for (ll i = 2; i <= N; i++) {
    if (isPrime[i] == false) continue;
    // 2は素数
    // 4, 6, 8, 10, ... は素数ではない
    // 3は素数
    // 6, 9, 12, 15, ... は素数ではない
    for (ll j = i * 2; j <= N; j += i) {
      isPrime[j] = false;
    }
  }

  vector<ll> sum(N + 2, 0);
  for (ll i = 0; i < N + 1; i++) {
    if (isPrime[i] && isPrime[(i + 1) / 2]) {
      sum[i + 1] = sum[i] + 1;
    } else {
      sum[i + 1] = sum[i];
    }
  }

  // for (auto s : sum) {
  //   cout << s << endl;
  // }

  for (ll i = 0; i < Q; i++) {
    ll l = L[i];
    ll r = R[i];

    cout << sum[r + 1] - sum[l] << endl;
  }

  return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    int a,b,sa; 
    cin>>a>>b;
    sa = max(a+b,a-b);
    sa = max(a*b,sa);
    cout<<sa;
    return 0;
}

Measured memory_bytes: 3152
#include<iostream>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cstdlib>

using namespace std;
int main(){

  string s,p;

  cin >> s >> p;


  for(int i=0;i<s.size();i++){
    bool match = true;

    for(int j=0,idx=i;j<p.size();j++,idx++){
      if(idx>=s.size()) idx=0;
      if(s[idx]!=p[j]){
        match = false;
        break;
      }
    }
    if(match){
      cout << "Yes" << endl;
      return 0;
    }
    
  }

  cout << "No" << endl;

}


Measured memory_bytes: 3216
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String result = "No";

		for(int i = 0; i < 26; i += 4) {
			if(i > N) {
				break;
			}else if((N - i) % 7 == 0) {
				result = "Yes";
				break;
			}
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 22736
#include <iostream>

using namespace std;

int main()
{
	int n;
	int arr[50];

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

	int sum = 0;
	for(int i=0 ; i<n-1 ; i++)
	{
		for(int j=i+1 ; j<n ; j++)
			sum += (arr[i]*arr[j]);
	}

	cout << sum;
	return 0;
}

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

#define INF 1e6

int main(){
  int N; cin >> N;
  vector<int> dp(N+1, INF);
  vector<int> cost(N+1, 0);
  for(int i=1; i<N+1; ++i){
    int a; cin >> a;
    cost[i]=a;
  }
  for(int i=1; i<N+1; ++i){
    if(i==1){
      dp[i] = 0;
    }else if(i==2){
      dp[i] = abs(cost[i]-cost[i-1]);
    }else if(i==3){
      dp[i] = min(dp[i-1]+abs(cost[i]-cost[i-1]), abs(cost[i]-cost[i-2]));
    }else{
      dp[i] = min(dp[i-1]+abs(cost[i]-cost[i-1]), dp[i-2]+abs(cost[i]-cost[i-2]));
    }
  }
  cout << dp[N] << endl;
  return 0;
}

Measured memory_bytes: 1024
from sys import stdin
import math

if __name__ == '__main__':
	n = stdin.readline()
	n = n.rstrip('\n')
	n = n.split(' ')
	n = [int(i) for i in n]
	n.sort()
	if (n[0] == n[1] and n[1] != n[2]) or (n[0] != n[1] and n[1] == n[2]):
		print('Yes')
	else:
		print('No')

Measured memory_bytes: 3064
# 2019/07/20

from heapq import heappop,heappush,heapify

n,m=map(int,input().split())
a=list(map(int,input().split()))
heapify(a)
bc=[]
for i in range(m):
    b,c=map(int,input().split())
    hq=(-c,b)
    heappush(bc,hq)



def cg(res):

    while bc:
        c,b=heappop(bc)
        c=-c
        while b and a:
            b-=1
            v=heappop(a)
            if c>v:res+=c
            else:
                res+=v
                return res
    return res
res=0
res=cg(res)
print(sum(a)+res)

Measured memory_bytes: 20856
"""
Writer: SPD_9X2
https://atcoder.jp/contests/agc030/tasks/agc030_b

列の左右からとっていく。
移動距離は、連続して同じ方からとった場合と前とは別方向からとった場合で異なる

1.連続してとった場合は、単純に前に取った要素との差が加わる
2.そうでない場合は、原点と前の要素の距離+原点と今回の要素の距離が加わる

左右で撮る場所を決めてしまった場合はどう？
同じ要素を取る場合、1を選んだ時の加算 < 2を選んだ時の加算は確定

多い方では、必ず1をその差分だけ？選ばなくてはいけない
2を選んだ方が得な要素は？

前に何を選んだかによらず、寄与を考える方法を考案する必要がある
2つの山には分けておこう。

なるべく後半に反対の山からもらう方が寄与が大きいのは当然。
よって、まず多い方の山を少ない方と同数にして、交互に行き来すれば最適？
→O(N**2)なので部分点か？

→ここから高速化 or 更に探索空間を減らせないか考える

累積和で高速化可能か？
→とりあえず部分点狙ってみよう

l==rのとき、lの右端 と rの左端のうち最小以外は全て2こ取れる
l>rのとき、lのr個と、rは2回取れる +　lのr+1を1回取れる
r<lの時は逆

dpで解けるのか？
"""

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

X = []

dl = []
dr = []

for i in range(N):

    x = int(input())
    dl.append(x)
    dr.append(L-x)

dls = [0]
drs = [0]

for i in range(N):

    dls.append(dls[-1] + dl[i])
    drs.append(drs[-1] + dr[-1-i])

ans = 0
for l in range(N+1):

    r = N-l
    if l==r:
        ans = max( ans , 2 * (dls[l] + drs[r]) - min(dl[l-1],dr[l]) )
    elif l > r:

        #先にLに行く場合は,lにr+1個行く。

        lsum = 2 * (dls[l] - dls[l-(r+1)]) - dl[l-1]
        rsum = 2 *  drs[r]

        ans = max(ans , lsum + rsum)

        #先にRに行く場合。lにr個いく

        lsum = 2 * (dls[l] - dls[l-r])
        rsum = 2 * (drs[r]) - dr[-1*r]

        ans = max(ans , lsum + rsum)
    else:

        #先にRに行く場合, rにl+1こいく

        rsum = 2 * (drs[r] - drs[r-(l+1)]) - dr[-1*r]
        lsum = 2 * (dls[l])

        ans = max(ans , lsum + rsum)

        #先にL

        rsum = 2 * (drs[r] - drs[r-l])
        lsum = 2 * (dls[l]) - dl[l-1]

        ans = max(ans , lsum + rsum)

print (ans)


        
        

    


Measured memory_bytes: 99544
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
    double x;
    cin >> x;
    int amount = 100, day = 0;
    while (amount < x) {
        amount += amount / 100;
        ++day;
    }
    cout << day;
}
//x=100*(1 + 0.01*n)

Measured memory_bytes: 3708
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n; // number of sticks
    cin >> n;
    vector<int> l(n,0); // distance of stick

    for(int i=0;i<n;++i){
        cin >> l[i];
    }
    sort(l.begin(),l.end());
    int ans = 0; // 三角形の個数
    for(int a=0;a<l.size();++a){
        for(int b=a+1;b<l.size();++b){
            for(int c=b+1;c<l.size();++c){
                if(l[a]+l[b] <= l[c]){
                    break;
                }
//                if(l[b]+l[c]>l[a] && l[c]+l[a]>l[b]){
                    ans++;
//                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int H[N+1];
    string Ans="Yes";
    for(int i=1;i<=N;i++)cin >> H[i];
    for(int i=1;i<N;i++){
        if(H[N-i]<=H[N-i+1]);
        else if(H[N-i]-1==H[N-i+1])H[N-i]-=1;
        else {
            Ans="No";
            break;
        }
    }
    cout << Ans << endl;
}


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

using namespace std;

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

    int n, a;
    cin >> n >> a;

    if(n % 500 <= a)
        cout << "Yes\n";
    else
        cout << "No\n";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		String str = sc1.next();
		int count = 0;
		int rest = 15 - str.length();

		for ( int i = 0 ; i < str.length() ; i++ ) {
			if(str.charAt(i) == 'o') {
				count++;
			}
		}

		if ((count + rest) >= 8) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

		sc1.close();

	}

}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  int g = 0;
  REP (i, s.length()) {
    if (s[i] == 'g') g++;
  }

  printf("%d\n", (g - ((int)s.length() - g)) / 2);
}


Measured memory_bytes: 512
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	a,b=MI()
	print(a*b)


if __name__ == "__main__":
	main()


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

std::array<std::string, 100> blues;
std::array<std::string, 100> reds;

int main() {
    int n;
    std::cin >> n;
    for (int i = 0; i < n; ++i) {
        std::cin >> blues[i];
    }
    int m;
    std::cin >> m;
    for (int i = 0; i < m; ++i) {
        std::cin >> reds[i];
    }
    int ret = 0;
    for (int i = 0; i < n; ++i) {
        auto word = blues[i];
        int score = 0;
        for (int i = 0; i < n; ++i) {
            if (word == blues[i]) {
                ++ score;
            }
        }
        for (int i = 0; i < m; ++i) {
            if (word == reds[i]) {
                -- score;
            }
        }
        ret = std::max(ret, score);
    }
    std::cout << ret << std::endl;
    return 0;
}


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

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


Measured memory_bytes: 256
import math

a,b,C = list(map(float, input().split()))

h = b * math.sin(math.radians(C))
L = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(C))) + a + b
S = a * h / 2

print("{:f}".format(S))
print("{:f}".format(L))
print("{:f}".format(h))



Measured memory_bytes: 5696
#define _CRT_SECURE_NO_WARNINGS

#include <vector>
#include <iostream>
#include <string>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <ctime>
#include <queue>
#include <deque>
#include <math.h>
#include <cmath>
#include <stack>
#include <algorithm>
#include <list>
#include <array>
#include <valarray>
#include <unordered_map>
#include <cassert>
#include <random>

using namespace std;

#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define all(a) a.begin(), a.end()
#define li long long
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)

double eps = 1e-9;
const long long INF = 1e9 + 7;
const int MOD = 998244353;

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

	int n;
	cin >> n;

	multiset<int> d;
	forn(i, n) {
		int x;
		cin >> x;
		d.insert(x);
	}

	int m;
	cin >> m;

	forn(i, m) {
		int x;
		cin >> x;
		auto it = d.find(x);
		if (it != d.end())
			d.erase(it);
		else {
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;
}

Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
  int a, b, c;
  cin >> a >> b >> c;
  int sum = a + b + c;
  if(sum >= 22) cout << "bust" << endl;
  else cout << "win" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{

int a[10000], min, max, n, i;
long long sum = 0;
scanf("%d", &n);//1以上が入力されるものとします
for(i = 0; i < n; i++){
scanf("%d", &a[i]);
sum += a[i];
}
max = min = a[0];//とりあえず最初の要素をセットしておく
for(i = 1; i < n; i++){//2番目以降の要素と比較
if(a[i] > max)max = a[i];
if(a[i] < min)min = a[i];
}
printf("%d %d %lld\n", min, max, sum);

return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>

int main( void )
{
  int a, b;
  scanf( "%d %d", &a, &b );
  if ( a < b ) {
    printf( "a < b\n" );
  }
  else if ( a > b ) {
    printf( "a > b\n" );
  }
  else {
    printf( "a == b\n" );
  }
  return 0;
}


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

using namespace std;
using ll = long long;
int main() {
    ll N;
    cin >> N;
    unordered_map<int, int> count;
    ll currentSum = 0;
    for (ll i = 0; i < N; ++i) {
        ll A;
        cin >> A;
        currentSum += A;
        ++count[A];
    }
    ll Q;
    cin >> Q;
    for (ll i = 0; i < Q; ++i) {
        ll B, C;
        cin >> B >> C;
        currentSum += count[B] * C - count[B] * B;
        count[C] += count[B];
        count[B] = 0;
        cout << currentSum << endl;
    }
    return 0;
}

Measured memory_bytes: 7044
# coding: utf-8
# Your code here!
N=int(input())
S=list(input())

if N%2==1:
    print("No")
else:
    a="".join(S[:N//2])
    b="".join(S[::-1][:N//2][::-1])
    if a==b:
        print("Yes")
    else:
        print("No")



Measured memory_bytes: 2940
#include <iostream>
#include <vector>

/*
unsigned long long order(unsigned long long n)
{
	std::vector<int> primes;
	int p = 2;
	while (n>1) {
		if (n % p == 0) {
			primes.push_back(p);
			do { n /= p; } while (n % p == 0);
		}
		p++;
	}
	
	unsigned long long res = 1;
	
	for (int i=0; i<primes.size(); i++) {
		res *= primes[i] - 1;
	}
	return res;
}
*/

unsigned long long order(unsigned long long a, unsigned long long m)
{
	unsigned long long x = 1;
	unsigned long long count = 0;
	do {
		x *= a;
		x %= m;
		count++;
	} while (x > 1);
	return count;
}
	
unsigned long long gcd(unsigned long long x, unsigned long long y) {
	if (x==0) return y;
	if (y==0) return x;
	if (x>y) return gcd(y, x%y);
	else return gcd(x, y%x);
}

unsigned long long lcm(unsigned long long x, unsigned long long y)
{
	return (x*y) / gcd(x, y);
}

unsigned long long lcm3(unsigned long long x, unsigned long long y, unsigned long long z)
{
	return lcm(x, lcm(y, z));
}

int main()
{
	unsigned long long a1, m1, a2, m2, a3, m3;
	while (true) {
		std::cin >> a1 >> m1 >> a2 >> m2 >> a3 >> m3;
		if (a1==0) break;
		//std::cout << lcm3(order(m1), order(m2), order(m3)) << std::endl;
		std::cout << lcm3(order(a1, m1), order(a2, m2), order(a3, m3)) << std::endl;
	}
	
	return 0;
}



Measured memory_bytes: 3080
function Main(input) {
    input = input.split("");
    sa = 753;
    for(j = 1; j <= 9; j++){
        for(i = 0; i < input.length - 2; i++){
            if(input[i] == String(j)){
                tikai = parseInt(input[i] + input[i+1] + input[i+2]);
                kari_sa = Math.abs(753-tikai)
                if(sa > kari_sa) sa = kari_sa;
            }
        }
    }
    console.log(sa);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
data = map(int,raw_input().split())

if data[0] < data[1]:
    if data[1] < data[2]:
        print "%d %d %d" %(data[0],data[1],data[2])
    elif data[0] < data[2]:
        print "%d %d %d" %(data[0],data[2],data[1])
    else:
        print "%d %d %d" %(data[2],data[0],data[1])
else:
    if data[0] < data[2]:
        print "%d %d %d" %(data[1],data[0],data[2])
    elif data[1] < data[2]:
        print "%d %d %d" %(data[1],data[2],data[0])
    else:
        print "%d %d %d" %(data[2],data[1],data[0])

Measured memory_bytes: 6424
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		int odd = 0;
		int two_x = 0;
		int four_x = 0;

		for(int i=0;i<N;i++) {
			int a = sc.nextInt();
			if(a % 2 == 1) {
				odd++;
			}else if(a % 4 == 0) {
				four_x++;
			}else {
				two_x++;
			}
		}

		if(odd - 1 > four_x) {
			System.out.println("No");
		}else if(odd - 1 == four_x) {
			if(two_x == 0) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}else {
			System.out.println("Yes");
		}
	}

}


Measured memory_bytes: 48164
import sys
X = int(input())
def is_prime(X):
    for i in range(2,X):
        if X % i == 0:
            return False
    return True
if is_prime(X):
    print(X)
    sys.exit(0)
else:
    while True:
        if X%2 == 0:
            X+=1
        else:
            if is_prime(X):
                print(X)
                sys.exit(0)
            X+=2

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){
  int N,M,X,Y;
  cin>>N>>M>>X>>Y;

  int maxX=X;
  for(int i=0;i<N;i++){
    int sx;
    cin>>sx;
    if(sx>maxX){
      maxX=sx;
    }
  }
  int minY=Y;
  for(int i=0;i<M;i++){
    int sy;
    cin>>sy;
    if(sy<minY){
      minY=sy;
    }
  }
  if(maxX<minY){
    cout<<"No War"<<endl;
  }else{
    cout<<"War"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
ll mod=1000000007;
#define vl vector<ll>
#define pl pair<ll,ll>
#define rep(i,b) for(ll i=0;i<b;i++)
#define all(v) (v).begin(),(v).end()
using namespace std;
int main(){
ll n,l,sum=0,dis=0,Min=100000000;
    cin>>n>>l;
    rep(i,n){
        sum+=l+i;
        if(Min>=abs(l+i)){
            Min=abs(l+i);
            dis=l+i;
        }
    }
    cout<<sum-dis<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define ULL unsigned long long

using namespace std;
template<class T> inline bool chmax(T& a, T b)
{
  if(a < b){
    a = b;
    return true;
  }
  return false;
}

bool make(vector<ULL>& A, ULL N, ULL M)
{
  if(N <= 0) return false;
  if(A[N-1] == M){
    if(make(A, N-1, M) == false) return false;
    A[N-1] = A[N-2] - 1;
  }
  A[N-1]++;
  return true;
}

int main()
{
  ULL N, M, Q;
  cin >> N >> M >> Q;
  
  vector<vector<ULL>> abcd(Q, vector<ULL>(4));
  for(ULL i = 0; i < Q; i++){
    cin >> abcd[i][0] >> abcd[i][1] >> abcd[i][2] >> abcd[i][3];
  }
  
  vector<ULL> A(N, 1);
  
  ULL ret = 0;
  for(ULL i = 0; i < Q; i++){
    if(A[abcd[i][1] - 1] - A[abcd[i][0] - 1] == abcd[i][2]){
      ret += abcd[i][3];
    }
  }
  
  while(make(A, N, M)){
    ULL score = 0;
    for(ULL i = 0; i < Q; i++){
      if(A[abcd[i][1] - 1] - A[abcd[i][0] - 1] == abcd[i][2]){
        score += abcd[i][3];
      }
    }
    chmax(ret, score);
  }
  
  cout << ret << endl;
}

Measured memory_bytes: 3632
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int N;
	int[] w,len = {5,7,5,7,7};

	public boolean dfs(int i,int k,int now){
		if(k == 5){
			return true;
		}

		if(now == len[k]){
			return dfs(i,k + 1,0);
		}

		if(i >= N)return false;
		if(now  < len[k]){
			return dfs(i + 1,k,now + w[i]);
		}else{
			return false;
		}
	}

	public void solve() {
		w = new int[40];
		while(true){
			N = nextInt();

			if(N == 0)break;
			for(int i = 0;i < N;i++){
				w[i] = next().length();
			}
			int ans = 0;
			for(int i = 0;i < N;i++){
				if(dfs(i,0,0)){
					ans = i + 1;
					break;
				}
			}
			out.println(ans);
		}
	}

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

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

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 25124
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;
const ll INF = (1ll << 60);
const ll MOD = 1e9 + 7;

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    vector<vector<ll>> dp(s.size(), vector<ll>(2, 0));
    dp[0][0] = 2;
    dp[0][1] = 1;

    rep(i, 1, s.size())
    {
        if (s[i] == '1')
        {
            dp[i][0] = (dp[i - 1][0] * 2) % MOD;
            dp[i][1] = (dp[i - 1][1] * 3 + dp[i - 1][0]) % MOD;
        }
        else
        {
            dp[i][0] = dp[i - 1][0];
            dp[i][1] = (dp[i - 1][1] * 3) % MOD;
        }
    }
    cout << (dp[s.size() - 1][0] + dp[s.size() - 1][1]) % MOD << endl;

    return 0;
}


Measured memory_bytes: 5760
#K = input()
NXT = list(map(int, input().split()))
#s = input().split()
#S = input()

unit = int(NXT[0] / NXT[1])

if (NXT[0] % NXT[1] == 0):
    print(unit * NXT[2])
else:
    print(unit * NXT[2] + NXT[2])

Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N+1);
  for(int i = 0; i < N + 1; i++){
    cin >> L.at(i);
  }
  int i = 1;
  int D = 0;
  while(D <= X && i <= N+1){
    D += L.at(i - 1);
    i++;
    
  }
  cout << i - 1 << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<math.h>
#include<queue>
using  namespace std;
long long a[2010][2014];
int main()
{
    long long n,m;
    long long i,j,k,flag,num[2016];
    scanf("%lld%lld",&n,&m);
    for(i=1;i<=n;i++)
        scanf("%lld",&num[i]);
    for(i=1;i<=n;i++){
        a[i][0]=num[i];
        for(k=1;k<=n-1;k++)
        {
            flag=i-k;
            if(flag<=0) flag=n+flag;
            a[i][k]=min(a[i][k-1],num[flag]);
        }
    }
    long long  minn=1e18;
    for(i=0;i<=n-1;i++){
        long long ans=0;
        for(j=1;j<=n;j++)
        {
            ans+=a[j][i];
        }
        minn=min(minn,ans+m*i);
    }
    printf("%lld\n",minn);
    return 0;
}


Measured memory_bytes: 31744
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
using ll =long long;

int main (void) {
  int N;
	scanf("%d\n",&N);
  int x=0;
  int ans=0;
  while (N--)
  {
    char c = getchar();
    x+=c=='I'?1:-1;
    if (x>ans) ans=x;
  }
	printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
#define spn setprecision
#define fr(x,a,b,c) for(int x = a; x <= b; x+=c)
using namespace std;
ll multiply(ll num1, ll num2, ll mod) { // with mod > 1e9
	ll ans = 0;
	num1 %= mod;
	num2 %= mod;
	while (num2) {
		if (num2&1) {
			ans += num1;
			ans %= mod;
		}
		num1 *= 2;
		num1 %= mod;
		num2 /= 2;
	}
	return ans;
}
ll powmod2(ll base,ll exponent,ll mod){ // with mod > 1e9
	ll ans = 1;
	while (exponent) {
		if (exponent&1) {
			ans = multiply(ans, base, mod);
		}
		base = multiply(base, base, mod);
		exponent /= 2;
	}
	return ans;
}
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
int main() {
	int n,m;
	sd(n);
	sd(m);
	if((n>8)||(m>8)){
		printf(":(");
	}
	else{
		printf("Yay!\n");
	}
	return 0;
}

Measured memory_bytes: 256