akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

const string INF = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
string ans_string(string s,string t) {
  string ans=INF;
  rep(i,s.size()-t.size()+1) {
    bool flag = true;
    string ss=s;
    rep(j,t.size()) {
      if(ss.at(i+j)=='?') ss.at(i+j) = t.at(j);
      if(ss.at(i+j)!=t.at(j)) {
        flag = false;
      }
    }
    rep(i,ss.size()) {
      if(ss.at(i)=='?') ss.at(i) = 'a';
    }
    if(flag) {
      if(ans>=ss) ans=ss;
    }
  }
  return ans;
}

int main() {
  string s,t;
  cin >> s >> t;
  if(s.size()<t.size()) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }

  string ans = ans_string(s,t);
  if(ans!=INF) cout << ans << endl;
  else cout << "UNRESTORABLE" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define Maxn 105
using namespace std;
int n,m;
int num;//总共几种颜色
int vis[Maxn][Maxn];//染色计数
char mp[Maxn][Maxn];//原始地图
int dt[][2]= {{1,0},{-1,0},{0,1},{0,-1}};//八个方向
void dfs(int x,int y,char ch)
{
    if(vis[x][y])
        return;
    vis[x][y]=num;
    for(int i=0; i<4; i++)
    {
        int tx=x+dt[i][0];
        int ty=y+dt[i][1];
        if(!vis[tx][ty]&&mp[tx][ty]==ch)
            dfs(tx,ty,ch);
    }
}
int main()
{
    while(cin>>n>>m,n+m)
    {
        num=0;
        MEM(mp,'X');
        MEM(vis,0);
        for(int i=0; i<n; i++)
            for(int j=0; j<m; j++)
                cin>>mp[i][j];
        for(int i=0; i<n; i++)
            for(int j=0; j<m; j++)
            {
                if(!vis[i][j]&&mp[i][j]!='X')
                {
                    num++;
                    dfs(i,j,mp[i][j]);
                }
            }
        cout<<num<<endl;
    }
}



Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;
const ll inf = (ll) 9e18;

struct lazy_segtree {
  int n;
  vector<ll> data;
  vector<ll> lazy;

  lazy_segtree(const int s) {
    init(s);
  }

  lazy_segtree(const vector<ll> &v) {
    int s = v.size();
    init(s);
    for (int i = 0; i < s; i++) {
      data[i+n-1] = v[i];
    }
    for (int i = n-2; i >= 0; i--) {
      data[i] = data[i*2+1] + data[i*2+2];
    }
  }

  void init(const int s) {
    n = 1;
    while (n < s) n <<= 1;
    data = vector<ll>(2*n-1);
    lazy = vector<ll>(2*n-1);
  }

  void evaluate(int p) {
    if (lazy[p] != 0) {
      data[p] += lazy[p];
      if (p <= n-2) {
        lazy[p*2+1] += lazy[p] / 2;
        lazy[p*2+2] += lazy[p] / 2;
      }
      lazy[p] = 0;
    }
  }

  void update(int l, int r, ll v, int p = 0, int a = 0, int b = -1) {
    if (b < 0) b = n; // init

    // evaluate lazy value
    evaluate(p);

    if (r <= a || b <= l) return; // out of range
    if (l <= a && b <= r) { // fully covered
      lazy[p] += v * (b - a);
      evaluate(p);
    }
    else {
      update(l, r, v, p*2+1, a, (a + b) / 2); // left
      update(l, r, v, p*2+2, (a + b) / 2, b); // right
      data[p] = data[p*2+1] + data[p*2+2]; // update
    }
    return;
  }

  ll query(int l, int r, int p = 0, int a = 0, int b = -1) {
    if (b < 0) b = n; // init
    if (r <= a || b <= l) return 0LL; // out of range

    // evaluate lazy value
    evaluate(p);

    if (l <= a && b <= r) return data[p];// fully covered

    ll vl = query(l, r, p*2+1, a, (a + b) / 2); // left
    ll vr = query(l, r, p*2+2, (a + b) / 2, b); // right
    return vl + vr;
  }
};

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

  int n, d, a;
  cin >> n >> d >> a;
  vector<Pii> xh(n);
  for (auto &y: xh) cin >> y.first >> y.second;

  sort(xh.begin(), xh.end());

  vector<ll> x(n), h(n);
  for (int i = 0; i < n; i++) {
    x[i] = xh[i].first;
    h[i] = xh[i].second;
  }

  vector<ll> range(n);
  int right = 0;
  for (int left = 0; left < n; left++) {
    while (right < n) {
      if (x[right] <= x[left] + d * 2) right++;
      else break;
    }
    range[left] = right;
  }

  lazy_segtree health(h);
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    int remaining = health.query(i, i+1);
    if (remaining > 0) {
      ll bomb = (remaining + a - 1) / a;
      health.update(i, range[i], -(a * bomb));
      ans += bomb;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 16256
#include <iostream>
#include <cmath>
#include <cstring>
#include <stdio.h>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <bitset>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
using namespace std;
typedef long long LL;
const LL mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const double e = exp(1);
const double eps = 1e-9;
const int MAX_N = 100000 + 5;

int a;
int n;
int cnt;
int sum[3];

int calc(int x)
{
    if(x%2 != 0) return 0;
    if(x%4 == 0) return 2;
    if(x%2 == 0) return 1;
}

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

    ios::sync_with_stdio(false);
    cin >> n;
    for(int i=1; i<=n; i++) {
        cin >> a;
        cnt = calc(a);
        sum[cnt]++;
    }
    if(sum[1]==0){
        if(sum[0] <= sum[2]+1) puts("Yes");
        else puts("No");
    } else {
        if(sum[0] <= sum[2]) puts("Yes");
        else puts("No");
    }

    return 0;
}


Measured memory_bytes: 256
import collections
N, M = map(int, input().split())

K, S_list = list(), list()
for i in range(M):
  k, *S = map(int, input().split())
  # K.append(K)
  S_list.append(set(S))
P = list(map(int, input().split()))


def search(N, status=set()):
  if N == 0:
    yield status
  else:
    yield from search(N-1, status=status | {N})
    yield from search(N-1, status=status)


ans = 0
for status in search(N):
  for p, S in zip(P, S_list):
    if len(S & status) % 2 != p:
      break
  else:
    ans += 1
print(ans)




Measured memory_bytes: 3316
import java.util.*;

public class Main{

	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		Sns sns = new Sns(n);

		int m = scan.nextInt();
		for(int i = 0; i < m; i++)
			sns.addRel(scan.nextInt(), scan.nextInt());

		int q = scan.nextInt();
		for(int i = 0; i < q; i++)
			if(sns.isFriends(scan.nextInt(), scan.nextInt()))
				System.out.println("yes");
			else
				System.out.println("no");

		scan.close();
		System.exit(0);
	}
}

class Sns{

		int[] leader;
		int[] member;

		public Sns(int n){
			leader = new int[n];
			member = new int[n];
			for(int i = 0; i < n; i++){
				leader[i] = i;
				member[i] = 1;
			}
		}

		public boolean isFriends(int s, int t){
			if(top(s) == top(t))
				return true;
			else
				return false;
		}
		private int top(int s){
			if(leader[s] == s)
				return s;
			else
				return top(leader[s]);
		}

		public void addRel(int s, int t){
			if(isFriends(s, t))
				return;
			int tt = top(t);
			int st = top(s);
			if(member[st] < member[tt]){
				leader[st] = tt;
				member[tt] += member[st];
			}else{
				leader[tt] = st;
				member[st] += member[tt];
			}
		}
}

Measured memory_bytes: 107744
#include <iostream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main(){

  stack <int> sa;
  string m;
  int cnt=0,result=0,high=0,tmp=0,h[20000],i;
  vector <int> amo;

  cin>>m;
  for(i=m.size()-1;i!=-1;i--){
    if(m[i]=='\\') tmp++;
    if(m[i]=='/') tmp--;
    high=max(high,tmp);
    h[i]=high;
  }
  //for(i=0;i<m.size();i++) cout<<h[i]<<" ";                                                                                                                                                   

  for(i=0;i<m.size();i++){
    //    if(i>0) if(h[i]-h[i-1]==1) sa.pop();                                                                                                                                                 
    if(m[i]=='\\'){
      sa.push(i);
    } else if(m[i]=='/' && !sa.empty()) {
      cnt+=i-sa.top();
      sa.pop();
      if(sa.empty()){
	amo.push_back(cnt);
	result+=cnt;
	cnt=0;
      }
    }
    if(i<m.size()-1) if(h[i+1]-h[i]!=0) sa.pop();
  }
  if(cnt!=0){
    amo.push_back(cnt);
    result+=cnt;
  }
  if(amo.empty()) cout<<"0"<<endl<<"0"<<endl;
  else{
    cout<<result<<endl<<amo.size()<<" ";
    for(i=0;i<amo.size()-1;i++) cout<<amo[i]<<" ";
    cout<<amo[amo.size()-1]<<endl;
  }
  return 0;

}

Measured memory_bytes: 3324
import java.util.Scanner;
import java.util.Set;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner (System.in);
        String s = sc.next();
        if(s.equals("ABC")){
            System.out.println("ARC");
        }
        else {
            System.out.println("ABC"); 
        }
    }    
}

Measured memory_bytes: 26992
#!/usr/bin/env python

n=int(input())
a=[int(i) for i in input().split()]

def cal(p, rev):
    if(rev):
        lst=reversed(list(enumerate(a)))
    else:
        lst=list(enumerate(a))
    for k,v in lst:
        if(k%2==p):
            print(str(v)+" ", end="")

if(n%2==1):
    cal(0, True)
    cal(1, False)
    print()
else:
    cal(1, True)
    cal(0, False)
    print()


Measured memory_bytes: 34980
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>K>>N;
    cout<<(K * 500 >= N ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
 
int main(int argc, char* argv[])
{
  int n, x, p;
  int i, j, sq, f;
 
  scanf("%d", &n);
  p = 0;
  for(i = 0; i < n; i++){
    scanf("%d", &x);
	if(0 < (x % 2)){
      sq = (int)sqrt((double)x);
	  f = 1;
      for(j = 3; j <= sq; j += 2){
       if(0 == (x % j)){
		 f = 0;
         break;
       }
     }
     if(f==1){
       p++;
     }
	}else if(2 == x){
	  p++;
	}
  }
  printf("%d\n", p);

  return(0);
}

Measured memory_bytes: 596
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void) {
	string o, s;
	cin>>o>>s;
	ll sum = o.size() + s.size();
	REP(i, sum) {
		if(i % 2 == 0) cout<<o[i / 2];
		else cout<<s[i / 2];
	}
	cout<<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;

int main(){
    string s;
    cin >> s;
    bool flag = true;
    if(s[0]!='A') flag = false;
    int cnt=0;
    for(int i=3;i<s.size();i++){
        if(s[i-1]=='C') cnt++;
    }
    if(cnt!=1) flag = false;
    
    int cnt2=0;
    rep(i,s.size()){
        if(s[i]>='a' && s[i]<='z') cnt2++;
    }
    if(cnt2!=s.size()-2) flag = false;
    
    
    cout<< (flag? "AC":"WA") <<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
		
		int h1 =sc.nextInt();
		int m1 =sc.nextInt();
        
        int h2 =sc.nextInt();
        int m2 =sc.nextInt();
        int k =sc.nextInt();
        
        int ans=0;
        
        ans=(60*(h2-h1)+(m2-m1) -k);
        
        System.out.println(ans);
    }
}


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

int main() {
	string S, T;
	int R1[26], R2[26];
	bool check = true;
	for (int i = 0; i < 26; i++) {
		R1[i] = R2[i] = -1;
	}
	cin >> S >> T;
	for (int i = 0; i < S.size(); i++) {
		if (R1[S[i] - 'a'] >= 0) {
			if (R1[S[i] - 'a'] != T[i] - 'a') check = false;
		}
		else R1[S[i] - 'a'] = T[i] - 'a';
		if (R2[T[i] - 'a'] >= 0) {
			if (R2[T[i] - 'a'] != S[i] - 'a') check = false;
		}
		else R2[T[i] - 'a'] = S[i] - 'a';
	}
	if (check) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_multiset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
//find_by_order(k) - k is the kth element of the multiset
//order_of_key(k) - Number of elements striclty samller than k
ll modularExponentiation(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return modularExponentiation((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;

}
ll modInverse(ll A,ll M=MOD)
{
    return modularExponentiation(A,M-2,M);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	set<char> st;
	map<char,ll> mmap;
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		st.insert(s[i]);
		mmap[s[i]]++;
	}
	if(st.size()!=2)
	{
		cout<<"No"<<endl;
		return 0;
	}
	map<char,ll>::iterator itr;
	itr=mmap.begin();
	ll x=itr->second;
	itr++;
	ll y=itr->second;
	if(x==2 && y==2)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int a,b,c,i,count=0;

	scanf("%d %d %d\n",&a,&b,&c);
	for(i=a;i<=b;i++){
		if(c%i==0)
			count++;
	}
	printf("%d\n",count);

	return 0;
}

Measured memory_bytes: 600
S = input()
s = list(S)
for i in range(len(s)):
    s[i] = int(s[i])
p = []
p.append(s[len(s)-1])
for i in range(1,len(s)):
    p.append((p[i-1]+s[len(s)-i-1]*pow(10,i,2019))%2019)
p.sort()
u = 0
for i in range(len(p)):
    if p[i] == 0:
        u = u+1
    else:
        break
r = 1
q = []
for i in range(len(p)-1):
    if p[i] == p[i+1]:
        r = r+1
    else:
        if r > 1:
            q.append(r)
            r = 1
q.append(r)
w = 0
for i in range(len(q)):
    w = w + int(q[i]*(q[i]-1)/2)
print(w+u)

Measured memory_bytes: 18812
import java.util.*;
import java.lang.*; 
 
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		long a = scan.nextInt();
		long b = scan.nextInt();
		long c = scan.nextInt();
		
		long uhen= (c-a-b)*(c-a-b);
		long sahen = 4*a*b;
		
		if(c-a-b<=0){
		 System.out.println("No");
		}
		else{
		if(sahen < uhen){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
		}
	}
}

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

using namespace std;

int main()
{
  int n;
  int t[100001], x[100001], y[100001];
  cin >> n;
  t[0] = 0; x[0] = 0; y[0] = 0;
  for(int i = 1; i <= n; ++i)
    cin >> t[i] >> x[i] >> y[i];
  for(int i = 1; i <= n; ++i) {
    int dift = t[i-1] - t[i];
    int difx = x[i-1] - x[i];
    int dify = y[i-1] - y[i];
    if(dift > difx + dify) {
      cout << "No" << endl;
      return 0;
    }
    else {
      if((dift - difx - dify) % 2 != 0) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main(){
  double f3;
  int a,b,f1,f2;
  scanf("%d %d" ,&a , &b);
  f1 = a / b;
  f2 = a % b;
  f3 =(double) a / b;
  printf("%d %d %.5f\n",f1,f2,f3);
  return 0;
}


Measured memory_bytes: 2104
n = int(input())
li = list(map(int, input().split()))
li.sort(reverse=True)
count = 0

for i in range(n-2):
    for j in range(i+1, n-1):
        left = j
        right = n

        while right - left > 1:
            mid = (left + right)//2
            if li[i]-li[j] < li[mid]:
                left = mid
            else:
                right = mid
        count += left - j

print(count)


Measured memory_bytes: 43676
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#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())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
  int N;
  scanf("%d", &N);
  int a[N];
  int sum = 0;
  FOR(i,0,N-1){
    cin >> a[i];
    sum ^= a[i];
  }

  if(sum==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long 
#define IOS ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define SIZE 100005
 
int main()
{
	string ch;
	ll n,k,r,s,p;
	cin >> n >>k;
	cin >> r >> s >> p;
	cin >> ch;
	map<int,int>m1,m2,m3;
	for(int i = 0; i < ch.size(); i++)
	{
		if(ch[i] == 'r') m1[i+1]++;
		else if(ch[i] == 's') m2[i+1]++;
		else m3[i+1]++;
	}
	
	//for(auto it : m1) cout << it.first << " " << it.second << endl;
//	for(auto it : m2) cout << it.first << " " << it.second << endl;
	//for(auto it : m3) cout << it.first << " " << it.second << endl;
	//
	ll ans = 0;
	
	for(auto it : m1)
	{
		int f = it.first;
		if(it.second > 0)
		{
			ans += p;
			m1[f+k] = 0;
		}
	}
 //   cout << ans << endl;	
	for(auto it : m2)
	{
		int f = it.first;
		if(it.second > 0)
		{
			ans += r;
			m2[f+k] = 0;
		}
	}
//	cout << ans << endl;	
	for(auto it : m3)
	{
		int f = it.first;
		if(it.second > 0)
		{
			ans += s;
			m3[f+k] = 0;
		}
	}
	cout << ans << endl;	
	return 0;
}


Measured memory_bytes: 9728
var
    n, i, sum: Longint;
    a: array[1..100001] of Longint;

begin
    readln(n);
    sum := 0;
    a[0] := 0;
    a[n+1] := 0;
    for i := 1 to n do
    begin
        read(a[i]);
        inc(sum, abs(a[i] - a[i - 1]));
    end;
    inc(sum, abs(a[n]));
    for i := 1 to n do
    begin
        if ((a[i] >= a[i-1]) and (a[i] <= a[i+1])) or ((a[i] <= a[i-1]) and (a[i] >= a[i+1])) then
        begin
            writeln(sum);
        end
        else 
        begin
            writeln(sum - ( abs(a[i-1]-a[i])+abs(a[i]-a[i+1])-abs(a[i+1]-a[i-1]) ));
        end;
    end;
end.

Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>
#include <map>
#include <queue>
#include <stack>

using namespace std;
int main(int argc, const char * argv[]) {
    
    int n, k, x, y; cin >> n >> k >> x >> y;

    cout << ( min(n,k)*x + max(0, n-k)*y ) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N,D;
  cin >> N >> D;
  N += 2 * D;
  cout << N / (2 * D + 1) << endl;
  return 0;
}


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

using namespace std;
int main() {
  int n, t;
  cin >> n >> t;
  int cMax = 1 << 30;
  int result = -1;
  for (int i = 0; i < n; i++) {
    int c, t1;
    cin >> c >> t1;
    if (t1 <= t && c < cMax) {
      result = c;
      cMax = c;
    }
  }
  if (result == -1)
    cout << "TLE" << endl;
  else
    cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sync ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main(){
	sync
	int n,m;
	cin >> n >> m;
	pair<long long,long long> a[n];
	for(int i=0;i<n;i++) cin >> a[i].first >> a[i].second;
	sort(a,a+n);
	long long ans=0;
	for(int i=0;i<n;i++){
		if(m>=a[i].second){
			m-=a[i].second;
			ans+=a[i].first*a[i].second;
		}
		else{
			ans+=m*a[i].first;
			break;
		}
	}
	cout << ans << "\n";
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22)
        cout << "bust" << endl;
    else
        cout << "win" << endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> T;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);
 
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
 
using Graph = vector<vector<pair<int, int>>>;
using vvec = vector<vector<int>>;
using vec = vector<int>;
 
 
 
int gcd(int x, int y) { return y ? gcd(y, x%y) : x; }
int lcm(int x, int y) { return x/gcd(x, y)*y; }
int mod_pow(int x, int y) { int res = 1; while (y > 0) { if (y & 1) { res = res * x % MOD; } x = x * x % MOD; y >>= 1; } return res; }
int comb(int n, int k) { k = min(k, n - k); int nnn = 1; for (int i = n - k + 1; i <= n; i++) { nnn *= i; nnn %= MOD; } int kkk = 1; for (int i = 1; i <= k; i++) { kkk *= i; kkk %= MOD; } return (nnn * mod_pow(kkk, MOD - 2)) % MOD; }
int to_int(string s) { int n = s.size(); int ans = 0; for (int i = 0; i < n; i++) { ans = ((ans * 10) + (s[i] - '0')) % MOD; } return ans; }
bool is_prime(int n) { for(int i = 2; i*i <= n; i++) { if (n % i == 0) return false; } return n != 1; }
int extgcd(int a, int b, int& x, int& y) { // ax+by = gcd(a,b) >> gcd(a, b)
    int d = a;
    if(d != 0) { d = extgcd(b, a%b, y, x); y -= (a/b)*x; }
    else { x = 1, y = 0; }
    return 0;
}
 
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int n;
    cin>>n;
    int memo[15][15];
    rep(i,15) rep(j,15) memo[i][j]=0;
    for(int i=1;i<=n;i++){
        string s=to_string(i);
        int f=s[0]-'0';
        int l=s[s.size()-1]-'0';
        memo[f][l]++;
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        string s=to_string(i);
        int f=s[0]-'0';
        int l=s[s.size()-1]-'0';
        ans+=memo[l][f];
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
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; }
using namespace std;



const ll MAX = 5100000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}






int main(){
  ll X,Y;
  cin>>X>>Y;
  
  bool CAN=true;
  
  
  COMinit();
  
  if(Y>2*X || X>2*Y) CAN=false;
  if((X+Y)%3!=0) CAN=false;
  
  if(CAN){
    co(COM((X+Y)/3,X-(X+Y)/3)%MOD);
    return 0;
  }
  
  co(0);
  return 0;
  
}

Measured memory_bytes: 119808
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int lli;
const long long int MaxN=300005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	lli arr[MaxN];
	priority_queue < pair <lli,lli> > menor,mayor;
	void solve(){
		lli N,K,i,j,res=1e9,p,q;
		cin>>N>>K;
		pair <lli,lli> menori,mayori;
		for(i=0;i<N;i++){
			cin>>arr[i];
		}
		sort(arr,arr+N);
		for(i=0;i<=N-K;i++){
			//cout<<i<<" "<<i+K<<"\n";
			res=min(res,arr[i+K-1]-arr[i]);
		}
		cout<<res;
	}
int main(){
	//cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,t;
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		long n = sc.nextLong();
		long res = 0;
		for(long i = 1 ; i<= n;i++) {
			if(i%3!=0 && i%5!=0) res+=i;
		}
		System.out.println(res);
	}

}


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

int main(){
    constexpr long MOD = 1000000007;
    auto modinv = [&MOD](unsigned long t, unsigned long a){
        unsigned long ret = t % MOD, n = MOD - 2;
        while(n){
            if(n & 1){
                ret *= a;
                ret %= MOD;
            }
            a *= a;
            a %= MOD;
            n >>= 1;
        }
        return ret;
    };
    unsigned long B, W;
    cin >> B >> W;

    vector<unsigned long> tapi(B), tapu(W);
    tapi[0] = 1;
    tapu[0] = 1;
    for(unsigned long i = 1, j = W; i < B; ++i, ++j)tapi[i] = modinv(tapi[i - 1] * j, i);
    for(unsigned long i = 1, j = B; i < W; ++i, ++j)tapu[i] = modinv(tapu[i - 1] * j, i);

    unsigned long ans(1), den(500000004);
    for(unsigned long i = 0; i < B + W; ++i){
        cout << ans * den % MOD << endl;
        ans *= 2;
        if(i >= B - 1)ans += MOD - tapu[i - B + 1];
        if(i >= W - 1)ans += tapi[i - W + 1];
        ans %= MOD;
        den *= 500000004;
        den %= MOD;
    }
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long ll;
int n;
ll fact[1000001],invfact[1000001],ans,k,suma;
ll inv(ll a)
{
    ll b=mod-2;
    ll rez=1;
    while(b)
    {
        if(b%2)
            rez=(rez*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return rez;
}
ll combi(ll a, ll b)
{
    ll rez=fact[a];
    rez=(rez*invfact[b])%mod;
    rez=(rez*invfact[a-b])%mod;
    return rez;
}
int main()
{
    cin>>n;
    fact[0]=1;
    invfact[0]=inv(1);
    for(int i=1;i<=n;i++)
    {
        fact[i]=(fact[i-1]*i)%mod;
        invfact[i]=inv(fact[i]);
    }
    //suma=fact[n-1];
    for(k=n/2;k<n;k++)
    {
        ll x=combi(k-1,n-k-1);
        x=(x*fact[k])%mod;
        x=(x*fact[n-k-1])%mod;
        x=x-suma;
        if(x<0)
            x+=mod;
        suma=(suma+x)%mod;
        x=(x*k)%mod;
        ans=(ans+x)%mod;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
 
 
long long int dp[100005][3];
 int main()
{   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin>>n;
    int arr[n][3];
    
    for(int i=0;i<n;i++)
     cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
     
     dp[0][0]=arr[0][0];
     dp[0][1]=arr[0][1];
     dp[0][2]=arr[0][2];
     
    for(int i=1;i<n;i++)
    {
    	dp[i][0]=max(dp[i-1][1],dp[i-1][2])+arr[i][0];
    	dp[i][1]=max(dp[i-1][0],dp[i-1][2])+arr[i][1];
    	dp[i][2]=max(dp[i-1][0],dp[i-1][1])+arr[i][2];
	}
      
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	return 0;
}  

Measured memory_bytes: 3840
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 10000000;
const long long inf = 11451419198109130;
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<int, PP> PPP;
struct edge { int to; int to2; int cost; };

int gcd(int a, int b) {
	if (!b)return a; return gcd(b, a%b);
}
signed main() {
	int n; cin >> n;
	int a; cin >> a;
	rep(i, n - 1) {
		int b; cin >> b; a = gcd(a, b);
	}
	cout << a << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 1234567890

const int maxn = 2e5 + 10;


//initialization here
//
vector<P> v;

//
//initialization finish


// your function is here
//



//
// your function finished



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

	// your code is here
	//
	

	ll n, t; cin >> n >> t;

	ll min = INF, machi, max = 0 , a;
	rep(i, n)
	{
		cin >> a;
		if (a < min)
		{
			min = a;
			machi = i;
		}

		if (a-min > max)
		{
			max = a - min;
			v.erase(all(v));
			v.pb(mp(machi, i));
		}
		else if (a - min == max)
		{
			v.pb(mp(machi, i));
		}
	}


	Print(v.size());
	//
	// your code finished


	return 0;
}

Measured memory_bytes: 892
#include <stdio.h>
int gcd(int, int);

int main(){
  int x,y;
  scanf("%d%d",&x,&y);
  printf("%d\n",gcd(x,y));
  return 0;
}

int gcd(int a, int b){
  int r;
  while(b>0){
    r=a%b;
    a=b;
    b=r;
  }
  return a;
}



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

int main() {
  
  int N;
  cin >> N;
  int a = 0;
  int n = N;
  
  for(int i = 0; i<9; i++){
    a = a + (n%10);
    n /= 10;
  }
  
  if(N%a == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}
    


Measured memory_bytes: 256
var
	n, k : integer;
    a : array[0..200005] of integer;
    i : integer;
    
begin
	readln(n);
    for i := 2 to n do
    begin
    	read(k);
        a[k] := a[k] + 1;
    end;
    writeln;
    for i := 1 to n do
    	writeln(a[i]);
end.

Measured memory_bytes: 1396
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N = inputInt()

	ans = {}
	ans["AC"] = 0
	ans["WA"] = 0
	ans["TLE"] = 0
	ans["RE"] = 0

	for i in range(N):
		s = inputStr()
		ans[s] += 1

	print("AC x {}".format(ans["AC"]))
	print("WA x {}".format(ans["WA"]))
	print("TLE x {}".format(ans["TLE"]))
	print("RE x {}".format(ans["RE"]))

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


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

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

    string s;
    cin >> s;

    int n = s.size();

    int l = 0, r = n - 1;
    int ans = 0;
    while(l < r){
        if(s[l] == s[r]){
            l++;
            r--;
        } else {
            if(s[l] == 'x'){
                l++;
                ans++;
            } else if(s[r] == 'x'){
                r--;
                ans++;
            } else {
                ans =  -1;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"YES\n":"NO\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<char> vec(6);
  REP(i,6) cin >> vec[i];
  bool f = true;
  if(vec[0] != vec[5]) f = false;
  if(vec[1] != vec[4]) f = false;
  if(vec[2] != vec[3]) f = false;
  YesorNo(f);
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=998244353;
const int INF=1e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;
    int ans=0;
    rep(i,4) {
        if (s[i]=='+') ++ans;
        else --ans;
    }
    cout << ans << endl;

    return 0; 
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){
  
  string s,t;
  cin >> s >> t;
  if(s == t.substr(0,s.size()))cout << "Yes" << endl;
  else cout << "No" << endl;




  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  char s[n + 1];
  cin >> s;
  int max_len = 0;
  for(int i = 0; i < n; i++) {
    int c = 0;
    int A[n];
    fill(A, A + n, 0);
    for(int j = i + 1; j < n; j++) {
      if(j + A[j - c] < i + c + A[c + i]){
        A[j] = A[j - c];
      } else {
        int k = max(0, i + c + A[i + c] - j);
        while((j + k < n) && (s[i + k] == s[j + k])) k++;
        A[j] = k;
        c = j - i;
      }
      int candidate = min(A[j], j - i);
      max_len = max(max_len, candidate);
    }
  }
  cout << max_len << "\n";
  return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)


int main(){
    string s;
    cin >> s;
    if(s=="Sunny"){
        cout << "Cloudy" << endl;
    }else if(s=="Cloudy"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
    return 0;
}

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int N;
vector<vector<pair<int, int>>> A;

int main(void) {
    cin >> N;
    A.resize(N);

    rep(i, N) {
        int a;
        cin >> a;
        rep(k, a) {
            int x, y;
            cin >> x >> y;
            A[i].push_back(make_pair(x - 1, y));
        }
    }

    int highest = 0;
    for (int bit = 0; bit < (1 << N); ++bit) {
        int count = 0;
        bool contradiction = false;

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

            // 不親切な人の話は聞かない
            if ((bit & (1 << i)) == 0) {
                continue;
            }

            count++;
            for (auto a : A[i]) {

                if ((bit & (1 << a.first)) != (a.second << a.first)) {
                    contradiction = true;
                    break;
                }
            }
            
            if (contradiction) break;
        }

        if (!contradiction) {
            highest = max(highest, count);
        }
    }

    cout << highest << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <algorithm>

using namespace std;

struct edge {
	int u, v, w;
	edge(int _u = 0, int _v = 0, int _w = 0) : u(_u), v(_v), w(_w) {}
	bool operator<(const edge& o) const {
		return w < o.w;
	}
};

int fa[1005];

int root(int x) {
	return fa[x] = (x == fa[x] ? x : root(fa[x]));
}

int n, m;
vector<edge> e;

int main() {
	while (scanf("%d%d", &n, &m) && n) {
		e.clear();
		for (int i = 0; i <= n; ++i) {
			fa[i] = i;
		}
		int u, v, w;
		for (int i = 0; i < m; ++i) {
			scanf("%d%d%d", &u, &v, &w);
			e.push_back(edge(u, v, w));
		}
		sort(e.begin(), e.end());
		int cnt = 0;
		for (int i = 0; i < m; ++i) {
			int fa1 = root(e[i].u);
			int fa2 = root(e[i].v);
			if (fa1 != fa2) {
				fa[fa1] = fa2;
				if (++cnt == (n + 1)/2) {
					printf("%d\n", e[i].w);
					break;
				}
			}
		}
	}
    return 0;
}

Measured memory_bytes: 1268
#include<iostream>
using namespace std;
int main()
{
  int Nn;
  cin>>Nn;
  int A[Nn],B[Nn+1]={0};
  int in;
  
  for(in=1;in<Nn;in++)
  {
  	cin>>A[in];
    B[A[in]]++;
  }
  for(in=1;in<=Nn;in++)
  {
  	cout<<B[in]<<endl;
  }
  
return 0;

}

Measured memory_bytes: 5188
#include<bits/stdc++.h>
#include <random>
using namespace std;
#define ll long long int 
#define ii pair<int ,int >
#define pb push_back
#define vl vector <long long int >
#define vi vector <int >
#define mod 1000000007
#define eps 1e-9
#define fi first
#define se second
#define _ <<" "<<
#define forn(x,	n) for(int x = 0; x < n ;++ x) 
#define forn1(x,n) for(int x = 1; x <= n ;++ x)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}

int main(){
	IOS
 	
 	int n;
 	cin>>n;
 	vi v(n);
 	cin>>v;

 	vi dp(n+1);

 	dp[0]=dp[1]=0;
 	dp[2]=abs(v[1]-v[0]);

 	for(int i=3;i<=n;i++)
 	{
 		dp[i] = min(dp[i-1]+abs(v[i-1]-v[i-2]),dp[i-2]+abs(v[i-1]-v[i-3]));
 	}

 	cout<<dp[n];
 
	return 0;	
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b / gcd(a,b);}

int main() {
    string s;
    cin >> s;
    int res = 0;
    for(int i=0; i<s.size(); i++) {
        if (s[i] == '+') {
            res++;
        } else {
            res--;
        }
    }
    cout << res << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
int main() {

  
  ll n; cin>>n;
  vector<ll>a(n); rep(i,n){cin>>a.at(i);}
  sort(all(a));
  
  ll ans=0;
  if(n==2){ans=max(a.at(0),a.at(1));}
  else if(n==4){ans=a.at(n-1)+a.at(n-2)*2;}
  else{
  
  if(n%2==1){ans=a.at(n-1)+a.at(((n+1)/2)-1);
            rep(j,((n+1)/2)-2){ans+=a.at(n-2-j)*2;}}
  
  
  else{ans=a.at(n-1)+a.at(n/2)*2;
            rep(j,(n/2)-2){ans+=a.at(n-2-j)*2; }}
  } 
   cout<<ans<<endl;
}

Measured memory_bytes: 4844
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <stack>
#include <iomanip>
#include <numeric>
#include <bitset>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;

typedef long long ll;

int h, w;
char maze[30][30];

int bfs(int sx, int sy, int gx, int gy) {
  int dx[] = {-1, 0, 0, 1};
  int dy[] = {0, -1, 1, 0};

  int dist[30][30];
  rep(i, 30) rep(j, 30) dist[i][j] = -1;

  queue<pair<int, int> > que;
  que.push( make_pair(sx, sy) );
  dist[sy][sx] = 0;

  while (!que.empty()) {
    auto x = que.front().first;
    auto y = que.front().second;
    que.pop();
    rep(i, 4) {
      int nx = x + dx[i];
      int ny = y + dy[i];
      if (nx < 0 || nx >= w || ny < 0 || ny >= h) {
        continue;
      }
      if ( maze[ny][nx] == '#' ) { continue; }
      if ( dist[ny][nx] != -1 ) { continue; }
      dist[ny][nx] = dist[y][x] + 1;
      que.push( make_pair(nx, ny) );
    }
  }
  return dist[gy][gx];
}

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

  cin >> h >> w;

  rep(i, h) {
    cin >> maze[i];
  }
  
  int ans = 0;
  rep(sx, w) {
    rep(sy, h) {
      rep(gx, w) {
        rep(gy, h){
          if (maze[sy][sx] == '.' && maze[gy][gx] == '.') {
            int t = bfs(sx, sy, gx, gy);
            ans = max(ans, t);
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define mod 1000000007
#define mp make_pair
typedef long long ll;
const int oo = 0x3f3f3f3f;

int main(void)
{
	int h, w;
	cin >> h >> w;
	int n;
	cin >> n;
	int a[n];
	for(int i = 0;i < n;i++)
		cin >> a[i];
	int ans[h][w];
	int x = 0, y = 0, add = 1;
	for(int i = 0;i < n;i++)
	{
		int tmp = a[i];
		for(int j = 0;j < tmp;j++)
		{
			ans[x][y] = i + 1;
			y += add;
			if(y == -1 || y == w)
			{
				y = (y == -1) ? 0 : w - 1;
				x++;
				add *= -1;
			}
		}
	}
	for(int i = 0;i < h;i++)
	{
		for(int j = 0;j < w;j++)
			cout << ans[i][j] << " ";
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 384
N, Q, S, *_LR = open(0).read().split()
N = int(N)
Q = int(Q)
LR = list(zip(*[map(int, iter(_LR))]*2))

AC = [0]*(N)

for i in range(1, N):
    if S[i-1] == "A":
        if S[i] == "C":
            is_AC = 1
        else:
            is_AC = 0
    else:
        is_AC = 0

    if i == 1:
        AC[i] = is_AC
    else:
        AC[i] = AC[i-1] + is_AC
        
for L,R in LR:
    print(AC[R-1] - AC[L-1])

Measured memory_bytes: 34332
#include <stdio.h>
int n;
long long a[100000];
long long b[100000];
long long s, t;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", a + i);
		s += a[i];
		if (i % 2)t += a[i];
	}
	b[0] = s - 2 * t;
	for (int i = 1; i < n; i++) {
		b[i] = 2 * a[i - 1] - b[i - 1];
	}
	for (int i = 0; i < n - 1; i++) {
		printf("%lld ", b[i]);
	}
	printf("%lld\n", b[n - 1]);
}

Measured memory_bytes: 2816
def main():
    def solve(N, W, wv):
        dp = [-1] * (W+1)
        dp[0] = 0

        for i in range(N):
            wi = wv[i][0]
            vi = wv[i][1]

            for j in range(W-wi, -1, -1):
                if dp[j] == -1:
                    continue
                if dp[j+wi] < dp[j] + vi:
                    dp[j+wi] = dp[j] + vi

        return max(dp)

    N, W = map(int, input().split())
    wv = tuple(tuple(map(int, input().split())) for i in range(N))
    print(solve(N, W, wv))

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


Measured memory_bytes: 7736
N, Y = map(int, input().split())
 
for i in range(N+1):
    for j in range(N+1-i):
            if 10000*i + 5000*j + 1000*(N-i-j) == Y:
                print(i, j, N-i-j)
                quit()
print(-1, -1, -1)

Measured memory_bytes: 3060