akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>





using namespace std;
int main() {
	
	int n;
	cin >> n;
	double x = 0;
	for (int i = 0; i < n; i++) {
		double p;
		string s;
		cin >> p >> s;
		if (s == "JPY") {
			x += p;

		}
		else {
			x += 380000 * p;
		}
	}
	cout << setprecision(50);
	cout << x << endl;

	return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env ruby
# require 'pry'

# dpテンプレ
# 最小化
# dp = Hash.new{ Float::INFINITY }
# dp[i] = [dp[i], dp[i-1] + hoge].min
# dp[0] = 0
# 最大化
# dp = Hash.new{ 0 }
# dp[i] = [dp[i], dp[i-1] + hoge].max
# dp[0] = 0

input = gets.chomp
a = input.upcase

puts (input == a) ? 'A' : 'a'


Measured memory_bytes: 14296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
  int n,ans=0;cin>>n;
  vector<int> p(n+2,-1);
  for(int i=0;i < n;i++)
  {
    cin>>p[i+1];
  }
  int cnt=0;
  for(int i=1;i < n+2;i++)
  {
    if(p[i]==i)cnt++;
    else{
      ans+=(cnt+1)/2;
      cnt=0;
    }
  }

  cout<<ans<<endl;
}



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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, x; scanf("%d %d", &N, &x);
  vector<ll> A(N);
  for (int i = 0; i < N; ++i) {
    scanf("%lld", &A[i]);
  }
  ll ans = 0;
  for (int i = 1; i < N; ++i) {
    ll sum = A[i - 1] + A[i];
    if (sum > x) {
      ans += (sum - x);
      A[i] = max(A[i] - (sum - x), 0LL);
    }
  }
  printf("%lld\n", ans);
  return 0;
}


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

int main(){
 	string str;
  	cin>>str;
    for(int i=0;i<str.size();i++){
      if(str[i]=='T')
        str[i]='A';
      if(str[i]=='C')
        str[i]='A';
      if(str[i]=='G')
        str[i]='A';
    }
	int count=0;
  	int ans=0;
  	for(int i=0;i<str.size();i++){
    	if(str[i]=='A'){
          count++;
          if(ans<count)
            ans=count;
        }
       	else
          count=0;

    }
  cout<<ans<<endl;
  	
}  

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

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;


//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

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

#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


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

typedef vector<vector<Edge>> AdjList;
AdjList graph;

int a[100010];
int main() {
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);

    int N; cin >> N;

    int p[100010]={0};

    REP(i, N) {
        cin >> p[i+1];
        a[p[i+1]] = i+1;
    }

    ll ans = 0;
    multiset<ll> used;
    used.insert(0);
    used.insert(0);
    used.insert(N+1);
    used.insert(N+1);

    for(ll i=N; i>=1; --i){
        ll r1, l1, r2, l2;

        auto itr = used.lower_bound(a[i]);
        r1 = *itr++;
        r2 = *itr--;
        itr--;
        l1 = *itr--;
        l2 = *itr;

        ans += i * (r2 -r1) * (a[i] - l1);
        ans += i*(l1-l2)*(r1-a[i]);
        used.insert(a[i]);
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 5760
#include<iostream>
using namespace std;
char a[3][3];
int main()
{
    int n=3,i,j;
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            cin>>a[i][j];
        }
    }
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            if(i==j){
                cout<<a[i][j];
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a[100009];
int main()
{
   ll n,x;
   cin>>n>>x;
   for(ll i=1;i<=n;i++)
   {
       cin>>a[i];
   }
   ll sum=0;
   if(a[1]>x)
   {
       sum+=a[1]-x;
       a[1]=x;
   }

   for(ll i=2;i<=n;i++)
   {
       if(a[i]+a[i-1]>x)
       {
           sum+=(a[i]+a[i-1]-x);
           a[i]-=(a[i]+a[i-1]-x);
       }
   }
   cout<<sum<<endl;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iterator>
#include <iostream>
//#include <iomanip>
//#include <cstring>
//#include <cstdlib>
#include <string>
#include <vector>
//#include <queue>
//#include <cmath>
//#include <set>
using namespace std;
#ifdef LOCAL
#define DEBUGMSG()                                                              \
{                                                                               \
    cerr << "[调试 @" << __PRETTY_FUNCTION__ << ":" << __LINE__ << "]" ;        \
}
#define DEBUGVAR(x)                                                             \
{                                                                               \
    cerr << "[调试 @" << __PRETTY_FUNCTION__ << ":" << __LINE__ << "]:" ;       \
    cerr << "([" << typeid(x).name() << "]" << #x << ")" << x << endl ;         \
}
#define DEBUGARR(l, r)                                                          \
{                                                                               \
    cerr << "[调试 @" << __PRETTY_FUNCTION__ << ":" << __LINE__ << "]:" ;       \
    copy(l, r, ostream_iterator<decltype(*l)>(cerr, " "));                      \
    cerr << endl ;                                                              \
}
#else
#define DEBUGMSG()
#define DEBUGVAR(x)
#define DEBUGARR(l, r)
#endif // LOCAL

typedef long long i64;

vector <i64> vec;
string str;
string t1, t2;
i64 ans;

void DFS(string s)
{
    if(s.size() <= 0)
    {
        for(i64 x : vec)
            ans += x;
        return ;
    }

    for(string::iterator itr = s.begin(); itr != s.end(); itr++)
    {
        t1 = string(s.begin(), itr+1);
        t2 = string(itr+1, s.end());
        //DEBUGVAR(t1);
        //DEBUGVAR(t2);
        //DEBUGVAR(stol(t1));
        vec.push_back(stoll(t1));
        DFS(t2);
        vec.pop_back();
    }
}

int main()
{
    cin >> str ;
    DFS(str);
    cout << ans << endl ;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e3 + 5);
const int W = (int)(3e4 + 5);
const int LOG = (int)(20);

struct block {
	lli w, s, v;
}ar[N];

lli n, dp[N][W], ans;

bool operator < (block x, block y) {
	return x.w + x.s < y.w + y.s;
}

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);
	
	cin >> n;
	for(lli i = 1; i <= n; i++)
		cin >> ar[i].w >> ar[i].s >> ar[i].v;
	
	sort(ar + 1, ar + n + 1);

	for(lli i = 0; i < N; i++)
		fill(dp[i], dp[i] + W, LONG_LONG_MIN);

	dp[0][0] = 0;
	for(lli i = 1; i <= n; i++)
		for(lli j = 0; j < W; j++) {
			dp[i][j] = dp[i - 1][j];
			if(j - ar[i].w >= 0 && ar[i].s - j + ar[i].w >= 0)
				dp[i][j] = max(dp[i][j], dp[i - 1][j - ar[i].w] + ar[i].v);
		}
	for(lli i = 0; i < W; i++)
		ans = max(dp[n][i], ans);

	cout << ans;
}

Measured memory_bytes: 235904
#include <bits/stdc++.h>
#define int long long
#define N 101
using namespace std;
int n,W,v[N],w[N];
int dp[N][N*N];
const int INF = 1LL<<55;

int Min(int &a,int b){return a=min(a,b);}

int DP(){
  for(int i=0;i<N;i++)
    for(int j=0;j<N*N;j++) dp[i][j] = INF;
  
  dp[0][0] = 0;  
  for(int i=0;i<n;i++)
    for(int j=0;j<N*N;j++){
      Min(dp[i+1][j],dp[i][j]);
      Min(dp[i+1][j+v[i]],dp[i][j]+w[i]);
    }
  int res = 0;
  for(int i=0;i<N*N;i++) if(dp[n][i]<=W) res = i;
  return res;
  }

signed main(){
  cin>>n>>W;
  for(int i=0;i<n;i++)cin>>v[i]>>w[i];
  cout<<DP()<<endl;
  return 0;
}

Measured memory_bytes: 11096
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=1000000007;
int main(){
  ll N,K;
  cin>>N>>K;
  ll ans=0;
  for(ll i=K;i<=N+1;i++){
    ll mini=i*(i-1)/2;
    ll maxi=i*(2*N-i+1)/2;
    ll tmp=maxi-mini+1;
    ans=(ans+tmp)%MOD;
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,-1,0,1},dy={1,0,-1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	bool ok = true;
	rep(i,s.size()){
		if(i % 2 == 0 && s.at(i) == 'L') ok = false;
		if(i % 2 == 1 && s.at(i) == 'R') ok = false;
	}
	if(ok) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  sort(A.begin(),A.end());
  int ans=0;
  int i=0;
  while(i < N){
    int num=1;
    while(A[i] == A[i+1]){
      num++;
      i++;
    }
    if(num%2 == 1){
      ans++;
    }
    i++;
  }
  cout << ans << endl;
  return 0;
  }


Measured memory_bytes: 640
#include"bits/stdc++.h"
using namespace std;
#define rep(i, N) for(int i=0; i<N; ++i)
using ul = unsigned long;
using ll = long long;

int main() {
    int m1, m2, d1, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if (m1 != m2) cout << '1' << endl;
    else cout << '0' << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
class Pair{
	public:
	long long int a,b;
	Pair(){
		a=0;
		b=0;
	}
	bool operator()(const Pair x,const Pair y){
		return x.a<y.a;
	}
};
int main(){
	long long int n,m,tmp1,tmp2;
	cin>>n>>m;
	vector<Pair>p(n);
	for(int i=0;i<n;i++){
		cin>>tmp1>>tmp2;
		p[i].a=tmp1;
		p[i].b=tmp2;
	}
	sort(p.begin(),p.end(),Pair());
	long long int sum=0;
	for(int i=0;i<n;i++){
		if (p[i].b>=m){
			sum+=p[i].a*m;
			break;
		}else{
			m-=p[i].b;
			sum+=p[i].b*p[i].a;
		}
	}

	cout<<sum<<endl;

	return 0;
}

Measured memory_bytes: 1792
/* Simplicity and Goodness */
 
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;


void solve()
{   
    int n;
    scn(n);

    ll a[n];

    rep(i, 0, n)
    lscn(a[i]);

    ll total = - 1;

    rep(i, 0, n/2) {
        if(total == -1) {
            total = a[i] ^ a[n-i-1];
        } else {
            total ^= a[i] ^ a[n-i-1];
        }
    }

    rep(i, 0, n)
    a[i] ^= total;

    rep(i, 0, n)
    lpri(a[i]);
}

int main()
{
    int t = 1;
    // scn(t);

    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5256
#include<cstdio>
#include<cstring>
using namespace std;

int main(){
 char str[1001];
 
 while(1){
  int sum = 0;
  scanf("%s", str);
  
  if(str[0] == '0') break;

  for(int i = 0; i < strlen(str); i++){
   sum += str[i] - '0';
  }

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

 }

 return 0;
}

Measured memory_bytes: 964
class Dice:
    
    def __init__(self, nums):
        self.nums = list(nums)
        
    @property
    def top(self):
        return self.nums[0]
        
    def _shift(self, *pairs):
        for pair in pairs:
            num = self.nums[pair[0]]
            self.nums[pair[0]] = self.nums[pair[1]]
            self.nums[pair[1]] = num
            
    def go(self, opes:str):
        for ope in opes:
            if ope == "N":
                self.go_north()
            elif ope == "E":
                self.go_east()
            elif ope == "W":
                self.go_west()
            else:
                self.go_south()
                
    def go_top(self, num):
        i = self.nums.index(num)
        
        if i == 1:
            self.go_north()
        elif i == 2:
            self.go_west()
        elif i == 3:
            self.go_east()
        elif i == 4:
            self.go_south()
        elif i == 5:
            self.go_north()
            self.go_north()
            
    def go_ahead(self, num):
        i = self.nums.index(num)
        
        if i == 2:
            self.go_cw()
        elif i == 4:
            self.go_cw()
            self.go_cw()
        elif i == 3:
            self.go_ccw()
            
        
    def go_north(self):
        self._shift((0, 1), (1, 5), (5, 4))
        
    def go_east(self):
        self._shift((0, 3), (3, 5), (5, 2))
        
    def go_west(self):
        self._shift((0, 2), (2, 5), (5, 3))
        
    def go_south(self):
        self._shift((0, 4), (4, 5), (5, 1))
        
    def go_ccw(self):
        self._shift((3, 4), (4, 2), (2, 1))
        
    def go_cw(self):
        self._shift((3, 1), (1, 2), (2, 4))
        

dice = Dice(map(int, input().split()))

for _ in range(int(input())):
    top, ahead = map(int, input().split())
    dice.go_top(top)
    dice.go_ahead(ahead)
    print(dice.nums[2])


Measured memory_bytes: 5608
b1,b2,b3=map(int,input().split())
if b1==1:
    if b2==1:
        print("Open")
    else:
        print("Close")
elif b1==0:
    if b2==1:
        print("Close")
    else:
        if b3==1:
            print("Open")
        else:
            print("Close")
else:
    print("Close")


Measured memory_bytes: 5596
// unolight {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
// }}}

const int MAX_N = 100005;
int n;
vector<PII> edges;
vector<int> adj[MAX_N];
bool visited[MAX_N] = {};

void input() {
    RI(n);
    REP1(i, 1, n-1) {
    	int u, v;
    	RI(u,v);
    	edges.PB({u,v});
    	adj[u].PB(v);
    	adj[v].PB(u);
    }
}

void solve() {
	queue<PII> q;
	map<PII, int> m;
	int root, K=0;

	REP1(i, 1, n-1) {
		if(adj[i].size() > K) {
			K = adj[i].size();
			root = i;
		}
	}

	visited[root] = true;
	REP(i, (int)adj[root].size()) {
		int v = adj[root][i];
		m[{v, root}] = i;
		q.push({v, root});
		visited[v] = true;
	}

	while(!q.empty()) {
		int u = q.front().first;
		int e = q.front().second;
		q.pop();
		int k = m[{u, e}];

		for(int v:adj[u]) {
			if(visited[v]) continue;
			m[{v, u}] = (++k)%K;
			q.push({v, u});
			visited[v] = true;
		}
	}

	printf("%d\n", K);
	for(auto a:edges) {
		int u = a.first, v = a.second;
		if(m.count({u, v})) {
			printf("%d\n", m[{u,v}]+1);
		} else {
			printf("%d\n", m[{v,u}]+1);
		}
	}
}

int main( int argc, char *argv[] ) {
	input();
	solve();
    return 0;
}

Measured memory_bytes: 13172
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

template<typename T> T my_gcd(T a, T b) {
    return (a ? my_gcd(b % a, a) : b);
}

int main(int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, X, diff[100001]; cin >> N >> X;
    rep(i, N) {
        int x;
        cin >> x;
        diff[i] = abs(X - x);
    }

    if (N == 1) {
        cout << diff[0] << endl;
    } else if (N == 2) {
        cout << my_gcd(diff[0], diff[1]) << endl;
    } else {
        int D = my_gcd(diff[0], diff[1]);
        for (int i = 2; i < N; ++i) {
            D = my_gcd(D, diff[i]);
        }

        cout << D << endl;
    }

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------

/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/


#define INF 1LL<<60
typedef long long ll;
int N, A[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];

    ll x = 0, y = 0;
    ll ans = INF;
    rep(i, 0, N) y += A[i];
    rep(i, 0, N - 1) {
        x += A[i];
        y -= A[i];
        ans = min(ans, abs(x - y));
    }
    cout << ans << endl;
}

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

#define pb push_back
#define mp make_pair  //access values using v[i].first,v[i].second
#define mt make_tuple //access values using get<1>(v[i]),get<0>(v[i]) etc

#define inf 1000000000
#define mod 1000000007

#define FIN freopen("input.txt","r",stdin)
#define FOUT freopen("output.txt","w",stdout)

#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define sc(n) scanf("%c",&n)
#define sd(n) scanf("%lf",&n)

#define pin(n) printf("%d\n",n)
#define pln(n) printf("%lld\n",n)
#define pdn(n) printf("%lf\n",n)

#define pis(n) printf("%d ",n)
#define pls(n) printf("%lld ",n)

#define pn printf("\n")
#define ps(n) printf("%s",n)
#define psn(n) printf("%s\n",n)

vector<int> primes;  //primes.size() = 78498 //last prime number = 999983
void sieve()
{
    vector<bool> a(1000000,false);
    for(int u=2;u<=1000000;u++)
    {
        if(a[u])continue;
        for(int i=2*u;i<=1000000;i+=u)a[i]=true;
    }
    for(int i=2;i<=1000000;i++)
    {
        if(!a[i])primes.pb(i);
    }
}

int gcd(int a, int b)
{
    while(1)
    {
        if(a==0)return b;
        b%=a;
        if(b==0) return a;
        a%=b;
    }
}
int lcm(int a, int b)
{
    int g=gcd(a,b);
    return ((a*b)/g);
}

int digitCount(int n)
{
    int c=0;
    while(n!=0)
    {
        c+=n%10;
        n/=10;
    }
    return c;
}

int totalDigit(int n)
{
    int d;
    for(d=1,n/=10;n!=0;n/=10)d++;
    return d;
}


int parseInt(string str)
{
    int a=0;
    int l=str.length();
    for(int i=0;i<l;i++)
    {
        a*=10;
        a+=str[i]-48;
    }
    return a;
}

long long parseLong(string str)
{
    long long a=0;
    int l=str.length();
    for(int i=0;i<l;i++)
    {
        a*=10;
        a+=str[i]-48;
    }
    return a;
}

int main()
{
    //FIN;
    string st1,st2;
    cin>>st1;
    cin>>st2;
    reverse(st1.begin(),st1.end());
    if(st1==st2)psn("YES");
    else psn("NO");
}


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  // ll N; cin >> N;
  ll H, W; cin >> H >> W;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  // string s; cin >> s;
  vector<vector<ll>> a(10, vector<ll>(10));
  rep(i, 10) rep(j, 10)  cin >> a[i][j];
  vector<ll> w(H*W);
  rep(i, H*W) cin >> w[i];

  
  ll ans = 0;
  bool chg = false;
  do {
    chg = false;
    rep(i, 10) rep(j,10) rep(k, 10) {
      
      if(a[i][k] + a[k][j] < a[i][j]) {
	a[i][j] = a[i][k] + a[k][j];
	chg = true;
      }
    }
  } while(chg);

  rep(i, 10) {
    rep(j, 10) {
      cerr << a[i][j] << " ";
    }
    cerr << "\n";
  }

  rep(i, H*W) {
    if(w[i] >= 0) {
      ans += a[w[i]][1];
    }
  }
  
  cout << ans << endl;

}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


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

#define INF 1145141919
using LL = long long int;
#define II pair<int, int>

using namespace std;

int main()
{
  string S;
  string SS = "FESTIVAL";
  cin >> S;
  cout << S.substr(0, S.length() - SS.length()) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a;
  double b;
  cin>>a>>b;
  b+=EPS;
  int c=b*100;
  cout<<(a*c)/100<<endl;
  
  //cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 3684
#include <stdio.h>
int main(){
        int a,b,n,s,i,j;
        char c;
        scanf("%d %d",&n,&s);
        int line[n];
        for(i=0;i<n;i++){
                line[i] = i+1;
        }
        for(i=0;i<s;i++){
                scanf("%d%c%d", &a,&c,&b);
                j       = line[a-1];
                line[a-1] = line[b-1];
                line[b-1] = j;
        }
        for(i=0;i<n;i++){
                printf("%d\n",line[i]);
        }
return 0;
}

Measured memory_bytes: 596
# coding: utf-8

N, M = tuple(map(int, input().split()))

graph = [ [] for i in range(N+1)]
for i in range(M):
    a, b = tuple(map(int, input().split()))
    graph[a].append(b)
    graph[b].append(a)

res = "IMPOSSIBLE"
for i in range(2, N):
    if 1 in graph[i] and N in graph[i]:
        res = "POSSIBLE"

print(res)


Measured memory_bytes: 38544
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  l = InputLine.to_f

  puts ((l / 3.0) ** 3.0).to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

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

int main(){
  std::string str;
  std::cin>>str;
  if(str=="abc"||str=="acb"||str=="cab"||str=="bac"||str=="bca"||str=="cba")
    std::cout<<"Yes"<<std::endl;
  else std::cout<<"No"<<std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
using Int = long long;
#define MOD 1000000007
int ADD(int x, int y) { return ((Int)x + y) % MOD; }
int MUL(int x, int y) { return (Int)x * y % MOD; }
int POW(int x, int y) {
    int result = 1;
    while (y > 0) {
        if (y & 1) result = MUL(result, x);
        x = MUL(x, x);
        y >>= 1;
    }
    return result;
}
int FACT(int x) {
    int result = 1;
    for (int i = 1; i <= x; i++) {
        result = MUL(result, i);
    }
    return result;
}
int INV(int x) { return POW(x, MOD-2); }
int S[100001]; // 1/1 + 1/2 + ... + 1/n
int main()
{
    for (int i = 1; i <= 100000; i++) {
        S[i] = ADD(S[i-1], INV(i));
    }
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    int result = 0;
    for (int j = 0; j < N; j++) {
        result = ADD(result, MUL(A[j], S[j+1] + S[N-j] - 2));
    }
    int sum = 0;
    for (int i = 0; i < N; i++) sum = ADD(sum, A[i]);
    cout << MUL(FACT(N), ADD(result, sum)) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
    int64_t N;
    int count=0;
    cin >> N;
    //a = N*0.01;
    int64_t a;
    a = 100;
    while(1){
        a = a + (a * 0.01);
        //cout << a << endl;
        ++count;
        if (N <= a){
          break;  
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
int main(){
ll n,m;
cin >> n >> m;
priority_queue<ll, vector<ll>,greater<ll>> pq;
for (ll i = 0; i < n;i++){
    ll t;
    cin >> t;
    pq.push(t);
}
vector<pair<ll, ll>> query(m);
for (ll i = 0; i < m;i++){
    ll b, c;
    cin >> b >> c;
    query[i].first = c;
    query[i].second = b;
}
sort(query.begin(), query.end(),greater<pair<ll,ll>>());
for (ll i = 0; i < m; i++) {
    for (ll j = 0; j < query[i].second;j++){
        ll t = pq.top();
		if(query[i].first>t){
            pq.pop();
            pq.push(query[i].first);
        }
		else
            break;
    }
}
ll ans = 0;
while(!pq.empty()){
	ans+=pq.top();
    pq.pop();
}
cout << ans << endl;
}

Measured memory_bytes: 5640
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int a, l, m, n;
      cin >> a;
      l = a % 10;
      m = (a / 10) % 10;
      n = (a / 100) % 10;
      cout << l + m + n << endl;        
    }

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

int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if((a+b)>(c+d))
	    cout<<"Left"<<endl;
	else if((a+b)<(c+d))
	    cout<<"Right"<<endl;
	else
	    cout<<"Balanced"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N, D;
vector<vector<int>> X;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> D;
  X = vector<vector<int>>(N, vector<int>(D, 0));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> X[i][j];
    }
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      int sum = 0;
      for (int k = 0; k < D; k++) {
        sum += pow(abs(X[i][k] - X[j][k]), 2);
      }
      double root = sqrt(sum);
      if (ceil(root) == floor(root)) {
        ans++;
      }
    }
  }

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

Measured memory_bytes: 256
n = int(input())
matrix = [[0]*10 for _ in range(10)]
for i in range(1,n+1):
    s = str(i)
    matrix[int(s[0])][int(s[-1])] += 1
total = 0
for i in range(1,10):
    for j in range(1,10):
        total += matrix[i][j]*matrix[j][i]
print(total)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n;
  cin >> n;
  vector<map<char,ll>> count(n);
  for(ll i=0;i<n;i++) {
    string s;
    cin >> s;
    for(ll j=0;j<s.size();j++) {
      count[i][s[j]]++;
    }
  }
  map<char,ll> ans;
  for(ll i=0;i<'z'-'a'+1;i++) {
    ll num=inf;
    for(ll j=0;j<n;j++) {
      num=min(num,count[j]['a'+i]);
    }
    ans['a'+i]=num;
  }
  for(ll i=0;i<'z'-'a'+1;i++) {
    for(ll j=0;j<ans['a'+i];j++) {
      cout << char('a'+i);
    }
  }
  cout << endl;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void) {
	int n, m;
	int answer = 0;
	scanf("%d %d", &n, &m);

	int vector1[n][m];
	int vector2[m];

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			scanf("%d", &vector1[i][j]);
		}
	}
	for (int i = 0; i < m; i++) {
		scanf("%d", &vector2[i]);
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			answer += vector1[i][j] * vector2[j];
		}
		printf("%d\n", answer);
		answer = 0;

	}

	return 0;
}


Measured memory_bytes: 2756
#include<cstdio>
#include<iostream>
using namespace std;
const long long md=998244353;
const int maxn=1000100;
long long fac[maxn],inv[maxn];
long long powd(long long x,long long y){
	long long res=1;
	while(y){
		if(y&1) res=res*x%md;
		x=x*x%md;
		y>>=1;
	}
	return res;
}
long long C(int n,int m){
	return fac[n]*inv[m]%md*inv[n-m]%md;
}
long long Max(long long x,long long y){
	return x>y?x:y;
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	if(n<m) swap(n,m);
	fac[0]=1;
	for(int i=1;i<maxn;i++)
		fac[i]=fac[i-1]*i%md;
	inv[maxn-1]=powd(fac[maxn-1],md-2);
	for(int i=maxn-1;i>=1;i--)
		inv[i-1]=inv[i]*i%md;
	long long ans=0;
	for(int i=1;i<=m;i++)
		ans=(ans+C(i*2,i)*C(n+m-i*2,n-i))%md;
	ans=ans*inv[2]%md*powd(C(n+m,n),md-2)%md;
	printf("%lld\n",(ans+n)%md);
	return 0;
}


Measured memory_bytes: 15872
#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"
//#include <intrin.h>  //AtCoder (gcc) 上ではこれがあると動かない。__popcnt用のincludeファイル。
using namespace std;
using Graph = vector<vector<int>>;

typedef long long ll;
typedef long double ld;


#define int long long
#define rep(i, n) for(long long i = 0; i < (n); i++)
#define sqrt(d) pow((long double) (d), 0.50)

const ll INF = 2e9;
const ll large_P = 1e9 + 7;



//繰り返し2乗法
//N^aの、Mで割った余りを求める。
//M = 1000000007 (1e9 + 7) など。
//M = 1000000009 (1e9 + 9) もある。
//M = 998244353 もある。

ll my_pow(ll N, ll a, ll M) {
	ll tempo;
	if (a == 0) {
		return 1;
	}
	else {
		if (a % 2 == 0) {
			tempo = my_pow(N, a / 2, M);
			return (tempo * tempo) % M;
		}
		else {
			tempo = my_pow(N, a - 1, M);
			return (tempo * N) % M;
		}
	}
}




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

	vector<int> T(N);
	rep(i, N) cin >> T.at(i);

	int M; cin >> M;

	vector<int> P(M), X(M);
	rep(i, M) {
		cin >> P.at(i) >> X.at(i);
		P.at(i)--;
	}

	int sum_time = 0;
	rep(i, N) {
		sum_time += T.at(i);
	}

	rep(i, M) {
		cout << sum_time + X.at(i) - T.at(P.at(i)) << endl;
	}


}

Measured memory_bytes: 256
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
                
#define int long long
#define ll long long 
bool FLAG = 0;
#define debug(x) if (FLAG) { 	cerr << #x << " = " << x << endl;}
#define debug_vec(x) if (FLAG) {cerr << #x << " = {"; for (auto to x) cout << to << ", "; cout << "}" << endl}
#define F first
#define S second                               
#define sqr(x) ((x) * (x))
#define make make_pair
#define pb push_back
#define sz(x) (int)(x.size()) 
#define all(x) x.begin (), x.end ()

using namespace std;
                        
typedef unsigned long long ull;
typedef long double ld;

const int MOD = 998244353, N = (int)1e6+ 222;
const int INF = (int)1e18;
const ld eps = (ld)1e-6;

int dx[] = {0, -1, 0, 1, 0};
int dy[] = {0, 0, 1, 0, -1};         
                 
int n, a[N], b[N];
vector <int> v[3];


inline void solve () {             
	cin >> n;
	int res = 0;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	for (int i = 1; i <= n; ++i) cin >> b[i];
	for (int x = 0; x <= 30; ++x) {
		for (int i = 1; i <= n; ++i) {
			int k = b[i] % (1 << (x + 1));
			if ((b[i] & (1 << x)) != 0) v[1].pb(k);
			else v[0].pb(k);  
		}           
		sort(all(v[0]));
		sort(all(v[1]));
		int zero = 0, l, r, ans = 0;
		for (int i = 1; i <= n; ++i) {
			int k = a[i] % (1 << (x + 1));
			if ((a[i] & (1 << x)) != 0) {
				r = upper_bound(all(v[0]), (1 << (x + 1)) - 1 - k) - v[0].begin() - 1;
				l = lower_bound(all(v[0]), (1 << x) - k) - v[0].begin();
				ans += max(r - l + 1, zero);
				r = upper_bound(all(v[1]), (1 << (x + 2)) - 2 - k) - v[1].begin() - 1;
				l = lower_bound(all(v[1]), (1 << x) + (1 << (x + 1)) - k) - v[1].begin();
				ans += max(r - l + 1, zero);
			} else {
				r = upper_bound(all(v[1]), (1 << (x + 1)) - 1 - k) - v[1].begin() - 1;
				l = lower_bound(all(v[1]), (1 << x) - k) - v[1].begin();
				ans += max(r - l + 1, zero);
				r = upper_bound(all(v[0]), (1 << (x + 1)) - 2 - k) - v[0].begin() - 1;
				l = lower_bound(all(v[0]), (1 << x) - k) - v[0].begin();
				ans += max(r - l + 1, zero);
			}             	
		}
		ans %= 2;
		res += (1 << x) * ans; 
		v[0].clear();
		v[1].clear();
	}
	cout << res;
}	    

signed main () {
	#ifdef Maga
		freopen("input", "r", stdin);
	#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int t = 1;
//	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

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

int main(void){
    int A,B,M;
    cin>>A>>B>>M;
    int a[A] = {};
    int b[B] = {};
    int amin=100000,bmin=100000;
    for(int i=0;i<A;i++){
        int ai;
        cin>>ai;
        a[i] = ai;
        amin = min(amin, ai);
    }
    for(int i=0;i<B;i++){
        int bi;
        cin>>bi;
        b[i] = bi;
        bmin = min(bmin, bi);
    }

    int ans = amin + bmin;
    for(int i=0;i<M;i++){
        int x,y,c;
        cin>>x>>y>>c;
        ans = min(ans, a[x-1]+b[y-1]-c);
    }
    cout<<ans<<endl;
}

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

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

using namespace std;

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

int sum(int n) {
	int s = 0;
	while (n) {
		s += (n % 10);
		n /= 10;
	}

	return s;
}

int main() {

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

	int n;
	cin >> n;

	int min_value = 1e6;
	for (int a = 1; a < n; ++a) {
		min_value = min(min_value, sum(a) + sum(n - a));
	}

	cout << min_value << "\n";

	return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<functional>
using namespace std;

#define INF 1<<21
#define MOD 1000000007

int main(void) {
  string s,str;
  int cnt,flag;
  int ans = 105;
  cin >> s;
  for (char c = 'a'; c <= 'z'; c++) {
	str = s;
	cnt = 0;
	while (1) {
	  flag = 1;
	  for (int i = 0; i < str.length(); i++) {
		if (str[i] != c)flag = 0;
	  }

	  if (flag==0){
		for (int i = 0; i < str.length() - 1; i++) {
		  if (str[i + 1] == c)str[i] = c;
		}
		cnt++;
		str = str.substr(0, str.length() - 1);
	  }

	  else {
		break;
	  }

	}
	ans = min(cnt, ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int grid[3][3];
int x[3];
int y[3];
int main() {
    for(int i=0; i < 3; i++){
        for(int j=0; j < 3; j++){
            cin >> grid[i][j];
        }
    }
    x[0] = 0;
    for(int i=0; i < 3; i++) y[i] = grid[0][i] - x[0];
    for(int i=0; i < 3; i++) x[i] = grid[i][0] - y[0];
    bool good = true;
    for(int i=0; i < 3; i++){
        for(int j=0; j < 3; j++){
            if(x[i] + y[j] != grid[i][j]) good = false;
        }
    }
    if(good) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

char prime[10000000];

int main(void) {
    memset(prime, 0xFF, sizeof(prime));

    prime[1] = 0;
    prime[6] = 0xFF;
    prime[36]= 0;

    for(int i=7; i<300000; i+=7) {
        if(prime[i+1]) {
            prime[(i+1)*6] = 0;
            for(int j=7; i*j<300000; j+=7)
                prime[(i+1)*(j+1)] = prime[(i+1)*(j+6)] = 0;
        }
        if(prime[i+6]) {
            prime[(i+6)*6] = 0;
            for(int j=7; i*j<300000; j+=7)
                prime[(i+6)*(j+1)] = prime[(i+6)*(j+6)] = 0;
        }
    }

    while(true) {
        int in;
        scanf("%d",&in);
        if(in == 1) break;

        printf("%d:",in);

        if(in % 6 == 0) printf(" 6");
        for(int i=7; i<300000; i+=7) {
            if(prime[i+1]) {
                if(in % (i+1) == 0) printf(" %d", i+1);
            }
            if(prime[i+6]) {
                if(in % (i+6) == 0) printf(" %d", i+6);
            }
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 10800
#include <cstdio>
#include <utility>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;

const int INF = 1000000000;
int n, k;
vector<P> way[128];

int query(int a, int b);

int main()
{
	while (scanf("%d %d", &n, &k), n != 0){
		for (int i = 1; i <= n; i++) way[i].clear();
		while (k-- > 0){
			int mode;
			scanf("%d", &mode);
			
			if (mode == 0){
				int a, b;
				scanf("%d %d", &a, &b);
				int cost = query(a, b);
				if (cost == INF) puts("-1");
				else printf("%d\n", cost);
			}
			else {
				int c, d, e;
				scanf("%d %d %d", &c, &d, &e);
				way[c].push_back(P(e, d));
				way[d].push_back(P(e, c));
			}
		}
	}
	
	return 0;
}

int query(int a, int b)
{
	static int mini[128];
	for (int i = 1; i <= n; i++) mini[i] = INF;
	
	priority_queue<P> q;
	q.push(P(0, a));
	mini[a] = 0;
	while (!q.empty()){
		P p = q.top(); q.pop();
		
		if (mini[p.second] < p.first) continue;
		for (int i = 0; i < way[p.second].size(); i++){
			P tmp = way[p.second][i];
			
			if (mini[tmp.second] > mini[p.second] + tmp.first){
				mini[tmp.second] = mini[p.second] + tmp.first;
				q.push(tmp);
			}
		}
	}
	
	return mini[b];
}

Measured memory_bytes: 1088
i,j,k,s;
main(x)
{
  char a[99],b[99];
  for(scanf("%s%d",a,&x);x--;)
    {
      scanf("%s",b);
      for(i=0;i<10;i++)
	{
	  k=0;
	  for(j=i;a[k]==b[j];)
	    {
	      j++;
	      k++;
	      j=j>9?0:j;
	      if(a[k]=='\0')
		{s++;i=11;break;}
	    }
	}
    }
  printf("%d\n",s);
  exit(0);
}

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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


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

	int a[n];
	for (int i = 0; i < n; i++) {
		a[i] = 0;
	}

	for (int i = 1; i < n; i++) {
		// for (int k = 0; k < n; k++) {
		// 	cout << a[k] << "\n";
		// }

		int c, s, f;
		cin >> c >> s >> f;

		for (int j = 0; j < i; j++) {
			if (s>=a[j]) {
				a[j] += c + (s-a[j]);
				continue;
			}
			if ((a[j]-s)%f==0) {
				a[j] += c;
				continue;
			}
			a[j] += c + (f-(a[j]-s)%f);
		}
	}
	for (int i = 0; i < n; i++) {
		cout << a[i] << "\n";
	}
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main implements Closeable {

  private InputReader in = new InputReader(System.in);
  private PrintWriter out = new PrintWriter(System.out);

  public void solve() {
    n = in.ni();
    m = in.ni();
    grid = new char[n][m];
    for (int i = 0; i < n; i++) {
      grid[i] = in.next().toCharArray();
    }
    dp = new Long[n][m];
    out.println(recurse(0, 0));
  }
  
  private int n, m;
  private char[][] grid;
  private Long[][] dp;
  private final long MOD = (long) 1e9 + 7;
  
  private long recurse(int row, int col) {
    if (row == n - 1 && col == m - 1) return 1;
    
    if (dp[row][col] != null) return dp[row][col];
    
    long ans = 0;
    if (row + 1 < n && grid[row + 1][col] == '.') {
      ans += recurse(row + 1, col);
      ans %= MOD;
    }
    if (col + 1 < m && grid[row][col + 1] == '.') {
      ans += recurse(row, col + 1);
      ans %= MOD;
    }
    return dp[row][col] = ans;
  }
  
  @Override
  public void close() throws IOException {
    in.close();
    out.close();
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

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

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

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

    public void close() throws IOException {
      reader.close();
    }
  }

  public static void main(String[] args) throws IOException {
    try (Main instance = new Main()) {
      instance.solve();
    }
  }
}


Measured memory_bytes: 78480
#include <iostream>

using namespace std;

const int N = 100005;
int n, k, a[N], mark[N], ans, cn;

int main()
{
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
	{
		char c;
		cin >> c;
		if (c == '1') a[i] = 1;
	}
	mark[0] = 1;
	for (int i = 2; i <= n; i++)
	{
		if (a[i] != a[i - 1]) mark[++cn] = i;
	}
	mark[0] = 1;
	mark[cn + 1] = n + 1;
	int st = 0, ed = -1, now = 0;
	while (st <= ed || st == 0)
	{
		while (now <= k && ed <= cn)
		{
			ed++;
			if (a[mark[ed]] == 0)
			{
				now++;
			}
		}
		ed--;
		if (now > k) now--;
		
		ans = max(ans, mark[ed + 1] - mark[st]);
		
		if (a[mark[st]] == 0)
		{
			now--;
		}
		st++;
	}
	cout << ans << endl;
	return 0;
}


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

using ll = long long;

struct edge {
   ll to, cost;
};

int main() {
   ll N, M; // Nはノードの個数、Mは辺の個数
   // 入力 ------------------------------------------
   cin >> N >> M;
   vector<vector<edge>> G(N);
   for (int i = 0; i < M; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      a--, b--;
      // a~bまでの距離で、コストはc
      G[a].push_back(edge{b, c});
   }
   // ----------------------------------------------

   const ll INF = 1e18;
   vector<ll> dist(N, -INF);
   dist[0] = 0;
   // ベルマンフォード法
   for (int k = 0; k < N; k++) { // 適当な回数操作する
      for (int i = 0; i < N; i++) {
         if (dist[i] == -INF) continue;
         for (edge e : G[i]) {
            dist[e.to] = max(dist[e.to], dist[i] + e.cost);
         }
      }
   }
   ll ans1 = dist[N-1];

   // もう一度ベルマンフォード法
   for (int k = 0; k < N; k++) { // 適当な回数操作する
      for (int i = 0; i < N; i++) {
         if (dist[i] == -INF) continue;
         for (edge e : G[i]) {
            dist[e.to] = max(dist[e.to], dist[i] + e.cost);
         }
      }
   }
   ll ans2 = dist[N-1];

   // 2つの答えが違えば負の閉路が存在するため"inf"となる
   if (ans1 != ans2) {
      puts("inf");
   } else {
      cout << ans1 << endl;
   }

   return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<int> v(n);
  r(i,n) cin>>v.at(i);
  int q;
  cin>>q;
  while(q--){
    int a, b, c;
    cin >> a >> b >> c;
    rotate(v.begin()+a, v.begin()+b, v.begin()+c);
  }
  r(i,n){
    if(i) cout << " ";
    cout << v.at(i);
  }
  cout<<endl;
}


Measured memory_bytes: 3156