akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
using namespace std;

int main(){
    int N;
    cin >> N;
    int route = N*(N-1)/2;
    vector<int> d(N);
    for (int i = 0; i < N; i++)
    {
        /* code */
        cin >> d[i];
    }

    int total = 0;
    for (int i = 0; i < N; i++)
    {
        /* code */
        for (int j = i + 1; j < N; j++)
        {
            /* code */
            total += d[i] * d[j];
        }
        
    }
    cout << total << endl;
}

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

int answer = 0, n, m;
vector<int> adj[10];
bool processed[10]={false};
void dfs(int v){
    processed[v]=true;
    for(auto vert: adj[v]){
        if(processed[vert]==true) continue;
        dfs(vert);
        bool ok=true;
        for(int i=1; i<=n; i++){
            if(processed[i]==false) ok=false;
        }
        if(ok==true) answer++;
        processed[vert]=false;
    }
}


int main(){
    cin>>n>>m;
    for(int i = 0; i < m; i++){
        int a, b;
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    dfs(1);
    cout<<answer;

    return 0;
}

Measured memory_bytes: 256
#n = int(input())
n, q = map(int, input().split())
#bl = list(map(int, input().split()))
#al=[list(input()) for i in range(n)]
s = input()
acnum = [0]*(n+1)
for i in range(2, n+1):
    if s[i-2:i] == 'AC':
        acnum[i] += acnum[i-1]+1
    else:
        acnum[i] += acnum[i-1]

for i in range(q):
    l, r = map(int, input().split())
    print(acnum[r]-acnum[l])


Measured memory_bytes: 13024
#pragma GCC optimize(3,"Ofast","inline")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 500;
const int mod = 1e9 + 7;
const double pi = acos(-1);
const ll inf = 9e18;
int h,w,kk,ww;
int dp[105][105];
int main()
{
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
//    ios::sync_with_stdio(false);
//    cin.tie(NULL);
    scanf("%d%d%d", &h, &ww, &kk);
    w = ww;
    --ww;
    --kk;
    dp[0][0] = 1;
    for (int i = 1; i <= h; ++i)
    {
        for (int j = 0; j < (1 << ww); ++j)
        {
            int f = 1;
            int tmp = j;
            while (tmp)
            {
                int t = tmp & 1;
                tmp >>= 1;
                if (t && (tmp & 1))
                {
                    f = 0;
                    break;
                }
            }
            if (!f)
                continue;
            for (int k = 0; k < w; ++k)
            {
                if (k > 0 && ((j >> (k - 1)) & 1))
                    dp[i][k] += dp[i - 1][k - 1];
                else if (k < w - 1 && ((j >> k) & 1))
                    dp[i][k] += dp[i - 1][k + 1];
                else
                    dp[i][k] += dp[i - 1][k];
                if (dp[i][k] >= mod)
                    dp[i][k] -= mod;
            }
        }
    }
    printf("%d\n", dp[h][kk]);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()


int A[(int)1e5 + 10];



int main() {

    int n;
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> A[i];
    }
    bool ok = 1,_ok = 1;
    for(int i=1;i<=n;i++){
        ok &= (A[i]&1);
        _ok &= ((A[i]&1)==0);
    }
    if(ok || _ok){

        cout << "YES" << endl;
        return 0;

    }
    int cnt = 0;
    for(int i=1;i<=n;i++){
        cnt += (A[i]&1);
    }
    if((cnt&1)==0){
        cout << "YES" << endl;
        return 0;
    }
    cout << "NO" << endl;


}


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

using namespace std;

int main(void){
  int H, W, count, change, result = 0;
  string input;
  vector<string> str_map;
  int U[2000][2000], D[2000][2000], L[2000][2000], R[2000][2000];
  
  cin >> H >> W;
  for(int i = 0; i < H; i++){
    cin >> input;
    str_map.push_back(input);
  }
  
  for(int w = 0; w < W; w++){
    count = 0;
    for(int h = 0; h < H; h++){
      if(str_map[h][w] == '#'){
        count = 0;
      }
      else{
        count++;
      }
      U[h][w] = count;
    }
  }
  
  for(int w = 0; w < W; w++){
    count = 0;
    for(int h = H-1; h > -1; h--){
      if(str_map[h][w] == '#'){
        count = 0;
      }
      else{
        count++;
      }
      D[h][w] = count;
    }
  }
  
  for(int h = 0; h < H; h++){
    count = 0;
    for(int w = 0; w < W; w++){
      if(str_map[h][w] == '#'){
        count = 0;
      }
      else{
        count++;
      }
      L[h][w] = count;
    }
  }
  
  for(int h = 0; h < H; h++){
    count = 0;
    for(int w = W-1; w > -1; w--){
      if(str_map[h][w] == '#'){
        count = 0;
      }
      else{
        count++;
      }
      R[h][w] = count;
    }
  }
  
  for(int h = 0; h < H; h++){
    for(int w = 0; w < W; w++){
      change = U[h][w] + D[h][w] + L[h][w] + R[h][w] - 3;
      result = max(result, change);
    }
  }
  
  cout << result << endl;
  
  return 0;
}

Measured memory_bytes: 66816
#pragma region
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
#pragma endregion

void solve() {
  int a;
  string s;
  cin >> a >> s;
  if (a >= 3200) {
    cout << s << endl;
  } else {
    cout << "red" << endl;
  }
}


Measured memory_bytes: 256
s = int(input())

def f(n):
    if n%2 == 0:
        return n // 2
    else:
        return 3*n + 1

a = [s]
for i in range(1, 1000001):
    if a[i-1] in a[:i-1]:
        print(i)
        break
    else:
        a.append(f(a[i-1]))

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

// using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
const int MAX = 55;
int n, m;
bool a[MAX][MAX];
bool b[MAX][MAX];

/***** MAIN *****/
signed main() {
  cin >> n >> m;
  REP(i,n) REP(j,n) {
    char c;
    cin >> c;
    a[i][j] = c == '#';
  }
  REP(i,m) REP(j,m) {
    char c;
    cin >> c;
    b[i][j] = c == '#';
  }
  int size_dif = n-m;
  REP(i,size_dif+1) {
    REP(j,size_dif+1) {
      bool flag = true;
      REP(y, m) {
        REP(x, m) {
          if(a[y+i][x+j] != b[y][x]) {
            flag = false;
            break;
          }
        }
      }
      if(flag) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No";
  
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
#include <cstdio>

int main(){
    int a, b, c;
    scanf("%d %d %d",&a, &b, &c);
    int ans;
    if(a * c <= b){
        ans = c;
    }else{
        ans = b / a;
    }
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1E9 + 9;
const int INF = 1<<29; 

int main(){
    int N, M;
    cin >> N >> M;
    if(N == M){
        cout << "Yes" << endl;
    }else{
    cout << "No" << endl;
    }
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9
string s;

ll ans = 0;

void dfs(int idx, ll sum){
  if(idx == s.size()){
    ans += sum;
  }
  REP(i, s.size()-idx){
    ll add = stoll(s.substr(idx, i+1));
    dfs(idx+i+1, sum+add);
  }
}

int main(){
  cin >> s;
  dfs(0, 0);
  cout << ans << endl;
  

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

import sys


def exchageCup(cups, param):
    cups[param[0]], cups[param[1]] = cups[param[1]], cups[param[0]]


def main():
    params = [x.rstrip("\n").split(",") for x in sys.stdin.readlines()]
    cups = {
        "A": True,
        "B": False,
        "C": False}

    for param in params:
        exchageCup(cups, param)

    for key in cups:
        if cups[key]:
            print key


if __name__ == '__main__':
    main()

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    
    int n; cin >> n;
    vi a(n);
    REP(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    int ans = 0;
    REP(i, n - 1) ans += a[i];
    ans += a[n-1] / 2;
    cout << ans << endl;
    

    return 0;
}

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

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define boost ios::sync_with_stdio(0); cin.tie(0)

#define fi first
#define se second

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int, int> pii;

const int X = 250000 + 5;
const int N = 1e6 + 5;
const ull B = 545;
ull invB;

/***************************************************************************/

ull power(ull a, ull n) {
	if(n == 0) return 1;
	ull p = power(a, n>>1);
	p = p * p;
	if(n & 1) p = p * a;
	return p;
}

string S;
ull powB[N];

inline ull& pow(int n) {
	if(n < 0) n += N;
	return powB[n];
}

map<ull, int> M;

int main() {

	boost;
	invB = power(B, (ull(1)<<63)-1);
	assert(B * invB == 1);

	pow(0) = 1;
	for(int i=1; i<X; i++) {
		pow(i) = pow(i-1) * B;
		pow(-i) = pow(-i+1) * invB;
	}

	int n; cin>>n;
	cin>>S;

	ull phas = 0, chas = 0;

	int p = 0;
	for(auto it : S) {
		if(it == '+') phas += pow(p);
		else if(it == '-') phas -= pow(p);
		else if(it == '>') p++;
		else p--;
	}

	ll ans = 0;
	M[phas]++;
	p = 0;

	for(auto it : S) {
		if(it == '+') chas += pow(p);
		else if(it == '-') chas -= pow(p);
		else if(it == '>') p++;
		else p--;

		ans += M[chas];
		M[chas + pow(p) * phas]++;
	}

	cout<<ans<<"\n";

	return 0;
}

Measured memory_bytes: 37396
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,s,a,b;
    s=0;
    cin>>n;
    a=0;
    int arr[n];
    fr(i,n){
        cin>>arr[i];
        s+=arr[i];
    }
    fr(i,n+1){
        a+=arr[i];
        if(a>s/2){
            cout<<min(2*a-s,s-2*(a-arr[i]));
            exit(0);
        }
    }
}

Measured memory_bytes: 3644
#include <bits/stdc++.h> 
using namespace std; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define EPS 0.000001
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
void setIO(string s) {
  ios_base::sync_with_stdio(0); cin.tie(0); 
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}
int main()
{
  //flash;
  string a;
  cin>>a;
  if(a=="ABC")cout<<"ARC";
  else cout<<"ABC";
  return 0;
}
//code the AC sol !
// BS/queue/map

Measured memory_bytes: 3596
using System;
class Program{
    static void Main(){
        while(true)
        {
            string[] s = Console.ReadLine().Split(' ');
            int h,w;
            h = int.Parse(s[0]);
            w = int.Parse(s[1]);
            if(h == 0 && w == 0)break;
            for(int i=0;i < h;i++)
            {
                for(int j = 0;j < w; j++)
                {
                    Console.Write('#');
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
}



Measured memory_bytes: 15904
#include <iostream>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)

int main() {
	int n, s;
	cin >> n;
	rep(i,n) {
		cin >> s;
		cout << "Case " << i+1 << ":" << endl;
		rep(j,10) {
			s *= s;
			s /= 100;
			int ns = s/10000 * 10000;
			s -= ns;
			cout << s << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    int N;
    string S;
    cin >> N >> S;

    int red, blue;
    red = count(S.begin(), S.end(), 'R');
    blue = count(S.begin(), S.end(), 'B');
    if(red > blue){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl
#define rep(n, i) for (int i = 0; i < n; i++)

using namespace std;
using i64 = long long;

int main()
{
    int n;
    cin >> n;
    vector<i64> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if(a[i]==0)
        {
            cout << "0" << endl;
            return 0;
        }
    }
    
    i64 p = 1;
    for (auto &&ai : a)
    {
        if (p > 1000000000000000000LL/ai)
        {
            cout << "-1" << endl;
            return 0;
        }
        p *= ai;
    }
    
    cout << p << endl;

    return 0;
}

Measured memory_bytes: 3988
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVL vector<vector<ll>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<ll,ll>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;
constexpr ll MOD = 1000000007;
using std::cout;
using std::endl;
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::multiset;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, ll b) {
	ll ans = 1;
	while (b > 0) {
		if (b % 2 == 1) {
			ans *= a;
			ans %= MOD;
		}
		b /= 2;
		a *= a;
		a %= MOD;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a - b < b) { return comb(a, a - b); }
	ll c = 1;
	FOR(i, a - b + 1, a + 1) {
		c *= i;
		c %= MOD;
	}
	ll k = 1;
	FOR(i, 2, b + 1) {
		k *= i;
		k %= MOD;
	}
	c *= pow(k, MOD - 2);
	return c % MOD;
}
multiset<ll> prime_decomposition(ll n) {
	ll i = 2;
	multiset<ll> table{};
	while (i * i <= n) {
		while (n % i == 0) {
			n /= i;
			table.emplace(i);
		}
		++i;
	}
	if (n > 1) {
		table.emplace(n);
		return table;
	}
	return table;
}
/*
-- bit --
REP(i, (1 << n)) {
	REP(j, n) {
		cout << (1 & (i >> j));
	}
	cout << endl;
}
*/


int main() {
	int n, k;
	cin >> n >> k;
	vector<bool> v(10, false);
	REP(i, n) { 
		ll k;
		cin >> k;
		v[k] = true;
	}

	FOR(i, n, 1e5) {
		ll t = i;
		bool flg = true;
		while (t > 0) {
			ll p = t % 10;
			t /= 10;
			if (v[p]) {
				flg = false;
				break;
			}
		}
		if (flg) {
			cout << i << endl;
			return 0;
		}
	}

}

Measured memory_bytes: 256
const int isDebugMode = 1;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long gcd(T1 a, T2 b){return a % b ? gcd(b , a % b) : b;}
template<class T1, class T2> void reduce(T1 &a, T2 &b){ll g = gcd(a, b); a /= g; b /= g; return;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

int main(){
    ll N; cin >> N;
    vector<ll> a(N), ans;
    rep(i, N) cin >> a[i];
    ll now = 0;
    for(ll i = 1; i < N; i++)now = now ^ a[i];
    ans.push_back(now);
    rep(i, N - 1){
        now ^= a[i];
        now ^= a[i + 1];
        ans.push_back(now);
    }
    debug(ans);
}

Measured memory_bytes: 7868
#include<bits/stdc++.h>
using namespace std;
const int N = 100005;
vector<pair<int,pair<int,int> > >lis;
int cnt[N];
int ans[N][2];
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		lis.push_back(pair<int,pair<int,int> >(a, pair<int,int>(b, i)));
		ans[i][0] = a;
	}
	sort(lis.begin(), lis.end());
	for (int i = 0; i < m; i++) {
		ans[lis[i].second.second][1] = ++cnt[lis[i].first];
	}
	for (int i = 0; i < m; i++) {
		printf("%06d%06d\n", ans[i][0], ans[i][1]);
	}
}

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

void prians(bool answer) {
  if(answer)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
int r, g, b;

int main() {
  cin >> r >> g >> b;
  prians((g * 10 + b) % 4 == 0);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int price, payment, change;
  scanf("%d", &price);
  if(1<= price && price <= 10000){
    payment = (price + 1000 -1) / 1000 * 1000;
    change = payment - price;
    printf("%d\n", change);
  }else{
    printf("%d isn't adequate", price);
  }
  return 0;
}


Measured memory_bytes: 1692
#include <iostream>
using namespace std;
int main(){
  int N, K, Q;
  cin >> N >> K >> Q;
  int player[N];
  for(int i = 0; i < N; i++){
    player[i] = K-Q;
  }
  for(int i = 0; i < Q; i++){
    int a;
    cin >> a;
    a--;
    player[a]++;
  }
  for(int i = 0; i < N; i++){
    if(player[i] > 0){
      cout << "Yes" << endl;
      continue;
    }
    cout << "No" << endl;
  }


}

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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using ll = long long;
const ll inf = 1e9+5; 

const double PI =  3.14159265;

int main(){
	IO;
	int a,b,c;
	cin>>a>>b>>c;
	printf("%d %d %d",c,a,b);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=2e5;
const int inf=1e9;
vector<int> g[size];
vector<pair<int,long>> dp[size];
map<int,pair<int,long>> L[size],R[size];
pair<int,long> ans[size];
long fact[size];
void calc(int n){
	fact[0] = 1;
	rep(i,1,n+1){
		fact[i] = (fact[i-1] * i) % mod;
	}
	return;
}
long modcomb(long n,long r){//nCr mod p
	if(n<r) return 0;
	long x = (fact[n-r] * fact[r]) % mod;
	long res = 1; int i = 0;
	while( (mod-2) >= (1<<i) ){
		if( (mod-2) & (1<<i) ) (res *= x) %= mod;
		i++; x = x * x % mod;
	}
    return (res * fact[n]) % mod;
}
pair<int,long> func(pair<int,long> x,pair<int,long> y){
	pair<int,long> z;
	z.first = x.first + y.first;
	z.second = x.second * y.second % mod;
	(z.second *= modcomb(z.first , x.first)) %= mod;
	return z;
}
pair<int,long> dfs1(int p,int v){
	pair<int,int> res = {0,1};
	for(int u:g[v]){
        if(u == p) continue;
		dp[v].push_back(dfs1(v,u));
		res = func(res , dp[v].back());
	}
	res.first++;
	return res;
}
void dfs2(int p,int v){
	ans[v] = func(R[v][0] , dp[v].back());
    int j = 0;
	for(int u:g[v]){
		if(u == p) continue;
		pair<int,long> t = func(dp[v].back() , func(L[v][j] , R[v][j+1]));
		t.first++;
		dp[u].push_back(t);
		dfs2(v,u);
        j++;
	}
	return;
}
int main(){
	int N;cin>>N;
	int a,b;
	rep(i,0,N-1){
		cin>>a>>b; a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
    calc(size);
	dfs1(-1,0);
	rep(i,0,N){
		L[i][0] = {0,1}; R[i][dp[i].size()] = {0,1};
		rep(j,0,dp[i].size()) L[i][j+1] = func(L[i][j] , dp[i][j]);
		for(int j = dp[i].size(); j > 0; j--) R[i][j-1] = func(R[i][j] , dp[i][j-1]);
	}
	dp[0].push_back({0,1});
	dfs2(-1,0);
	rep(i,0,N) cout<<ans[i].second<<endl;
}

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

char btoc(bool b) {
  return b ? '+' : '-';
}

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

  int A = s / 1000 % 10;
  int B = s / 100 % 10;
  int C = s / 10 % 10;
  int D = s % 10;

  vector<vector<bool>> v;
  rep(i,0,(1<<3)-1) {
    vector<bool> a(3, 0);
    rep(j,0,2) {
      if (i & (1<<j)) a[j] = 1;
    }
    v.push_back(a);
  }

  rep(i,0,7) {
    int ans = 0;
    vector<bool> a = v.at(i);

    if (a.at(0)) ans = A + B;
    else ans = A - B;

    if (a.at(1)) ans += C;
    else ans -= C;

    if (a.at(2)) ans += D;
    else ans -= D;

    if (ans == 7) {
      cout << A << btoc(a.at(0)) << B << btoc(a.at(1)) << C << btoc(a.at(2)) << D << '=' << 7 << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int a[100];

int main() {
  int n,d,x;
  cin >> n >> d >> x;
  int sum = 0;
  rep(i, n){
    cin >> a[i];
  }
  rep(i, n){
    int tm = 1;
    for(int j=1; tm <= d; j++){
      tm=j*a[i]+1;
      sum++;
    }
  }
  cout << sum + x << endl;
}


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

bool dp[2000009];

int main()
{
    int n, i, j, a[2009], sum = 0;

    cin >> n;
    for(i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }

    dp[0] = 1;


    for(i = 0; i < n; i++)
    {
        for(j = sum/2; j >= a[i]; j--)
        {
            dp[j] |= dp[j - a[i]];
        }
    }

    for(i = sum/2; i >= 0; i--)
    {
        if(dp[i])
        {
            cout << sum - i;
            return 0;
        }
    }
}


Measured memory_bytes: 5584
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

//for A以上B未満でI探索 for (int I = A; i <= B; i++)
//string s = to_string(i);
int a = 0, b = 0, c = 0, x = 0, y = 0, z = 0, n = 0, sum = 0, i = 0;
string s = ""; asas; cncn;

int main(void) {
	cin >> a >> b;
	ans = a + b;
	if (ans >= 24)cout << ans - 24 << rt;
	else cout << ans << rt;
	please AC;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define fh(i,be,e) for(int i=head[be];~i;i=e[i].next)
#define fa(i,V) for(auto i:V)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
//Cancel in interactive questions
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define P pair<int,int>
#define SET set<int>
#define mp map<int,int>
#define mk make_tuple
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m
#define bffs(i) __builtin_ffs(i)
#define bcount(i) __builtin_popcount(i)
#define bone(i) ((1<<i)-1)
#define got(container,num) get<num-1>(container)
using namespace std;
const int INF=LLONG_MAX/2;
const int dx[]={0,0,-1,1},dy[]={-1,1,0,0};//up down left right
const int maxn=1e6+1e5;
const int mo_num=1e9+7;
int n,m,t,a[maxn],b[maxn],ans;

main()
{
    IOS
    cin>>n;
    fun(i) {
        cin >> a[i];
        ans^=a[i];
    }
    fun(i)
    {
        cout<<(ans^a[i])<<" ";
    }
    return 0;
}


Measured memory_bytes: 5140
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	for stdin.Scan() {
		line := strings.Split(stdin.Text(), " ")
		len := []int{}
		for i := 0; i < 3; i++ {
			tmp, _ := strconv.Atoi(line[i])
			len = append(len, tmp)
		}
		if len[0] == 0 && len[1] == 0 && len[2] == 0 {
			break
		}
		sort.Ints(len)
		d2 := len[0]*len[0] + len[1]*len[1]
		stdin.Scan()
		n, _ := strconv.Atoi(stdin.Text())
		for i := 0; i < n; i++ {
			stdin.Scan()
			r, _ := strconv.Atoi(stdin.Text())
			if 4*r*r > d2 {
				fmt.Println("OK")
			} else {
				fmt.Println("NA")
			}
		}
	}
}



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

int main() {
  int N;
  cin >> N;
  int f_x = 0;
  int temp = N;
  while(temp>0){
    f_x += temp%10;
    temp /= 10;
  }
  if(N%f_x==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int h, n, a[100000], cnt = 0;
int main () {
	cin >> h >> n;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		cnt += a[i];
	}
	if(h <= cnt) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define int long long

using namespace std;

signed main() {
    int N, M;
    cin >> N >> M;
    string ans;
    for(auto i = 0LL; i < N; i++){
        ans.push_back('o');
    }
    for(auto i = 0LL; i < M; i++){
        int s, c;
        cin >> s >> c;
        if(s > N){
            cout << -1 << endl;
            return 0;
        }else if(ans[s-1] == 'o'){
            ans[s - 1] = '0' + c;
        }else if(ans[s-1] != '0' + c){
            cout << -1 << endl;
            return 0;
        }
    }
    if(ans[0] == '0' && N > 1){
        cout << -1 << endl;
        return 0;
    }
    if(ans[0] == 'o'){
        if(N == 1){
            cout << 0 << endl;
            return 0;
        }
        ans[0] = '1';
    }
    for(auto i = 1LL; i < N; i++){
        if(ans[i] == 'o'){
            ans[i] = '0';
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
x = []
y = []
h = []
for i in range(N):
    _x, _y, _h = map(int, input().split())
    x.append(_x)
    y.append(_y)
    h.append(_h)

def solve():
    for cx in range(101):
        for cy in range(101):
            H = -1
            Hmax = 1<<30
            flg = True
            for i in range(N):
                dist = abs(x[i] - cx) + abs(y[i] - cy)
                if h[i] > 0:
                    HH = h[i] + dist
                    if H < 0:
                        H = HH
                    if H != HH or H > Hmax:
                        flg = False
                        break
                else:
                    Hmax = min(Hmax, dist)
                    if H > Hmax or Hmax == 0:
                        flg = False
                        break
            if flg:
                if Hmax == 1:
                    H = 1
                print(cx, cy, H)
                return

solve()

Measured memory_bytes: 41200
import java.util.Scanner;

public class Main{
    public static void main(String [] args){
        Scanner s = new Scanner(System.in);
        int ans,n,x;
        while(true){
        n = s.nextInt();
        x = s.nextInt();
        if(n==0&&x==0)break;
        ans = solve(0,0,0,n,x);
        System.out.println(ans);

        

        }
    }
    public static int solve(int nn,int c,int now,int a,int b){
        int sum=0;
        if(nn==10&&now==b&&c==a)return 1;
        if(nn==10)return 0;
        sum += solve(nn+1,c,now,a,b);
        sum += solve(nn+1,c+1,now+nn,a,b);
        return sum;
    }
}


Measured memory_bytes: 26516
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] In = Console.ReadLine().Split(' ');
            int[] P = new int[n];
            for(int i=0; i < n; i++)
            {
                P[i] = int.Parse(In[i]);
            }
            int cnt = 0;
            for(int i = 1; i < n - 1; i++)
            {
                if (P[i - 1] < P[i] && P[i] < P[i + 1]) cnt++;
                if (P[i - 1] > P[i] && P[i] > P[i + 1]) cnt++;
            }
            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 27168
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  int a, b;
  readf("%s %s\n", &a, &b);
  writeln(a * b - a - b + 1);
}


Measured memory_bytes: 256
abcd = input().split(" ")
a = int(abcd[0])
b = int(abcd[1])
c = int(abcd[2])
d = int(abcd[3])

flag = 0
while a > 0 and c > 0:
    c = c - b
 
    if c <= 0:
        flag = 1
        break
    a = a - d
    if a <= 0:
        flag = 2
        break

if flag == 1:
    print('Yes')
else:
    print('No')

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:
bool f(pair<string, int> x, pair<string, int> y) {
  if(x.first < y.first) return true;
  else if((x.first == y.first) && x.second > y.second ) return true;
  else return false;
}

int main() {
  int N; cin >> N;
  vector<pair<string, int>> v(N);
  vector<pair<string, int>> fix(N);
  for(int i = 0; i < N; ++i) {
    string s;
    int p;
    cin >> s >> p;
    v[i].first = s; fix[i].first = s;
    v[i].second = p; fix[i].second = p;
  }
  sort(v.begin(), v.end(), f);

  for(int i = 0; i < N; ++i) {
    for(int j = 0; j < N; ++j) {
      if(v[i].first == fix[j].first && v[i].second == fix[j].second) {
        cout << j+1 << endl;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
from collections import deque

N = int(input())
X = [[] for i in range(N)]
Y = [-1] * N
for i in range(N-1):
    x, y = map(int, input().split())
    X[x-1].append(y-1)
    X[y-1].append(x-1)

C = sorted([int(a) for a in input().split()])
print(sum(C)-max(C))

que = deque([0])
while que:
    i = deque.popleft(que)
    if Y[i] < 0:
        Y[i] = C.pop()
        for a in X[i]:
            deque.append(que, a)
print(*Y)

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

using namespace std;

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

  string ans = "";
  while (n != 0) {
    if (abs(n % 2) == 1) {
      ans += "1";
      if (n > 0) {
        n /= (-2);
      } else {
        n = (n - 1) / (-2);
      }
    } else {
      ans += "0";
      n /= (-2);
    }
  }
  reverse(ans.begin(), ans.end());
  cout << (ans == "" ? "0" : ans) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int sum_a = 0,sum_b = 0,i = 4,n;
	
	while(i-- > 0){
		scanf("%d", &n);
		sum_a += n;
	}
	
	i = 4;
	
	while(i-- > 0){
		scanf("%d", &n);
		sum_b += n;
	}
	
	if(sum_a > sum_b)printf("%d\n", sum_a);
	else printf("%d\n", sum_b);
	
	return(0);
}

Measured memory_bytes: 592
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
    string s;
    getline(cin,s);
    for(int i=0;i<s.size();i++){
        char c=s[i];

            if('A'<=c && c<='Z'){
                c=c+32;
            }
            else if('a'<=c && c <='z'){
                c=c-32;
            }
            cout << c;
    }
    cout << endl;
    
    }



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

int main(){

int n,k;
cin >> n >> k;
int l[n];
for (int i = 0; i < n; i++)
{
  cin >> l[i];
}

sort(l, l + n, greater<int>());

int length = 0;
for (int i = 0; i < k; i++)
{
  length += l[i];
}

cout << length << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];

    sort(s[i].begin(), s[i].end());
  }

  map<string, int> temp;

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    temp[s[i]]++;
    if (temp[s[i]] != 1) ans += (temp[s[i]] - 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 13996
#include <bits/stdc++.h>
/* S.size() s.substr(l,r=s.size()-l) -> l文字目からr文字分
__gcd()　lower_bound(a+l,a+r,x)-a でindex
// 配列  -> min/max({}) 
// vector-> *min_element(a+l,a+r)  *忘れず lとrで[l,r) 
//reverse(a+l,a+r)   配列aの[l,r)を逆順に strはreverse(all(s))
//sort(a+l,a+r,greater <int>()) 配列aの[l,r)昇順sort,大きい順はgreater<type>()
//vectorならall(v)
clock()/CLOCKS_PER_SEC で秒数
vector v.push_back(x),v.pop_back()
q.push(x),front()で先頭を返す,pop()で削除, size(),empty()
<deque>(push/pop)_(front/back)/fornt/back/insert/
priority_queue 宣言は priority_queue< Type, vector<Type>, greater<Type>> Q1; 
// pq.push(x),top()で参照 pop()で削除   greaterで最小 lessで最大がtopに*/
using namespace std;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

#define print(i) std::cout << (i) << '\n'
#define rrep(i,n) for(int (i)=(n)-1;(i)!=-1;(i)--)
#define vep(i,v) for(auto (i)=v.begin();(i)<(v.end());(i)++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
inline long long ceildiv(long long a, long long  b) { return (a+b-1)/b; }
typedef pair<long long,long long> P;
typedef pair<int,int> PI;
using Graph = std::vector<std::vector<int> >;
using vi = std::vector<int>;
const long long inf = 10e17;
const long long mod = 1000000007;
//int |x|<=2*10**9     long |x|<= 9*10**18
//printf(".(小数点以下の桁数)lf(double時、float ならf)")
#define ll long long
int main(){
int n;cin>>n;
vi v(n+1);int cnt=0;
rep(i,n){int value;cin>>value;v[value]=cnt;cnt++;}

multiset<int> di;
di.insert(-1);di.insert(-1);di.insert(n);di.insert(n);
ll ans=0ll;
auto g=di.begin();
for(int p=n;p!=0;p--){
    auto x=di.insert(v[p]);
    x--;x--;auto i=*x;
    x++;auto j=*x;
    x++;x++;auto k=*x;
    x++;auto l=*x;x--;x--;
    ll ok=(ll)(p)*((j-i)*(-*x+k)+(-j+*x)*(l-k));
    ans+=ok;
}print(ans);}

Measured memory_bytes: 5376
#include<cstring>
#include<iostream>
#include<cstdio>
#include<cctype>
using namespace std;
const int maxn = 2000;
char s[maxn];

int main()
{
    int n;
    scanf("%d",&n);
    int x1 = n / 100;
    int x2 = n % 100;
    if(x1 <= 12 && x2 <= 12&&x1&&x2){
        printf("AMBIGUOUS\n");
    }else if(x1 && x1 <= 12&&x2 > 12){
        printf("MMYY\n");
    }else if(x1 > 12&& x2 &&x2 <=12){
        printf("YYMM\n");
    }else if(x1 > 12&&x2 > 12){
        printf("NA\n");
    }else if((x1 == 0)&& x2 <= 12&&x2){
        printf("YYMM\n");
    }else if(x1 <= 12&&x1 && (x2 == 0)){
        printf("MMYY");
    }else {
        printf("NA");
    }
    return 0;
}

Measured memory_bytes: 256
sx,sy,tx,ty =gets.chomp.split.map(&:to_i)
a= <<~EOS
#{"U"*(ty-sy).abs}#{"R"*(tx-sx).abs}#{"D"*(ty-sy).abs}#{"L"*(tx-sx).abs}
L#{"U"*(ty-sy).abs}U#{"R"*(tx-sx).abs}RDR#{"D"*((ty-sy).abs+1)}L#{"L"*(tx-sx).abs}U
EOS
puts a.gsub(/\n/,"")

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

long long POW[33];

int N;
int a[200005];

multiset<int> ms;

int main()
{
	POW[0]=1;
	for(int i=1;i<=33;i++)
	{
		POW[i]=POW[i-1]*2;
	}
	
	scanf("%d",&N);
	for(int i=1;i<=N;i++)
	{
		scanf("%d",&a[i]);
		ms.insert(a[i]);
	}
	sort(a+1,a+1+N);
	
	int ans=0;
	while(!ms.empty())
	{
		multiset<int>::iterator z=ms.end();
		z--;
		int xz=(*z);
		ms.erase(z);
		
		int p;
		for(p=33;p>=0;p--)
		{
			if(POW[p]<=xz)
			{
				p++;
				break;
			}
		}
		multiset<int>::iterator it=ms.find(POW[p]-xz);
		if(it!=ms.end())
		{
			ans++;
			ms.erase(it);
		}
	}
	
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 10368
import math
X, K, D = map(int, input().split())
X = abs(X) 

mini = math.ceil(X/D)

if mini >= K:
    print(abs(X-D*K))
else:
    if (K-mini)%2 == 0:
        print(abs(X-D*mini))
    else:
        print(X-D*(mini-1))

Measured memory_bytes: 61832
def main():
    N = int(input())
    sp_lst = [0 for _ in range(N)]

    for i in range(N):
        S, P = input().split()
        sp_lst[i] = [i + 1, S, int(P)]

    sp_lst.sort(key=lambda x: x[2], reverse=True)
    sp_lst.sort(key=lambda x: x[1])

    for i, _, _ in sp_lst:
        print(i)


if __name__ == "__main__":
    main()


Measured memory_bytes: 62760
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
using ll = long long;
using P = pair<ll, int>;

const int mod = 1000000007;
struct mint {
  ll x; 
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};

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

using p_vec = pair<vector<ll>, vector<mint>>;

int n;
vector<vector<Edge>> g; 

p_vec dijkstra(int start){
	vector<ll> dist(n, LINF);
	vector<mint> cnt(n, 0); 
	priority_queue<P, vector<P>, greater<P>> que;
	cnt[start] = 1;
	dist[start] = 0;
	que.push({dist[start], start});

	while(!que.empty()){
		auto v = que.top();
		que.pop();
		int from = v.second;
		ll d = v.first;
		if(d > dist[from])continue;

		for(auto nv : g[from]){
			int to = nv.to;
			ll cost = nv.cost;
			if(dist[from] + cost < dist[to]){
				cnt[to] = cnt[from];
				dist[to] = dist[from] + cost;
				que.push({dist[to], to});
			}
			else if(dist[from] + cost == dist[to]){
				cnt[to] += cnt[from];
			}
		}
	}

	return {dist, cnt};
}

int main(){
  int m, s, t;
  cin >> n >> m >> s >> t;
  --s;
  --t;
  g.resize(n);
  for(int i = 0; i < m; ++i){
  	int u, v;
  	ll d;
  	cin >> u >> v >> d;
  	--u;
  	--v;
  	g[u].push_back(Edge(v, d));
  	g[v].push_back(Edge(u, d));
  }

  auto dij_s = dijkstra(s);
  auto dist_s = dij_s.first;
  auto cnt_s = dij_s.second;
  auto dij_t = dijkstra(t);
  auto dist_t = dij_t.first;
  auto cnt_t = dij_t.second;

  ll total_dist = dist_s[t];
  mint ans = cnt_s[t] * cnt_t[s];
  for(int i = 0; i < n; ++i){
  	if(dist_s[i] * 2 == dist_s[t]){
  		ans -= (cnt_s[i] * cnt_t[i]).pow(2);
  	}
  	for(auto nv : g[i]){
  		int from = i;
  		int to = nv.to;
  		ll cost = nv.cost;
  		if(dist_s[from] < dist_t[from] && dist_s[to] > dist_t[to]){
  			if(dist_s[from] + cost + dist_t[to] == total_dist){
  				ans -= (cnt_s[from] * cnt_t[to]).pow(2);
  			}
  		}
  	}
  }

  
  cout << ans.x << endl;

  return 0;
}


Measured memory_bytes: 20820
#include<stdio.h>
int main(void){
    int a, b;
    char op;
    while(1){
    scanf("%d %c %d", &a, &op, &b);
    if(op == '?')break;
    if(op == '+'){
        printf("%d\n", a + b);
    }
    else if(op == '-'){
        printf("%d\n", a - b);
    }
    else if(op == '*'){
        printf("%d\n", a*b);
    }
    else if(op == '/'){
        printf("%d\n", a / b);
    }
    else{
        printf("やりますねぇ！\n");
    }
}
       return 0;
}


Measured memory_bytes: 2044