akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#ifndef M_PI
const double M_PI=acos(-1);
#endif
using namespace std;
static const double EPS = 1e-8;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};

ll dp[16][16];

main(){
  int test;
  cin>>test;
  while(test--){
    int gx,gy,p;
    cin>>gx>>gy>>p;
    set<pair<PI,PI> >app;
    rep(i,p){
      int x1,y1,x2,y2;
      cin>>x1>>y1>>x2>>y2;
      if(x1>x2)swap(x1,x2);
      if(y1>y2)swap(y1,y2);
      app.insert(mp(mp(x1,y1),mp(x2,y2)));
    }
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int x=0;x<=gx;x++){
      for(int y=0;y<=gy;y++){
        if(x && !app.count(mp(mp(x-1,y),mp(x,y))))dp[x][y]+=dp[x-1][y];
        if(y && !app.count(mp(mp(x,y-1),mp(x,y))))dp[x][y]+=dp[x][y-1];
      }
    }
    if(dp[gx][gy]==0)cout<<"Miserable Hokusai!"<<endl;
    else cout<<dp[gx][gy]<<endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int N,arr[10005],s=1,ans=0;
int main(){
	scanf("%d",&N);
	for(int i=1;i<=N;i++){ scanf("%d",&arr[i]);	} arr[N+1]=10001;
	for(int i=1;i<=N;i++){
		if(arr[i]!=arr[i+1]){
			ans+=(i-s+1)/2;
			s=i+1;
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
int main()
{
    long long s,c;
    scanf("%lld %lld",&s,&c);
    if (2*s>=c) {
        printf("%lld",c/2);
        return 0;
    }
    if (2*s<c) {
        c=c-2*s;
        c=c/4;
        printf("%lld",c+s);
        return 0;
    }
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int r, g;cin >> r >> g;
    cout << 2*g - r << endl;
    return 0;
}


Measured memory_bytes: 256
from operator import itemgetter, attrgetter

N = int(input())
shoplist = []
i = 0
for i in range(N):
	tmplist = input().split(" ")
	shoplist.append(list())
	shoplist[i].append(tmplist[0])
	shoplist[i].append(int(tmplist[1]))
	shoplist[i].append(i+1)

s1 = sorted(shoplist, key = itemgetter(1), reverse = True)
s2 = sorted(s1, key = itemgetter(0))
for i in range(N):
	print(s2[i][2])



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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;
const int K = 500;
const int maxN = 50;

int rec(int n) {
	if (!n) return 0;
	return rec(n / 2) * 2 + 1;
}

void solve() {
	int h;
	cin >> h;
	cout << rec(h);
}

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;


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

    int X;
    cin >> X;
    for(int i=-1000;i<=1000;i++){
        int Y;
        Y = X + i*i*i*i*i;
        if(Y <= 0) continue;
        for(int j=1;j<=2000;j++){
            int Z = j*j*j*j*j;
            if(Y == Z){
                cout << j << ' ' << i << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e5)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
} 

int main()
{
    ll A, B;
    cin >> A >> B;
    ll cnt = 0;
    ll sum = 1;
    while(sum < B) {
        sum += A-1;
        cnt++;
    }
    print(cnt);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846;

int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m; //a:時針、b:分針

    //円周率の定義
    double theta, fay;                        //θ：時針の角度、φ：分針の角度、の定義
  
    //角度の計算
    theta = (60 * h + m) * 2 * PI / 720;
    fay = (60 * h + m) *  2 * PI / 60;

    //端点の位置特定
    double Rx = a * cos(theta);
    double Ry = a * sin(theta);
    double rx = b * cos(fay);
    double ry = b * sin(fay);

    //相対位置の評価
    double dx = abs(Rx - rx);
    double dy = abs(Ry - ry);

    //距離計算
    double d = sqrt(dx * dx + dy * dy);
    cout << fixed << setprecision(16);
    cout << d << endl;
}

Measured memory_bytes: 4084
#include <iostream>
#include <string>
#define int long long
using namespace std;

int n, i, j;

signed main() {
	while (cin >> n >> i >> j) {
		if (!n) { break; }
		i--; j--;
		
		string ans;
		while (n > 0) {
			if (i % 2 == j % 2) ans += 'L';
			else ans += 'R';
			if (i < (1LL << (n - 1))) i = (1LL << (n - 1)) - 1 - i;
			else i -= (1LL << (n - 1));
			n--;
			j /= 2;
		}
		for (int k = ans.length() - 1; k >= 0; k--) {
			cout << ans[k];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3176
while str = gets do
  num = str.chomp.to_i
  break if num == 0
  a = 0
  b = 0
  num.times do |n|
    x, y = gets.chomp.split(" ").map(&:to_i)
    if x > y
      a += x + y
    elsif x < y
      b += x + y
    else
      a += x
      b += y
    end
  end
  puts [a, b].join(" ")
end

Measured memory_bytes: 8804
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
const int day=86400;

int main(){
	while(1){
		int n;
		cin >> n;
		if(n==0) break;
		
		vector<int> v(day,0);
		for(int i=0; i<n; i++){
			for(int s=0; s<2; s++){
				string tmp;
				cin >> tmp;
				int sec=0;
				for(int j=0,r=3600; j<9; j+=3,r/=60){
					tmp[j+2] = 0;
					sec += atoi(&tmp[j])*r;
				}
				v[sec] += -2*s+1;
			}
		}
		
		int ans=0;
		for(int i=1; i<day; i++){
			v[i] += v[i-1];
			ans = max(ans, v[i]);
		}
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;

int main(){
  long long N; cin>>N;

  vector<long long> a(N);
  for(long long i=0;i<N;i++) cin>>a[i];

  sort(a.begin(),a.end());
  long long ans=0;
  long long i=0;
  while(i<N){
    long long count=0;
    long long temp=a[i];
    for(volatile long long j=i;j<N;j++){
      if(temp!=a[j]){
        i=j;
        break;
      }
      count++;
      if(j==N-1){i=j; break;}
    }
    if(temp!=count){
      ans+=((count>temp)?count-temp:count);
    }
    if(i==N-1&&temp==a[i]) break;
  }

  cout<<ans<<endl;

  return 0;
}


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

typedef long long int ll;

int main()
{
	ll n;
	scanf("%lld",&n);
	ll ans=0;
	for(ll i=1;i<=n;i++)
	{
		if((i%3)!=0 && (i%5)!=0)
		{
			ans+=i;
		}
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 3764
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()
s = input()

a=0
i=0
j=1

while j<n:
    if s[i:j] in s[j:]:
        a = max(a,len(s[i:j]))
        j+=1
    else:
        i+=1
    if i==j:
        i+=1
        j+=2

print(a)

Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
using namespace std;
typedef long long int ll;
using ull = unsigned long long;


mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int last[26];
int c[26];
int s[365][26];
int a[365];

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int d; cin >> d;
    for(int i=0;i<26;i++){
    	cin >> c[i];
    }
    for(int i=0;i<d;i++){
    	for(int j=0;j<26;j++){
    		cin >> s[i][j];
    	}
    }
    for(int i=0;i<d;i++){
    	int mx=0;
    	int id=0;
    	for(int j=0;j<26;j++){
    		if(mx<(i+1-last[j])*c[j]*5+s[i][j]){
    			mx=(i+1-last[j])*c[j]*5+s[i][j];
    			id=j;
    		}
    	}
    	a[i]=id+1;
    	last[id]=i+1;
    }
    for(int i=0;i<26;i++){
    	last[i]=0;
    }
    int res=0;
    for(int i=0;i<d;i++){
    	res+=s[i][a[i]-1];
    	last[a[i]-1]=i+1;
    	for(int j=0;j<26;j++){
    		res-=c[j]*(i+1-last[j]);
    	}
    }
    for(int i=0;i<1e6;i++){
    	int day,qq;
    	day=myRand(d)+1;
    	qq=myRand(26)+1;
    	int resres=res;
    	int qqq=a[day-1];
        last[qq-1]=last[qqq-1]=0;
        for(int i=0;i<d;i++){
            if(a[i]==qq){
                last[a[i]-1]=i+1;
            }
            if(a[i]==qqq){
                last[a[i]-1]=i+1;
            }
            resres+=c[qq-1]*(i+1-last[qq-1]);
            resres+=c[qqq-1]*(i+1-last[qqq-1]);
        }
        a[day-1]=qq;
        resres-=s[day-1][qqq-1];
        resres+=s[day-1][qq-1];
        last[qq-1]=last[qqq-1]=0;
        for(int i=0;i<d;i++){
            if(a[i]==qq){
                last[a[i]-1]=i+1;
            }
            if(a[i]==qqq){
                last[a[i]-1]=i+1;
            }
            resres-=c[qq-1]*(i+1-last[qq-1]);
            resres-=c[qqq-1]*(i+1-last[qqq-1]);
		}
		if(resres>=res){

		}
		else{
			a[day-1]=qqq;
		}
    }
    for(int i=0;i<d;i++){
    	printf("%d\n",a[i]);
    }
}



Measured memory_bytes: 3796
#include <stdio.h>

int F[50];

int fibonacci(int n)
{
  if( n==0 || n==1 ){
    F[n] = 1;
    return F[n];
  }
  if( F[n]!=-1 )
    return F[n];
  F[n]=fibonacci(n-1)+fibonacci(n-2);
  return F[n];
}

int main()
{
  int n,i;

  for( i=0 ; i<50 ; i++ )
    F[i]=-1;

  scanf("%d",&n);
  
  printf("%d\n",fibonacci(n));

  return 0;
  
}



Measured memory_bytes: 2112
program EDPCA
    implicit none
    integer(8)::N,i
    integer(8),allocatable,dimension(:)::H,dp
    read(5,*)N
    allocate(H(N))
    allocate(dp(N))
    read(5,*)(H(i),i=1,N)
    dp=0

    do i=1,N
        if(i==2)then
            dp(i)=abs(H(i)-H(i-1))
        else if(i>2)then
            dp(i)=min(dp(i-1)+abs(H(i)-H(i-1)),dp(i-2)+abs(H(i)-H(i-2)))
        end if
    end do

    print'(i0)',dp(N)
end program EDPCA

Measured memory_bytes: 2304
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

  ll n,m,s; cin>>n>>m>>s;
  struct Train {
    ll s, c, d;
    Train(ll s,ll c,ll d):s(s),c(c),d(d){}
    bool operator>(const Train& x) const {return d>x.d;}
  };
  vector<Train> graph[n];
  for (int i = 0; i < m; i++) {
    ll u,v,a,b; cin>>u>>v>>a>>b; u--; v--;
    graph[u].emplace_back(v,a,b);
    graph[v].emplace_back(u,a,b);
  }
  for (int i = 0; i < n; i++) {
    int c,d; cin>>c>>d;
    graph[i].emplace_back(i,-c,d);
  }
  constexpr ll MAX = 200;
  constexpr ll INF = 1e18;
  vector<array<ll, MAX+1>> dp(n);
  for (auto& arr:dp) arr.fill(INF);
  dp[0][min(s,MAX)] = 0;
  priority_queue<Train, vector<Train>, greater<>> qs;
  qs.emplace(0,s,0);
  while (not qs.empty()) {
    auto [s,c,d] = qs.top(); qs.pop();
    if (d > dp[s][min(c,MAX)]) continue;
    for (auto t:graph[s]) {
      if (c-t.c<0) continue;
      if (d+t.d >= dp[t.s][min(c-t.c,MAX)]) continue;
      dp[t.s][min(c-t.c,MAX)] = d+t.d;
      qs.emplace(t.s, c-t.c, d+t.d);
    }
  }
  for (int i = 1; i < n; i++) {
    cout << *min_element(dp[i].begin(), dp[i].end()) << '\n';
  }

  return 0;
}


Measured memory_bytes: 3836
W=[]
K=[]
i=0
while i<10:
    s=int(input())
    W.append(s)
    i+=1
W.sort()
while 10<=i and i<20:
    s=int(input())
    K.append(s)
    i+=1
K.sort()
sum1=0
sum2=0
for i in range(7,10):
    sum1+=W[i]
for i in range(7,10):
    sum2+=K[i]
print(f'{sum1} {sum2}')


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;


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

	ll a,p;
	cin >> a >> p;
	p += a*3;
	cout << p/2 << endl;
}


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

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

  int tmp, ans = 753;
  for (int i = 0; i < s.size() - 2; i++) {
    tmp = (s[0+i] - '0') * 100 + (s[1+i] - '0') * 10 + s[2+i] - '0';
    ans = min(ans, abs(tmp - 753));
  }

  cout << ans << endl;
}


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

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

    string X;
    cin >> X;
    int cnt = 0;
    int res = X.size();
    for(int i=0; i<X.size(); i++){
        if(X[i] == 'S') cnt++;
        else if(X[i] == 'T' && cnt > 0){
            cnt--;
            res-=2;
        }
    }
    cout << res << endl;


	return 0;
}


Measured memory_bytes: 720
// https://atcoder.jp/contests/

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

ll N, M, a, b, cnt;
vector<set<int>> g;

void search(int s, set<int> v)
{
  if (v.find(s) != v.end())
    return;

  v.insert(s);
  if (v.size() == N)
  {
    cnt++;
    return;
  }

  for (auto &p : g[s])
    search(p, v);
}

int main()
{
  set<int> s;
  cnt = 0;

  cin >> N >> M;
  REP(i, N)
  {
    g.push_back(s);
  }
  REP(i, M)
  {
    cin >> a >> b;
    g[a - 1].insert(b - 1);
    g[b - 1].insert(a - 1);
  }

  search(0, s);

  cout << cnt << '\n';

  return 0;
}


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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		String[] inputStr = null;
		int[] inputInt = null;
		while(true) {
			try {
				inputStr = (input.readLine()).split(" ");
				inputInt = new int[inputStr.length];
				for (int i = 0; i < inputInt.length; i++) {
					inputInt[i] = Integer.parseInt(inputStr[i]);
				}
				if(inputInt[0] == 0 && inputInt[1] == 0) {
					break;
				}
				for (int row = 0; row < inputInt[0]; row++) {
					for (int col = 0; col < inputInt[1]; col++) {
						if (((row % 2 != 0) && (col % 2 == 0)) || ((row % 2 == 0) && (col % 2 != 0)) ) {
							System.out.print(".");
						} else {
							System.out.print("#");
						}
					}
					System.out.println();
				}
				System.out.println();
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
		}
	}

}



Measured memory_bytes: 31060
#include<bits/stdc++.h>
using namespace std;
int main(){
  string A,B;cin>>A>>B;
  int N=A.size(),flag=0;
  for(int i=0;i<N;i++){
    A=A.substr(1)+A.at(0);
    if(A==B)flag++;
  }
  if(flag==0)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using ll=long long;
using ld=long double;
#define INF 1000000009
const ll INFll=1ll*INF*INF;
#define MOD 998244353
#define MODE 1000000007
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define pb push_back
#define mp make_pair
#define rep(i,n) for (ll i = 0; i < n; i++)
#define rev(i,n) for (ll i = n-1; i >= 0; i--)
#define REP(i,a,b) for (ll i = a; i < b; i++)
#define REV(i,a,b) for (ll i = a; i >= b; i--)
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define vl vector<ll>
#define pll pair<ll,ll>
#define sz(a) (ll)a.size()
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << ' '; cout << endl;
#define printii(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << it->f<<' '<<it->s << endl; cout << endl;
#define MID(i,j) ((i)+(j))/2
#define nl '\n' 
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define int ll
ll gcd(ll a,ll b)  {return (b==0)? a:gcd(b,a%b);}

ll bpow(ll a, ll b, ll m) {
  a %= m;
  ll res = 1;
  while (b > 0) {
    if (b & 1)res = res * a % m;
    a = a * a % m;
    b >>= 1;
}
return res;
}


void solve() {
    int n, m;
    cin >> n >> m;
    vector<int>v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    vector<bool>dp(m+1);
    for(int i = 0; i < m+1; i++){
        for(int x : v){
            if(i >= x && !dp[i-x])dp[i] = 1;
        }
    }
    if(dp[m] == 0){
        cout << "Second" << endl;
    }
    else{
        cout << "First" << endl;
    }

}

// DONT GET TLE FOR NOT USING FASTIO (--__--)

signed main(){
	fastio;
    ll t = 1;
    // cin >> t;
    rep(i, t){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m,c;
  cin >> n >> m >> c;
  vector<int> b(m);
  vector<vector<int>> a(n,vector<int>(m));
  int ans =0;
  for(int i = 0;i<m;i++){
    cin >> b.at(i);
  }
  for(int i = 0;i<n;i++){
    for(int j = 0;j<m;j++){
      cin >> a.at(i).at(j);
    }
  }
  for(int i=0;i<n;i++){
    int sum = 0;
    for(int j =0;j<m;j++){
      sum += a.at(i).at(j)*b.at(j);
    }
    if((sum + c )> 0){
      ans +=1;
    }
  }
  cout << ans;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
 
typedef uint64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;
 
 
int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	vector<ll> a(n);
	rep(i,n) cin >>a[i];
	map<ll,int> mp;
	rep(i,n) mp[a[i]]++;
	ll mx1=0, mx2=0;
	for(auto x: mp){
		if(x.second < 2) continue;
		if(mx1 < x.first){ mx2 = mx1; mx1 = x.first;}
		else if(mx2 < x.first) mx2 = x.first;
	}
	if(mp[mx1] >=4){cout << mx1*mx1 <<"\n"; return 0;}
	cout <<mx1 * mx2 <<"\n";
	return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,T,A;
    cin>>N>>T>>A;
    T*=1000;A*=1000;
    
    int index,delta=INT_MAX;
    for(int i=0;i<N;++i){
        int h;
        cin>>h;
        int d=abs(T-h*6-A);
        if(d<delta){
            index=i;
            delta=d;
        }
    }
    
    cout<<index+1<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

ll n, m;
string a, b;

ll hgcd (ll x, ll y){
    while(y) {
        x %= y;
        swap(x,y);
    }
    return x;
}

int main() {
    cin >> n >> m >> a >> b;
    ll ans = n*m/hgcd(n,m);
    ll aa = ans/m, bb = ans/n;
    ll _a = 0, _b = 0;
    for (int i = 0; i < hgcd(n,m); i++) {
        if (a[_a] != b[_b]) {
            puts("-1");
            return 0;
        }
        _a += aa;
        _b += bb;
    }
    cout << ans << endl;
}



Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <random>
#include <map>
using namespace std;

const double pi = acos(-1);
#define nyan cout << "(=^•ω•^=)" << endl;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop while(true)
#define YN(f) f?cout<<"YES"<<endl:cout<<"NO"<<endl;
#define yn(f) f?cout<<"Yes"<<endl:cout<<"No"<<endl;

int ans;

signed main(){
	string s;cin>>s;
	for(int i=0;i<s.length();i++)if(s[i]=='2')ans++;
	cout<<ans<<endl;
	return 0;
}

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

int x, y, z;

int main() {
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y << endl;
  return 0;
}

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

using namespace std;
int main(void){
    // Your code here!
    string s;
    cin>>s;
    cout<<s[0]<<s[1]<<s[2]<<s[3]<<s[4]<<" "<<s[6]<<s[7]<<s[8]<<s[9]<<s[10]<<s[11]<<s[12]<<" "<<s[14]<<s[15]<<s[16]<<s[17]<<s[18]<<endl;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			scanner.nextInt();
			scanner.nextLine();
			Set<Integer> commonSet = new HashSet<>();
			for (int i = 0; i < n; i++) {
				int number = scanner.nextInt();
				Set<Integer> set = new HashSet<>();
				for (int j = 0; j < number; j++) {
					set.add(scanner.nextInt());
				}
				scanner.nextLine();
				if (0 == i) {
					commonSet.addAll(set);
				} else {
					Set<Integer> removeSet = new HashSet<>();
					for (Integer integer : commonSet) {
						if (!set.contains(integer)) {
							removeSet.add(integer);
						}
					}
					commonSet.removeAll(removeSet);
				}
			}
			System.out.println(commonSet.size());
		}
	}
}


Measured memory_bytes: 24916
N, x = map(int, input().split())
A = sorted(list(map(int, input().split())))

for i in range(1, N+1):
    if sum(A[:i]) == x:
        print(i)
        quit()
    if sum(A[:i]) > x:
        print(i-1)
        quit()
print(N - 1)

Measured memory_bytes: 38512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = a; i < b; i++)
#define rep(i, n) FOR(i, 0, n)
#define rFOR(i, a, b) for(ll i = a - 1; i >= b; i--)
#define rrep(i, a) rFOR(i, a, 0)
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ld PI = acos(-1);
const ll INF = 1e18;
struct edge{ll to, cost;};

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
      a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vl A(N),B(N);
    vl cnt0(N),cnt1(N);
    vl cnt(N);
    vP p(N);
    rep(i,N){
        cin >> A[i];
        A[i]--;
        cnt0[A[i]]++;
    }
    rep(i,N){
        cin >> B[i];
        B[i]--;
        cnt1[B[i]]++;
    }
    rep(i,N){
        if(cnt0[i]+cnt1[i]>N){
            cout << "No" << '\n';
            return 0;
        }
    }
    cout << "Yes" << '\n';
    reverse(B.begin(),B.end());
    int right=0,left=N-1;
    rep(i,N){
        if(A[i]!=B[i])continue;
        else if(A[right]!=B[i]&&B[right]!=A[i]){
            swap(B[i],B[right]);
            right++;
        }
        else{
            swap(B[i],B[left]);
            left--;
        }
    }
    rep(i,N){
        cout << B[i]+1 << (i==N-1?'\n':' ');
    }
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/


Measured memory_bytes: 14276
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

ll dp[2009][2009]; // dp[i][j] : i個の箱にj個の玉を振り分ける場合の数
				   // 各箱には0個以上

// combination_table
// パスカルの三角形
ll Com[2009][2009]; // C[n][k] = nCk

void combination_table(int N) {
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= i; j++) {
			if (j == 0 || j == i) Com[i][j] = 1LL;
			else {
				Com[i][j] = Com[i - 1][j] + Com[i - 1][j-1];
				Com[i][j] %= MOD;
			}
		}
	}
}

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

	int N, K; cin >> N >> K;

	combination_table(2000);

	/*
	for (int i = 0; i <= 2000; i++) dp[i][0] = 1;
	for (int i = 0; i <= 2000; i++) {
		for (int j = 1; j <= N; j++) {
			dp[i][j] = dp[i][j - 1] * i;
			dp[i][j] %= MOD;
		}
	}
	*/

	for (int i = 1; i <= K; i++) {
		if (N - K + 1 < 0) {
			if (i == 1) cout << 1 << endl;
			else cout << 0 << endl;
		}
		else {
			ll ans = Com[K - 1][min(i - 1, K - i)] * Com[N - K + 1][min(i, N - K - i + 1)];
			cout << ans % MOD << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
#define ll long long
#define maxn 105 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second
using namespace std;
int n, m;
char inp[maxn][maxn];
int dp[maxn][maxn];
int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		scanf("%s", inp[i]);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			if (i == 0 && j == 0) dp[i][j] = 0;
			else {
				dp[i][j] = maxn * maxn;
				if (i) {
					int rs = dp[i - 1][j] + (inp[i - 1][j] != inp[i][j]);
					dp[i][j] = min(dp[i][j], rs);
				}
				if (j) {
					int rs = dp[i][j - 1] + (inp[i][j - 1] != inp[i][j]);
					dp[i][j] = min(dp[i][j], rs);
				}
			}
	int res = dp[n - 1][m - 1];
	if (inp[0][0] == '#') res++;
	if (inp[n - 1][m - 1] == '#') res++;
	res++;
	res /= 2;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <string>

#include <iostream>

using namespace std;

int main(){
	int c=0;
	string s;

	cin >> s;

	int left=0, right;
	right=(int)s.size() - 1;


	while(left < right){
		if(s[left] == s[right]){
			left++;
			right--;
		}else if(s[left] == 'x'){
			left++;
			c++;
		}else if(s[right] == 'x'){
			right--;
			c++;
		}else{
			cout << -1 << endl;
			return 0;
		}
	}

	cout << c << endl;

	return 0;
}

Measured memory_bytes: 512
import java.math.BigInteger;
import java.util.*;
public class Main {
	//模範解答の理解度確認
	static public HashMap<Long, BigInteger> memo = new HashMap<Long, BigInteger>();
	static public long a, b, c, d;

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 文字列の入力
		String[] lineString = sc.nextLine().split(" ");
		int t = Integer.parseInt(lineString[0]);

		for (int test = 0; test < t; test++) {
			lineString = sc.nextLine().split(" ");
			memo.clear();
			a = Long.parseLong(lineString[1]);
			b = Long.parseLong(lineString[2]);
			c = Long.parseLong(lineString[3]);
			d = Long.parseLong(lineString[4]);
			System.out.println(solve(Long.parseLong(lineString[0])).toString());
		}

		// 出力
		sc.close();
	}

	static public BigInteger solve(long n) {
		if (n == 0) {
			return BigInteger.ZERO;
		} else if (n == 1) {
			return BigInteger.valueOf(d);
		} else if (memo.containsKey(n)) {
			return memo.get(n);
		} else {
			long l2 = n / 2;
			long r2 = l2 + 1;
			long l3 = n / 3;
			long r3 = l3 + 1;
			long l5 = n / 5;
			long r5 = l5 + 1;

			BigInteger result = BigInteger.valueOf(n).multiply(BigInteger.valueOf(d));

			result = result.min(BigInteger.valueOf(Math.abs(n - l2 * 2)).multiply(BigInteger.valueOf(d)).add(BigInteger.valueOf(a)).add(solve(l2)));
			if (n % 2 > 0) {
				result = result.min(BigInteger.valueOf(Math.abs(n - r2 * 2)).multiply(BigInteger.valueOf(d)).add(BigInteger.valueOf(a)).add(solve(r2)));
			}

			result = result.min(BigInteger.valueOf(Math.abs(n - l3 * 3)).multiply(BigInteger.valueOf(d)).add(BigInteger.valueOf(b)).add(solve(l3)));
			if (n % 3 > 0) {
				result = result.min(BigInteger.valueOf(Math.abs(n - r3 * 3)).multiply(BigInteger.valueOf(d)).add(BigInteger.valueOf(b)).add(solve(r3)));
			}

			result = result.min(BigInteger.valueOf(Math.abs(n - l5 * 5)).multiply(BigInteger.valueOf(d)).add(BigInteger.valueOf(c)).add(solve(l5)));
			if (n % 5 > 0) {
				result = result.min(BigInteger.valueOf(Math.abs(n - r5 * 5)).multiply(BigInteger.valueOf(d)).add(BigInteger.valueOf(c)).add(solve(r5)));
			}

			memo.put(n, result);
			return result;
		}
	}
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define fi first
#define se second

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int main() {
    int n,k;
    cin>>n>>k;
    vector<pair<ll,ll>> p;
    rep(i,n){
        ll x,y;
        cin>>x>>y;
        p.push_back({x,y});
    }
    ll ans=5e18;
    rep(i,n){
        rep(j,n){
            rep(l,n){
                rep(m,n){
                    ll xmin=min(p[i].fi,min(p[j].fi,min(p[l].fi,p[m].fi)));
                    ll ymin=min(p[i].se,min(p[j].se,min(p[l].se,p[m].se)));
                    ll xmax=max(p[i].fi,max(p[j].fi,max(p[l].fi,p[m].fi)));
                    ll ymax=max(p[i].se,max(p[j].se,max(p[l].se,p[m].se)));
                    int b=1;
                    int c=0;
                    rep(o,n){
                        if (xmin<=p[o].fi && xmax>=p[o].fi && ymin<=p[o].se && ymax>=p[o].se){
                            c++;
                        }
                    }
                    if (c>=k){
                        ans=min(ans,(xmax-xmin)*(ymax-ymin));
                    }
                }
            }
        }
    }
    cout<<ans<<endl;



    return 0;
}

Measured memory_bytes: 256
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int r, d, a;
    cin >>r >>d >>a;
    int ans = r * a - d;
    for(int i = 1; i < 11; i++){
        cout <<ans <<"\n";
        ans = r * ans - d;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC targett("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(ll i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 4e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time"<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//_______________________________________________________________________________
int main()
{
       ll n,k;
       cin>>n>>k;
       ll a[n+1];
       fri(i,1,n+1){cin>>a[i];}
       bool vis[n+2];
       memset(vis,false,sizeof vis);
       ll curr = 1;
       ll timer[n+2];
       ll ct = 1;
       ll len;
       ll cv;
       while(1)
       {
              if(k == 0){
                     cout<<curr<<endl;
                     return 0;
              }
              if(vis[curr])
              {
                     //k--;
                     len = ct - timer[curr] ;
                     cv = curr;
                     break;
              }
              vis[curr] = true;
              timer[curr] = ct;
              ct++;
              curr = a[curr];
              k--;
       }
       k %= len;
       int ii = 0;
       while(ii < k)
       {
              ii++;
              cv = a[cv];
       }
       cout<<cv<<endl;
}


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

#define N_MAX 100
#define WH 0
#define GR 1
#define BK 2

long n;
long ttime = 0;
long G[N_MAX][N_MAX] = {};
long D[N_MAX], F[N_MAX];
long color[N_MAX] = {};

void dfs_rec(long u) {
    color[u] = GR;
    ttime++;
    D[u] = ttime;
    // cout << "start time " << u << ": " << D[u] << endl;

    for (long v = 0; v < n; v++) {
        // cout << "(u, v) = (" << u << ", " << v << ")" << endl;
        if (G[u][v] == 1 && color[v] == WH) {
            dfs_rec(v);
        }
    }
    color[u] = BK;
    ttime++;
    F[u] = ttime;
    // cout << "end time " << u << ": " << F[u] << endl;
}

int main() {
    long v_from, deg_out, v_to;

    cin >> n;
    for (long i = 0; i < n; i++) {
        cin >> v_from >> deg_out;
        v_from--;
        for (long j = 0; j < deg_out; j++) {
            cin >> v_to;
            v_to--;
            G[v_from][v_to] = 1;
        }
    }

    // for (long i = 0; i < n; i++) {
    //     for (long j = 0; j < n; j++) {
    //         if (j != 0) { cout << " "; }
    //         cout << G[i][j];
    //     }
    //     cout << endl;
    // }

    for (long u = 0; u < n; u++) {
        if (color[u] == WH) {
            dfs_rec(u);
        }
    }

    for (long i = 0; i < n; i++) {
        cout << i + 1 << " " << D[i] << " " << F[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3172
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char input[101];
char stack[101];
int pos;

void scan_data(void);

int main(void)
{
    int i, fl = 0;
    scan_data();
    while (strcmp(input, ".")) {
        fl = 0;
        i = 0;
        pos = 0;
        while (input[i] != '\0') {
            if (input[i] == '(') {
                stack[pos++] = '(';
            } else if (input[i] == '[') {
                stack[pos++] = '[';
            } else if (input[i] == ')') {
                if (pos == 0 || stack[--pos] != '(') {
                    fl = 1;
                    break;
                }
            } else if (input[i] == ']') {
                if (pos == 0 || stack[--pos] != '[') {
                    fl = 1;
                    break;
                }
            }
            i++;
        }
        if (pos != 0) {
            fl = 1;
        }
        if (fl) {
            puts("no");
        } else {
            puts("yes");
        }
        scan_data();
    }
    return 0;
}

void scan_data(void)
{
    char a;
    int i = 0;
    a = getchar();
    while (a != '\n') {
        input[i] = a;
        a = getchar();
        i++;
    }
    input[i] = '\0';
}

Measured memory_bytes: 524
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=sum(B)

for n in range(1,N):
    if A[n]-A[n-1]==1:
        ans+=C[A[n-1]-1]

print(ans)


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

int main() {
  int a, b, x;
  cin >> a >> b;
  
  x = a*b % 2;
  
  if (x == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
import math
n = int(input())
xs = list(map(int, input().split()))

p = sum(xs) / len(xs)
x1 = sum([(x - math.floor(p)) ** 2 for x in xs])
x2 = sum([(x - math.ceil(p)) ** 2  for x in xs])
print(min(x1, x2))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 1e9+7;

signed main(){
    int m; cin >> m;
    string s;
    int sum = 0, digit = 0;
    for(int i = 0; i < m; i++){
        int d, c; cin >> d >> c;
        digit += c;
        sum += d * c;
    }
    int ans = (sum - 1)/9 + digit - 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>


int main()
{
    int n;
    scanf("%d", &n);
    std::vector<int>dp(3, 0);
    for(int day=0 ;day<n; day++){
        std::vector<int>a(3), new_dp(3, 0);
        for(int& j: a){
            scanf("%d", &j);
        }
        for(int i=0 ;i<3;i++){
            for(int j=0 ;j<3; j++){
                if(i!=j){
                    new_dp[j] = std::max(new_dp[j], dp[i]+a[j]);    
                }
                
            }
        }
        dp = new_dp;
    }
    printf("%d", std::max(dp[0], std::max(dp[1], dp[2])));
    
    return 0;
}





Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.Array

eps :: Double
eps = 1.0e-8

data Point = Point (Double, Double) deriving (Show)
add (Point (x1, y1)) (Point (x2, y2)) = Point (x1 + x2, y1 + y2)
sub (Point (x1, y1)) (Point (x2, y2)) = Point (x1 - x2, y1 - y2)
mul (Point (x, y)) s = Point (x * s, y * s)
nrm (Point (x, y)) = Point (x / n, y / n) where n = sqrt $ (x * x + y * y)
dst  (Point (x, y)) = sqrt $ (x * x + y * y)
dst2 (Point (x, y)) = x * x + y * y
getX (Point (x, _)) = x
getY (Point (_, y)) = y

parsePoint :: String -> Point
parsePoint str =
    let [x, y] = map read $ words str
    in Point (x, y)

calcCenter :: Point -> Point -> (Point, Point)
calcCenter a b =
    let m = (a `add` b) `mul` 0.5
        d = sqrt (1.0 - ((dst $ a `sub` m) ** 2.0))
        e = a `sub` b
        n = nrm $ Point (negate $ getY e, getX e)
        c1 = m `add` (n `mul` d)
        c2 = m `sub` (n `mul` d)
    in (c1, c2)

solve' :: [Point] -> Int
solve' pts =
    let np    = length pts
        parr  = listArray (0, np-1) pts
        pairs = [ (parr ! i, parr ! j) | i <- [0..np-1], j <- [i+1..np-1] ]
    in if null pairs
        then 1
        else maximum $ map countUp pairs where
            countUp (p, q) =
                if (dst2 $ p `sub` q) >= 4.0 - eps
                    then 1
                    else
                        let (c1, c2) = calcCenter p q
                            m1 = length $ filter (\p -> (dst2 $ p `sub` c1) <= 1.0 + eps) pts
                            m2 = length $ filter (\p -> (dst2 $ p `sub` c2) <= 1.0 + eps) pts
                        in (max m1 m2)

solve :: [String] -> [Int]
solve []   = []
solve cont =
    let n           = read (head cont) :: Int
        (crds, rst) = splitAt n (tail cont)
        pts         = map parsePoint crds
    in if n == 0 then []
                 else (solve' pts) : solve rst

main :: IO ()
main = do
    contents <- getContents
    mapM_ print $ solve $ lines contents

Measured memory_bytes: 30180
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int a[100001];
int ans[100001];

int main() {
  int n;
  while(cin>>n)
  {
    inputs(a,n);
    ll s = 0;
    REP(i,n) {
      s += (i%2?-a[i]:a[i]);
    }
    ans[0] = s;
    REP(i,n) {
      ans[i+1] = 2 * a[i] - ans[i];
    }
    REP(i,n) printf("%d%c", ans[i], i!=n-1?' ':'\n');
  }
}


Measured memory_bytes: 2048
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	LL n,m;
	LL i,j,k;
	int a,b,c;
	cin>>n;
	for(i=sqrt(n);i>0;i--){
		if(n%i==0)break;
	}
	cout<<i+n/i-2<<endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt(), k=sc.nextInt();
        char[] ch=sc.next().toCharArray();
        sc.close();
        int[] s=new int[n];
        int info[][]=new int[n][3];
        int one[]=new int[n];
        int iinfo=0, ione=0;
        int zeros=0, ones=0;
        s[0]=ch[0]=='0'?0:1;
        for(int i=0;i<n;i++){
            if(i<n-1) s[i+1]=ch[i+1]=='0'?0:1;
            //System.out.println("s["+i+"]:"+s[i]);
            if(s[i]==0){
                ones=0;
                zeros++;
                if(i==n-1||s[i+1]==1){
                    info[iinfo][0]=i;
                    info[iinfo][1]=zeros;
                    iinfo++;
                }
                if(i==0){
                    one[ione]=0;
                    ione++;
                }
            }
            else{
                ones++;
                zeros=0;
                if(ones==1){
                    one[ione]=i;
                    ione++;
                }
            }
        }
        // System.out.println("iinfo:"+iinfo);
        // System.out.println("ione:"+ione);
        if(iinfo<=k){
            System.out.println(n);
            System.exit(0);
        }
        int max=0;
        int l,r;
        for(int i=k-1;i<iinfo;i++){
            if(i==iinfo-1) r=ones;
            else r=info[i+1][0]-info[i+1][1]-info[i][0];
            l=info[i][0]-one[i-k+1]+1;
            max=Math.max(max,l+r);
        }
        System.out.println(max);

    }
    
}

Measured memory_bytes: 31700
#include <stdio.h>

int main() {
	int h1, m1, h2 ,m2 ,k;
	int h = 0, m = 0;
	scanf ("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
	
	h = h2 - h1;
	m = m2 - m1;
	
	printf ("%d", 60 * h + m - k);
	
//	if (m < 0) {
	//	m *= -1;
	//}
	
	//if (h + m == k) {
	//	printf ("%d", k);
//	}
//	else {
//	printf ("%d\n", h + m - k);
//	}
	
	return 0;
}

Measured memory_bytes: 1708
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;


int main(){
    string s1, s2;
    cin >> s1 >> s2;
    out(s2+s1);
}

Measured memory_bytes: 256