akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
 
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define REREP(i,n) for(int i=int(n-1); i>=0; i--)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define REFOR(i,m,n) for(int i=int(n-1); i>=int(m); i--)
#define ALL(obj) (obj).begin(),(obj).end()
 
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>
 
#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>
 
#define SUMI(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SUMD(obj) accumulate((obj).begin(), (obj).end(), 0.)
#define SUML(obj) accumulate((obj).begin(), (obj).end(), 0LL)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

#define PB push_back
#define Cout(str) cout << str << endl

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const ll EPS = (ll)1e-8;

int main(){
	int n,m;
	int a,b,c,d;
	int sum;
	string str;
	string s,t;
	char ch;
	VI vi;
	vector<char> vc;
	VS vs;
	int reserve_vi = 100;
	map<int, int> table; 
	string str2, str3;
	map<char, string> vowel;
	vector<char> vowel_vec = {'a', 'e', 'i', 'o', 'u'};

	//cin >> n >> m;
	//cin >> a >> b;
	cin >> a >> b >> c;
	//cin >> a >> b >> c >> d;
	//cin >> str;
	//cin >> str >> str2 >> str3;
	//cin >> n;
	
	//cin >> s >> t;
	//cin >> ch;
	//cin >> a >> ch >> b;
	
	if(a <= c && c <= b) Cout("Yes");
	else Cout("No");

	//transform(ALL(str_toupper), str_toupper.begin(), ::toupper);

	//cout << accumulate(vi.begin(), vi.begin()+n, 0) << endl;
	//replace(ALL(str), ',', ' ');

	//swap(a, b);
	//vi.resize(N);
	//fill(vi.begin(), vi.end(), 1);
	//vi.reserve(reserve_vi);
	//vi.PB(n);

	//vc.resize(5);
	//vc[i] = (str[i]);

	//sort(vc.begin(), vc.end(), greater<char>());
	//sort(vc.begin(), vc.end());

	//for(auto itr = table.begin(); itr != table.end(); ++itr) {
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main () {
  int a,b,m;
  cin >>a>>b>>m;
  vector<int>an(a);
  vector<int>bn(b);
  int amin =1010010;
  int bmin =1010010;
  int ansA =0;
  for (int i=0;i<a;i++){
    cin >>an[i];
    amin =min(amin,an[i]);
  }
  for (int i=0;i<b;i++){
    cin>>bn[i];
    bmin =min(bmin,bn[i]);
  }
  ansA =amin+bmin;
 
  vector<vector<int>> mn(m, vector<int>(3));
 
  for(int i=0;i<m;i++){
    for(int j=0;j<3;j++){
      cin>>mn.at(i).at(j);
    }
  }
  for (int i=0;i<m;i++){
    ansA =min(ansA,an[mn[i][0]-1]+bn[mn[i][1]-1]-mn[i][2]);
  }
  cout <<ansA<<endl;
return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(a) cout << (a) << endl;
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

int main()
{
    double N,w;
    cin >> N;
    for (double i = 1; i <= 3500; i++) {
        for (double j = 1; j <= 3500; j++) {
            w = (N * i * j) / (4 * i * j - N * i - N * j);
            if(w >= 1 && w <= 3500 && w == floor(w)){
                cout << i << " " <<  j << " " << w << endl;
                return 0;
            }
        }
    }
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  ans += n / 25, n %= 25;
  ans += n / 10, n %= 10;
  ans += n / 5, n %= 5;
  ans += n;
  cout << ans << endl;
}


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

// macros
#define overload_rep(va_0, va_1, va_2, name, ...) name
#define rep_0(i, n) for(int i = 0; i < (n); ++i)
#define rep_1(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
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; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// libraries

// declarations

#define answer(str) do { cout << string(str) << "\n"; return; } while(0)

inline long long gcd(long long a, long long b) {
    if(a < b)swap(a, b); if(b == 0)return a;
    for(long long r; r = a % b; a = b, b = r); return b;
}

void solve(){
    long long A, B, C, D;
    cin >> A >> B >> C >> D;
    if(A < B || D < B)answer("No");
    if(C >= B - 1)answer("Yes");
    A %= B;
    long long E = gcd(B, D);
    long long F = A + (B - A - 1) / E * E;
    answer(F > C ? "No" : "Yes"); 
}

// solve
int main(){

    int T;
    cin >> T;
    while(T--)solve();

}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    int[][] map;
    int X;
    int Y;
    int[][] dp;
    int[] dx = { -1, 0, 1 };
    int[] dy = { 1, 1, 1 };

    void run() {
        Scanner sc = new Scanner(System.in);
        while (true) {
            X = sc.nextInt();
            Y = sc.nextInt();
            if ((X | Y) == 0)
                break;
            map = new int[Y + 2][X + 2];
            dp = new int[Y + 2][X + 2];
            for (int i = 0; i <= Y; i++) {
                map[i][0] = 1;
                map[i][X + 1] = 1;
            }
            for (int i = 1; i <= Y; i++) {
                for (int j = 1; j <= X; j++) {
                    map[i][j] = sc.nextInt();
                }
            }
            int ans = 0;
            for (int i = 1; i <= X; i++) {
                for (int j = 0; j <= Y + 1; j++) {
                    Arrays.fill(dp[j], -1);
                }
                ans += slove(i, 1);
            }
            System.out.println(ans);
        }
    }

    int slove(int x, int y) {
        if (dp[y][x] > 0) {
            return dp[y][x];
        } else {
            int res = 0;
            if (map[y][x] == 1) {
                res = 0;
            } else if (y >= Y) {
                return 1;
            } else if (map[y][x] == 2) {
                res = slove(x, y + 2);
            } else {
                for (int i = 0; i < 3; i++) {
                    int nx = x + dx[i];
                    int ny = y + dy[i];
                    if (!(map[ny][nx] == 2 && x != nx))
                        res += slove(nx, ny);
                }
            }
            return dp[y][x] = res;
        }
    }

    public static void main(String[] args) throws Exception {
        new Main().run();
    }
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

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


int main()
{
    int N;
    cin >> N;
    vector<int> w(N), s(N), v(N);
    REP(i, N) cin >> w[i] >> s[i] >> v[i];
        
    vector<int> ord;
    REP(i, N) ord.push_back(i);
    sort(ord.begin(), ord.end(), [&](int i, int j){ return min(s[i], s[j]-w[i]) > min(s[j], s[i]-w[j]);});

    // dp[i][j]: 最適な方からi番目まで決めたとき、重さが j になる価値の総和の最大値
    vector<vector<long long>> dp(N+1, vector<long long>(3e+4+1));
    REP(i, N){
        int idx = ord[i];
        REP(j, 2e+4+1){
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            if(s[idx] >= j) dp[i+1][j+w[idx]] = max(dp[i+1][j+w[idx]], dp[i][j]+v[idx]);
        }
    }
    cout << *max_element(dp[N].begin(), dp[N].end()) << endl;

    return 0;
}

Measured memory_bytes: 236800
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> v(n+1);
    rep(i,m){
        int a;
        cin >> a;
        v[a] = 1;
    }
    int tmp = 0;
    rep(i,x){
        tmp+=v[i];
    }
    int rmp = 0;
    for(int i = x;i<=n;i++){
        rmp+=v[i];
    }
    cout << min(tmp,rmp)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9+7;

class unionfind {
public:
	vector<int> par;
	vector<int> rnk;

	unionfind(int N) :par(N),rnk(N) {//コンストラクタ
		for (int i = 0; i < N; i++) {
			par[i] = i;
			rnk[i] = 0;
		}
	}

	int root(int x) {//データｘが属する木の根を再帰で得る:root(x)={ｘの木の根}
		if (par[x] == x)return x;
		return par[x] = root(par[x]);

	}

	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry)return;//ｘとｙの根が同じ（＝同じ木にある）時はそのまま
		if (rnk[rx] < rnk[ry]) {
			par[rx] = ry;//xとyの根が同じでない（＝同じ木にない）時：ｘの根をｒｘをｙの根につける
		}
		else if (rnk[rx] > rnk[ry]) {
			par[ry] = rx;
		}
		else {
			par[rx] = ry;
			rnk[ry]++;
		}
	}

	bool same(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}

};



ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y,x%y);
}


int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	ll A, B;
	cin >> A >> B;
	ll G = gcd(A, B);
	ll ans = 1;

	for (ll i = 2; i <= 1000001;i++) {
		if (G%i == 0) {
			ans++;
			while (G%i == 0)G /= i;
		}
	}
	if (G > 1)ans++;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL) {x = x->left;}
  return x;
}

Node treeSearch(Node u, int k){
  if(u==NIL || k ==u->key) return u;
  if(k< u->key) return treeSearch(u->left,k);
  else return treeSearch(u->right,k);
}
Node treeSuccessor(Node x){
  if(x->right !=NIL) return treeMinimum(x->right);
  root = x->parent;
  while(root!=NIL && x==root->right){
    x = root;
    root = root->parent;
  }
  return root;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL ||z->right==NIL) y=z;
  else y = treeSuccessor(z);
  if(y->left !=NIL) x = y->left;
  else x = y->right;
  if(x!=NIL) x->parent = y->parent;
  if(y->parent==NIL) root = x;
  else if(y==y->parent->left) y->parent->left = x;
  else  y->parent->right = x;
  if(y!=z) z->key = y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y==NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}
void inorder(Node u){
  if(u !=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u!=NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
  return 0;
}

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

using namespace std;

int H, W;
string S[52];
int dp[53][53][53][53];

int rec(int sy, int gy, int sx, int gx)
{
  if(sy >= gy || sx >= gx) return (0);
  if(sy + 1 == gy && sx + 1 == gx) return (0);
  int &ret = dp[sy][gy][sx][gx];
  if(~ret) return (ret);
  if(S[sy][sx] == '#') return (0);
  if(sy + 1 < gy && S[sy + 1][sx] != '#') ret = max(ret, rec(sy + 1, gy, sx, gx));
  if(sx + 1 < gx && S[sy][sx + 1] != '#') ret = max(ret, rec(sy, gy, sx + 1, gx));
  if(S[sy][sx] == '.' || isupper(S[sy][sx])) return (ret);
  char c = toupper(S[sy][sx]);
  bool v1[53][53] = {{}}, v2[53][53];
  v1[gy - 1][gx - 1] = true;
  for(int i = gy - 1; i >= sy; i--) {
    for(int j = gx - 1; j >= sx; j--) {
      if(!v1[i][j]) continue;
      if(i - 1 >= sy && S[i - 1][j] != '#') v1[i - 1][j] = true;
      if(j - 1 >= sx && S[i][j - 1] != '#') v1[i][j - 1] = true;
    }
  }
  for(int i = 0; i <= 1; i++) {
    const int sa = sy + i, sb = sx + 1 - i;
    if(sa >= gy || sb >= gx || S[sa][sb] == '#') continue;
    memset(v2, false, sizeof(v2));
    v2[sa][sb] = true;
    for(int j = sa; j < gy; j++) {
      for(int k = sb; k < gx; k++) {
        if(!v2[j][k]) continue;
        if(j + 1 < gy && S[j + 1][k] != '#') v2[j + 1][k] = true;
        if(k + 1 < gx && S[j][k + 1] != '#') v2[j][k + 1] = true;
      }
    }
    for(int j = sy; j < gy; j++) {
      for(int k = sx; k < gx; k++) {
        if(j + 1 < gy && (j == sy && k == sx || v2[j][k]) && c == S[j + 1][k]) {
          if(j + 1 == gy - 1 && k == gx - 1) ret = max(ret, rec(sa, j + 1, sb, k + 1) + 1);
          if(v1[j + 2][k]) ret = max(ret, rec(sa, j + 1, sb, k + 1) + rec(j + 2, gy, k, gx) + 1);
          if(v1[j + 1][k + 1]) ret = max(ret, rec(sa, j + 1, sb, k + 1) + rec(j + 1, gy, k + 1, gx) + 1);
        }
        if(k + 1 < gx && (j == sy && k == sx || v2[j][k]) && c == S[j][k + 1]) {
          if(j == gy - 1 && k + 1 == gx - 1) ret = max(ret, rec(sa, j + 1, sb, k + 1) + 1);
          if(v1[j][k + 2]) ret = max(ret, rec(sa, j + 1, sb, k + 1) + rec(j, gy, k + 2, gx) + 1);
          if(v1[j + 1][k + 1]) ret = max(ret, rec(sa, j + 1, sb, k + 1) + rec(j + 1, gy, k + 1, gx) + 1);
        }
      }
    }
  }
  return (ret);
}

int main()
{
  while(cin >> H >> W, H) {
    for(int i = 0; i < H; i++) cin >> S[i];
    memset(dp, -1, sizeof(dp));
    cout << rec(0, H, 0, W) << endl;
  }
}

Measured memory_bytes: 34388
#include<iostream>
#include<vector>
#include<algorithm>
#define M 10000

using namespace std;

bool TransportPacket(const vector< vector<int> >& data,
		     int s, int g, int ttl, int* ans_){
  vector<bool> is_reached(data.size(), false);
  vector<int> ans(data.size(), M);
  int i, j;
  ans[s] = 0;
  i = s;
  while(i != g){
    is_reached[i] = true;
    for(j=0; j<data[i].size(); ++j){
      ans[j] = min(ans[j], ans[i] + data[i][j]);
    }
    for(i=-1, j=0; j<is_reached.size(); ++j){
      if(!is_reached[j] && (i < 0 || ans[i] > ans[j])) i = j;
    }
  }
  *ans_ = ans[g] + 1;
  if(ttl - *ans_ >= 0) return true;
  else return false;
}

int main(){
  int n, r, k, t;
  int s, d, v, ans;

  cin >> n;
  vector< vector<int> > data(n, vector<int>(n, M));

  for(int i=0; i<n; ++i){
    cin >> r >> k;
    for(int j=0; j<k; ++j){
      cin >> t;
      data[r-1][t-1] = 1;
    }
  }
  cin >> n;
  for(int i=0; i<n; ++i){
    cin >> s >> d >> v;
    if(TransportPacket(data, s-1, d-1, v, &ans)) cout << ans << endl;
    else cout << "NA" << endl;
  }
  return 0;
}

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

int main() {
  string sa,sb,sc;
  cin>>sa>>sb>>sc;
  int ja=0;
  int jb=0;
  int jc=0;
  char ans='o';
  char turn='a';
  while(ans=='o'){
    if(turn=='a'){
    if(ja==sa.size())ans='A';
    else{turn=sa[ja];ja++;}
    continue;
  }
  if(turn=='b'){
  if(jb==sb.size())ans='B';
  else{turn=sb[jb];jb++;}
  continue;
}
if(turn=='c'){
if(jc==sc.size())ans='C';
else{turn=sc[jc];jc++;}
continue;
}
}
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
using namespace std;
//#define int long long
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N;
//=============================
void input()
{
    cin>>N;

}
//=============================
void func() {}
//=============================
void solve()
{
    cout<<(N%2 ? N*2 : N)<<endl;

}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split(" ")))

def gcd(m,n):
    while n != 0:
        a = n
        n = m % n
        m = a
    return m

l = [0]*N
r = [0]*N

l[0] = A[0]
r[-1] = A[-1]

for x in range(1,N):
    y = N - 1 - x
    l[x] = gcd(A[x],l[x-1])
    r[y] = gcd(A[y],r[y+1])

l.insert(0,0)
l.append(0)
r.insert(0,0)
r.append(0)

o = 1

for x in range(N):
    o = max(o,gcd(l[x],r[x+2]))

print(o)

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[125252];

ll dp[125252][2];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",a+i);
  REP(i,n+1)REP(j,2)dp[i][j] = -1ll<<60;
  dp[0][0] = 0;
  REP(i,n)REP(j,2){
    // no flip
    CHMAX(dp[i+1][0], dp[i][j] + (j ? -a[i] : a[i]));
    // flip
    CHMAX(dp[i+1][1], dp[i][j] + (!j ? -a[i] : a[i]));
  }
  printf("%lld\n",dp[n][0]);
  return 0;
}


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

int main(){
  	string S, T;
  	cin >> S >> T;
  	bool flag = true;
  	for (int i = 0; i < S.size(); i++){
      	if (S[i] != T[i]) flag = false;
	}
  
  	if(flag == true) cout << "Yes" << endl;
  	else cout << "No" << endl;
}

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

int main() {
	int H, W, i, j;
	while(1){
		cin>>H>>W;
		
		if(H == 0 && W == 0) break;

		for(i = 1; i <= H; i++){
			for(j = 1; j <= W; j++){
				if(i == 1 || i == H || j == 1 || j == W){
					cout<<"#";
				} else {
					cout<<".";
				}
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3092
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string S,T;
    cin>>S>>T;
    for(int i=0;i<S.size();i++){
        if(S[i]!=T[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 3624
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

using graph = vector<vector<int>>;

std::vector<int> tsort(std::vector<std::vector<int>> const &g)
{
  const int n = g.size();
  std::vector<int> in(n);
  for (int i = 0; i < n; ++i)
  {
    for (auto to : g[i])
    {
      ++in[to];
    }
  }
  std::vector<int> S;
  for (int i = 0; i < n; ++i)
  {
    if (in[i] == 0)
    {
      S.push_back(i);
    }
  }
  std::vector<int> res;
  while (!S.empty())
  {
    int v = S.back();
    S.pop_back();
    res.push_back(v);
    for (auto to : g[v])
    {
      --in[to];
      if (in[to] == 0)
      {
        S.push_back(to);
      }
    }
  }
  bool ok = true;
  for (int i = 0; i < n; ++i)
  {
    ok &= in[i] == 0;
  }
  if (!ok)
  {
    res.clear();
  }
  return res;
}

int main()
{
  int n, m;
  cin >> n >> m;
  graph g(n), gr(n);
  for (int i = 0; i < n + m - 1; ++i)
  {
    int u, v;
    cin >> u >> v;
    g[u - 1].push_back(v - 1);
    gr[v - 1].push_back(u - 1);
  }
  auto ans = tsort(g);
  int i = 0;
  vi mp(n);
  for (auto a : ans)
  {
    mp[a] = i++;
    //cout << a << endl;
  }
  for (int u = 0; u < n; ++u)
  {
    if (mp[u] == 0)
    {
      cout << 0 << endl;
      continue;
    }
    int now = 0, ret = 0;
    for (auto p : gr[u])
    {
      if (mp[u] > mp[p])
      {
        if (now > mp[p])
          continue;
        now = mp[p];
        ret = p + 1;
      }
    }
    cout << ret << endl;
  }
}


Measured memory_bytes: 12532
# https://beta.atcoder.jp/contests/abc110/tasks/abc110_b


def solve():
    _, _, x, y = map(int, input().split())
    Xn = max(map(int, input().split()))
    Ym = min(map(int, input().split()))

    for z in range(x + 1, y + 1):
        if Xn < z <= Ym:
            print('No War')
            exit()
    else:
        print('War')


if __name__ == '__main__':
    solve()


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

int n;	
int h[maxn];
int d[maxn];
int main(){
	scanf("%d",&n);

	for(int i = 0; i < n; ++i){
		scanf("%d",&h[i]);
	}
	d[n-1] = 0;
	d[n-2] = abs(h[n-1]-h[n-2]);	
	for (int i = n-3; i >= 0; --i){
		int um = abs(h[i]-h[i+1])+ d[i+1];
		int ds = abs(h[i]-h[i+2])+ d[i+2];
		d[i] = min(um,ds);
	}
	cout << d[0] << endl;
}

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

int main() {
  for(string s; cin >> s && s != "0"; ) {
    int num[2][11] = {1}, res = 0;
    for(int i = 0, now = 0; i < s.size(); ++i) {
      now = (now * 10 + s[i] - '0') % 11;
      res += num[i&1][now];
      if(i+1 == s.size() || s[i+1] != '0') num[i&1][now] += 1;
      for(int j = 0; j < 11; ++j) num[(i+1)&1][j*10%11] = num[i&1][j];
    }
    cout << res << endl;
  }
  return 0;
}

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


int I[17][17][17][17];
int dp[17][17];

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

  for(int times = 0; times < N; times++) {
    memset(I, 0, sizeof I);
    memset(dp, 0, sizeof dp);

    int W, H, p;
    cin >> W >> H >> p;

    for(int i = 0; i < p; i++) {
      int x1, y1, x2, y2;
      cin >> x1 >> y1 >> x2 >> y2;
      I[x1][y1][x2][y2] = 1;
      I[x2][y2][x1][y1] = 1;
    }

    dp[0][0] = 1;

    for(int x = 0; x <= W; x++) {
      for(int y = 0; y <= H; y++) {
        if(!I[x][y][x+1][y]) {
          dp[x+1][y] += dp[x][y];
        }

        if(!I[x][y][x][y+1]) {
          dp[x][y+1] += dp[x][y];
        }
      }
    }

    if(dp[W][H] == 0) {
      cout << "Miserable Hokusai!" << endl;
    } else {
      cout << dp[W][H] << endl;
    }
  }
}

Measured memory_bytes: 3384
package main

import (
	"fmt"
	"strings"
)

func main() {
	var sx, sy, tx, ty int
	fmt.Scan(&sx, &sy, &tx, &ty)
	dx := tx - sx
	dy := ty - sy
	ans := ""
	ans += strings.Repeat("U", dy)
	ans += strings.Repeat("R", dx)
	ans += strings.Repeat("D", dy)
	ans += strings.Repeat("L", dx)
	ans += "L"
	ans += strings.Repeat("U", dy+1)
	ans += strings.Repeat("R", dx+1)
	ans += "D"
	ans += "R"
	ans += strings.Repeat("D", dy+1)
	ans += strings.Repeat("L", dx+1)
	ans += "U"
	fmt.Println(ans)
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#include <numeric>
#include <math.h>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
	string N;
	cin >> N;
	int ans=0,flag=0,flag2=0;
	for(int i=0;i<N.size();i++){
		if(i==0&&N[i]=='1'){
			flag=1;
		}else if(N[i]=='0'){
			flag2++;
		}
	}
	if(flag==1&&flag2==N.size()-1){
		cout << 10 << endl;
		return 0;
	}else{
		for(int i=0;i<N.size();i++){
			ans = ans+(N[i]-'0');
		}
	}
	cout << ans << endl;
}

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

int main()
{
    int N;
    cin >> N;
    vector<pair<int, int>> work(N);
    rep(i, N)
    {
        int A, B;
        cin >> A >> B;
        work[i] = make_pair(B, A);
    }
    sort(work.begin(), work.end());
    int now_time = 0;

    rep(i, N)
    {
        now_time += work[i].second;
        if (now_time > work[i].first)
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

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

const int MDK=1e9+7;
vector < bool > brk;
int n;
vector < int > mtd;

int solve(){
    mtd[0]=1;
    for(int i=1;i<=n;++i){
        if(brk[i]){
            mtd[i]=0;
        }else{
            mtd[i]=(mtd[i-1]+(i>1?mtd[i-2]:0))%MDK;
        }
    }
    return mtd[n];
}

void _prepare(){
    cin>>n;
    int m;cin>>m;
    brk.resize(n+1);
    mtd.resize(n+1);
    for(int i=0;i<m;++i){
        int x;cin>>x;
        brk[x]=true;
    }
}

int main(){
    _prepare();
    cout<<solve()<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long mod = 1000000007;
const int INF = 1001001001;

int main(){
  int n;
  cin >> n;
  int x;
  x = n/1.08;
  int nn;
  bool flag = 0;
  for(int i=x;i<50000;i++){
    nn = i * 1.08;
    if( nn == n){
      flag = 1;
      x = i;
      break;
    }
  }
  if( flag == 1){
    cout << x << endl;
  }else{
    cout << ":(" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n,b,m;
    cin>>n;
    int a[n],maki=1<<n;
    set<int> s;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int bit=0;bit<maki;bit++){
        int num=0;
        for(int i=0,j=1;i<n;i++,j*=2)if(bit&j)num+=a[i];
        s.insert(num);
    }
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>b;
        if(s.find(b)!=s.end()){
            cout << "yes"<<endl;
        }else{
            cout << "no" <<endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN=1e6+69;
const int BASE=2e3;
const int mod = 998244353;
const int INF = 1e9;
int m,k,n,l,q;
map<int,int> check;
int a[MAXN],b[MAXN],c[MAXN],d[MAXN];
int ans[MAXN];
int maxx;
string s;
int luythua(int x, int y){
    if(y==0)return 1;
    if(y==1)return x%mod;
    int k = luythua(x,y/2);
    if(y%2==1)return k*k%mod*(x%mod)%mod;
    return k*k%mod;
}
void backtrack(int cur, int vt){
    if(vt==n+1){
        int res = 0;
        for(int i=1;i<=q;i++){
            if(ans[b[i]]-ans[a[i]]==c[i]){
                res += d[i];
            }
        }
        maxx = max(res,maxx);
        return;
    }
    for(int i=cur;i<=m;i++){
        ans[vt]=i;
        backtrack(ans[vt],vt+1);
    }
}
signed main(){                                                                                                                                                                                                                                                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n>>m>>q;
    for(int i=1;i<=q;i++){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    backtrack(1,1);
    cout<<maxx;
}


Measured memory_bytes: 3632
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] value = {0,0,0};
        for(int i = 0;i < 10;i++){
            int n = sc.nextInt();
            if(n > 0 && n <= 10000){
                for(int j = 0;j < 3;j++){
                    if(n > value[j]){
                        for(int k = 1;k >= j;k--){
                            value[k + 1] = value[k];
                        }
                        value[j] = n;
                        break;
                    }
                }
            }
        }
        sc.close();
        for(int i = 0;i < 3;i++){
            System.out.println(value[i]);
        }
    }
}

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

int main(){
        int H, W;
        char a;
        cin>>H>>W;
        for(int i = 0; i<W+2;i++){
                cout<<"#";
        }
        cout<<endl;
        for(int i = 0; i<H;i++){
                cout<<"#";
                for(int j = 0; j<W;j++){
                        cin>>a;
                        cout<<a;
                }
                cout<<"#";
                cout<<endl;
        }
        for(int i = 0; i<W+2;i++){
                cout<<"#";
        }
        cout<<endl;


}

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

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


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

typedef long long int ll; 

int main(void)
{
	ll n;
	cin >> n;
	map <ll,ll> umap;
	ll arr[1000];

	ll idx = 0;
	for(ll i=0;i<n;i++)
	{
		ll tt;
		cin >> tt;
		if(umap[tt] == 0)
			arr[idx++] = tt;
		umap[tt]++;
	}

	sort(arr,arr+idx);
	ll ans = 0;
	for(ll i=0;i<idx-2;i++)
	{
		for(ll j=i+1;j<idx-1;j++)
		{
			for(ll k=j+1;k<idx;k++)
			{
				if( (arr[i]+arr[j] > arr[k]) && (arr[j]+arr[k] > arr[i]) && (arr[k]+arr[i] > arr[j]) )
					ans += (umap[arr[i]] * umap[arr[j]] * umap[arr[k]]);
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3632
# include <bits/stdc++.h>
using namespace std;
int main ()
{
 string s;
 cin>>s;
 if (s.length()==2)
   cout<<s<<"\n";
 if (s.length()==3)
   {
   	 for (int i=2;i>=0;--i)
   	   printf ("%c",s[i]);
   	 printf ("\n");
   }
   return 0;	
} 

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;
ll mypow(ll x, ll n, ll m) {
	if (n == 0) {
		return 1;
	}
	if (n % 2 == 0) {
		return mypow(x*x%m, n / 2, m);
	}
	else {
		return x * mypow(x, n - 1, m) % m;
	}
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll COM(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % INF) % INF;
}
///////////////////////////////////////


int main() {
	int n, m; cin >> n >> m;
	if (n == 1 && m == 0) {
		cout << 0 << endl;
		return 0;
	}
	int key[3];
	REP(i, 3)key[i] = -1;
	REP(i, m) {
		int s, c;
		cin >> s >> c;
		s--;
		if (key[s] == -1) {
			key[s] = c;
		}
		else {
			if (key[s] != c) {
				cout << -1 << endl;
				return 0;
			}
		}
	}
	if (n != 1) {
		if (key[0] == 0) {
			cout << -1 << endl;
			return 0;
		}
	}
	REP(i, n) {
		if (i==0) {
			if (key[i] == -1) {
				cout << 1;
			}
			else {
				cout << key[i];
			}
		}
		else {
			if (key[i] == -1) {
				cout << 0;
			}
			else {
				cout << key[i];
			}
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;

typedef long long       ll;
typedef long double     ld;

typedef vector<int>     vi;
typedef vector<bool>    vb;
typedef vector<ll>      vll;
typedef vector<vi>      vvi;
typedef vector<vll>     vvll;
typedef vector<string>  vs;

typedef pair<int, int>  pii;
typedef pair<ll, int>   pli;
typedef pair<ll, ll>    pll;
typedef vector< pii >   vpi;
typedef vector< pll >   vpll;

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

#define pb           push_back
#define mod          1000000007
#define INF          1e17
#define mini         INT_MIN
#define maxo         INT_MAX
#define eb           emplace_back
#define ff           first
#define ss           second
#define re           return 
#define endl         "\n" 

#define all(c)       c.begin(),c.end()
#define be           begin()
#define en           end()
#define sz(x)        (ll)x.size()
#define mem(a,val)   memset(a,val,sizeof(a))
#define mk(x,y)      make_pair(x,y)
#define mid(s,e)     ((s)+((e)-(s))/2) 

#define fo(i,a,b)     for(ll i = (ll)(a); i <= (ll)(b); i++)
#define rf(i,a,b)    for(ll i = (ll)(a); i >= (ll)(b); i--)
#define read(a,n)    for(int i=0;i<n;i++)cin>>a[i];
#define show(a,n)    for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl;
#define p2(n)        (1LL << (n))
#define deb(x) cout <<#x << " = " << x << " | " << "LINE: "<<__LINE__<< endl;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void add(ll &x, ll y){ x += y; if(x>=mod) x %= mod; if(x<0) x = x%mod + mod; }

//============== *** START OF CODE ***




void solve()
{
    ll n;rd(n);
    int a[n+1]; read((a+1),n);
    int c = 0;
    for(int i=1;i<=n;i+=2){
        if(a[i]&1)c++;
    }
    pp(c);   
    
}


void prep(){}

//=============== *** END OF CODE ***

int main(){
    speedio; cout<<fixed<<setprecision(12);

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

    prep();
    int t = 1;
    // cin >> t;
    while(t--)
        solve();

    cout<<"\n";
    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> mon_HP(N);
  for(int i=0; i<N; i++){
    cin >> mon_HP.at(i); 
  }
  sort(mon_HP.begin(), mon_HP.end());
  int64_t sum = 0;
  if(K >= N){
    
  } else {
    for(int i=0; i<N-K; i++){
      sum += mon_HP.at(i);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 1024
x = input().split()
a = int(x[0])
b = int(x[1])
c = int(x[2])

if a > c:
  tmp = a
  a = c
  c = tmp

if a > b:
  tmp = a
  a = b
  b = tmp

if b > c:
  tmp = b
  b = c
  c = tmp
  
print(a, b, c)


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

int main()
{
    vector<vector<int>> bingo(8, vector<int>(9, 0));
    int cnt=0;
    REP(n, 3){
        REP(i, 3){
            REP(j, 3){
                bingo[cnt][n*3+j] = 1;
            }
        }
        cnt++;
    }

    REP(n, 3){
        REP(i, 3){
            REP(j, 3){
                bingo[cnt][i*3+n] = 1;
            }
        }
        cnt++;
    }

    bingo[cnt] = {1,0,0,0,1,0,0,0,1};
    cnt++;
    bingo[cnt] = {0,0,1,0,1,0,1,0,0};
    
    /*  
    REP(n, 8){
        REP(i,3){
            REP(j,3){
                cout << bingo[n][i*3+j] << " ";
            }
            cout  << endl;
        } 
        cout  << endl;
    }
    */ 

    vector<int> board(9,0);
    REP(i, 9){
        cin >> board[i];
    }

    int N;
    cin >> N;
    vector<int> nums(N);
    REP(i,N){
        cin >> nums[i];
    }

    vector<int> result(9,0);
    for (int i = 0; i < 9; i++){
        for(auto x:nums){
            if(board[i]==x) result[i] =1;
        }
    }
    /* 
    REP(i,3){
        REP(j,3){
            cout << result[i*3+j] << " ";
        }
        cout  << endl;
    }
    */
    string OK = "No";
    REP(n,8){
        bool flg=true;
        REP(i, 9){
            if(bingo[n][i] == 1 && result[i] != 1) flg = false;
        }
        if(flg){
            OK = "Yes";
            break;
        }
    }

    cout << OK<< endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int get_gcd(int n, int m) {
  while(m) {
    swap(m, n);
    m %= n;
  }
  return n;
}
 
int main() {
  int a, b;
  while (cin >> a >> b) {
    if (a > b) swap(a, b); 
    int gcd = get_gcd(a, b);
    cout << gcd << " " << a / gcd * b << endl;
  }
}

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

int main() {
    int k;
    cin >> k;
    int x = 7%k;
    set<int> s;
    int ans = 1;
    for (int i=1; i<=k; ++i) {
        if (x == 0) {
            cout << ans << endl;
            return 0;
        }
        s.insert(x);
        x = (x*10+7)%k;
        ++ans;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 50476
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		List<Integer> a = new ArrayList<>();

		for(int i=0; i<N; i++) {
			a.add(sc.nextInt());
		}

		Collections.sort(a, Comparator.reverseOrder());

		int alice = 0;
		int bob = 0;
		for(int i=0; i<N; i++) {
			if(i%2 == 0) alice += a.get(i);
			else bob += a.get(i);
		}

		println(alice - bob);

	}

	public static void print(Object o) {
		System.out.print(o);
	}

	public static void println(Object o) {
		System.out.println(o);
	}
}

Measured memory_bytes: 20820
using System;
using System.Linq;
using System.Collections.Generic;


namespace PCK2016
{
    class Q6
    {
        static int N;
        static int[,,] dp;
        static int[] Datas;
        static void Main()
        {
            N = int.Parse(Console.ReadLine());
            dp = new int[N+2,10,10];
            var buff = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            buff.Insert(0, 0);
            buff.Add(0);
            Datas = buff.ToArray();

            Console.WriteLine(dfs(N+1));
        }

        static int dfs(int cake, int hw1=0, int hw2=0)
        {
            if (cake == 0)
                return 0;

            if (hw1 >= Datas[cake - 1] && hw2 >= Datas[cake])
                return dfs(cake - 1, 0, hw1);

            if (hw2 < Datas[cake])
                if (cake == 1 || cake == N+1)
                    return dfs(cake, hw1 + 1, hw2 + 1) + 1;
                else
                    return dfs(cake, hw1 + 1, hw2 + 1) + 2;

            if (dp[cake, hw1, hw2] > 0)
                return dp[cake, hw1, hw2];

            if (cake == 1 || cake == N+1)
                return dp[cake,hw1,hw2] = Math.Min(dfs(cake, hw1 + 1, hw2 + 1) + 1, dfs(cake - 1, 0, hw1));

            return dp[cake,hw1,hw2] = Math.Min(dfs(cake, hw1 + 1, hw2 + 1) + 2, dfs(cake - 1, 0, hw1));
        }
    }
}

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

int sum(int x){
  int sum = 0;
  while(x !=0){
    sum += x%10;//一番右の桁の数字を足す
    x /= 10; //一番右の桁を消す
  }
  return sum;
}
    
  
int main() {
  int A,B;
  cin >>A>>B;
  int sum = 0;
  for(int x=A;x<=B;x++){
    int i = x;//iをfor文の中で割ったりはできない。いったんｘに置き換え
    int a = i%10;//1
    i /= 10;
    int b = i%10;//10
    i /= 10;

    i /= 10;
    int d = i%10;//1000
    i /= 10;
    int e = i%10;//10000
    if(a==e && b==d)sum++;
  }
  cout << sum << endl;
  return 0;
}


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

int main()
{

#ifdef _d
    freopen("input.txt", "r", stdin);
#endif

    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n+1);
    vector<int> b(m+1);
    vector<int> prefa(n+1);
    vector<int> prefb(m+1);
    int la = n+1; 
    int lb = m+1; 
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        if (prefa[i-1]+a[i] <= k) {
            prefa[i] = prefa[i-1]+a[i];
        } else {
            prefa[i] = INT_MAX;
            la = min(la, i);
        }
    }
    for (int i = 1; i <= m; ++i) {
        cin >> b[i];
        if (prefb[i-1]+b[i] <= k) {
            prefb[i] = prefb[i-1]+b[i];
        } else {
            prefb[i] = INT_MAX;
            lb = min(lb, i);
        }
    }
    int ans = la-1;
    int i = la-1;
    int j = 0;
    int sum = prefa[la-1];
    while (i >= 0) {
        while (j <= m-1 && sum+b[j+1] <= k) {
            ++j;
            sum += b[j];
        }
        ans = max(ans, i+j);
        sum -= a[i];
        --i;
    }
    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 6420
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld DINF = 1e12;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

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

  ll n;
  cin >> n;
  vector<int> v;
  while (n != 0)
  {
    v.push_back((abs(n)) % 2);
    n = (n - (abs(n)) % 2) / (-2);
  }
  if (v.empty())
    v.push_back(0);
  reverse(all(v));
  for (auto a : v)
    cout << a;
  cout << "\n";
  return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

lli d(lli a){
	lli tmp=0;
	while(a>0){
		tmp++;
		a/=10;
	}
	return tmp;
}

lli func(lli a,lli b){
	return max(d(a),d(b));
}

signed main(){

	lli n;
	cin>>n;

	lli ans = INF;
	for(lli i=1;i*i<=n;i++){
		if(n%i==0){
			lli a,b;
			a = i;
			b = n/i;
			ans = min(ans,func(a,b));
		}
	}
	cout<<ans<<endl;

	return 0;
}

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

signed main(){
  int A,B,H;
  cin>>A>>B>>H;
  int ans=(A+B)*H/2;
  cout<<ans<<endl;
  return 0;
}

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

int main() {
  double a, b, h, m;
  cin >>a >>b >>h >>m;
  double th, tm, tb, ret;

  th = 360.0 / 12.0 * h + 360.0 / 12.0 / 60.0 * m;
  tm = 360.0 / 60.0 * m;
  tb = (th*12.0>tm) ? th-tm : tm-th;
  if (tb > 180.0) tb -= 360.0;

  ret = sqrt( a*a + b*b - 2.0*a*b*cos(M_PI*tb/180.0) );
  printf("%.17g\n", ret);
  return 0;
}

Measured memory_bytes: 4224
#include <iostream>
using namespace std;
int main(void){
   string S;
   cin >> S;
   int n = 0;
   int s = 0;
   int w = 0;
   int e = 0;
   for(int i = 0;i < S.size();i++){
       switch(S[i]){
             case 'N':
             n++;
             break;
             case 'S':
             s++;
             break;
             case 'W':
             w++;
             break;
             case 'E':
             e++;
             break;
       }  
   }
   
   if(
         ((n > 0 && s > 0) || (n == 0 && s == 0)) &&
         ((w > 0 && e > 0) || (w == 0 && e == 0))
         
      ){
            cout << "Yes" << endl;
      }else{
            cout << "No" << endl;
      }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    int x,y,z;cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;
    return 0;
}

Measured memory_bytes: 256
Scanf.scanf "%d" (fun n ->
    let z = 1000000007 in
    let extgcd x y =
        let rec eg r0 r1 a0 a1 b0 b1 =
            if r1 = 0 then a0 else
                let q1 = r0 / r1 in
                eg r1 (r0 mod r1) a1 (a0 - q1 * a1) b1 (b0 - q1 * b1)
        in
        eg x y 1 0 0 1
    in
    let inv x y = (* 1/x in mod y *)
        let c = extgcd x y in
        if c < 0 then c + y else c
    in

    let ( +@) a b = (a + b) mod z in
    let ( -@) a b = (((a - b) mod z) + z) mod z in
    let ( *@) a b = (a * b) mod z in
    let ( /@) a b = a *@ inv b z in
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    let k = Array.fold_left (fun acc a -> acc +@ a * a) 0 a in
    let s = Array.fold_left (+@) 0 a in
    Printf.printf "%d\n" @@ (s *@ s -@ k) /@ 2
)

Measured memory_bytes: 7516