akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
const int INF = 1e9;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    swap(A, B);
    swap(A, C);
    cout << A << " " << B << " " << C << endl;

    return 0;
}

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

int main(){
	set<string> se;
	string s;
	int k,i;
	cin >> s >> k;
	for(int i=0;i<s.size();i++){
		for(int j=1;j<6;j++){
			if(i+j<=s.size()){
				se.insert(s.substr(i,j));
			}
		}
	}
	i=1;
	for(auto x:se){
		if(i==k){
			cout << x << endl;
			return 0;
		}
		i++;
	}
}

Measured memory_bytes: 1664
import java.util.*;

// ARC 106-D
// https://beta.atcoder.jp/contests/abc106/tasks/abc106_d

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

      int N = in.nextInt();
      int M = in.nextInt();
      int Q = in.nextInt();

      int[][] map = new int[N + 1][N + 1];
      for (int i = 0; i < M; i++) {
        int L = in.nextInt();
        int R = in.nextInt();

        map[L][R] += 1;
      }

      for (int i = 0; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
          map[i][j] += map[i][j - 1];
        }
      }
      
      for (int i = 0; i < Q; i++) {
        int P = in.nextInt();
        int q = in.nextInt();

        int answer = 0;
        for (int j = P; j <= q; j++) {
          answer += map[j][q];
        }

        System.out.println(answer);
      }
    }
}


Measured memory_bytes: 153996
#include<bits/stdc++.h>
using namespace std;
int l,r,x;
int main(){
  while(~scanf("%d%d%d",&l,&r,&x)){
  int t1=-1;
  for(int i=r;i>=l;i--){
  	if(i%x==0){
    	t1=i;
      break;
    }
  }
  int t2=-1;
  for(int i=l;i<=r;i++){
  	if(i%x==0){
    t2=i;
      break;
    }
  }
  if(t1==-1&&t2==-1) printf("%d\n",0);
  else printf("%d\n",t1/x-t2/x+1);
}
 return 0; 
}

Measured memory_bytes: 3748
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#else
    //    freopen("zalupa.in","r",stdin);
    //    freopen("zalupa.out","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(20);
    cout << fixed;
    ll sum = 0;
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    ll part = 0;
    ll part2 = 0;
    int i = 0;
    while (part * 2 < sum) {
        if ((part + a[i]) * 2 >= sum) {
            part2 = part;
        }
        part += a[i];
        ++i;
    }
    cout << min(2 * part - sum, sum - 2 * part2);
    return 0;
}

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

int main(){
    size_t X, Y, Z;
    cin >> X >> Y >> Z;
    vector<pair<long, long>> coins(X + Y + Z);
    long ans{0}, a;
    for(auto& i : coins){
        cin >> a >> i.first >> i.second;
        i.first -= a;
        i.second -= a;
        ans += a;
    }
    sort(coins.begin(), coins.end(), [](auto a, auto b){return a.first + b.second > a.second + b.first;});
    vector<long> c1{0}, c2{0};
    transform(coins.begin(), coins.end(), back_inserter(c1), [](auto a){return a.first;});
    transform(coins.rbegin(), coins.rend(), back_inserter(c2), [](auto a){return a.second;});

    vector<long> A, B, C;
    priority_queue<long> p, q;
    auto f = [&p, &Y](auto a, auto i){p.push(-i);if(p.size() > Y){a += p.top();p.pop();}return a += i;};
    partial_sum(c1.begin(), c1.begin() + X + Y + 1, back_inserter(B), f);
    swap(p, q);
    swap(Y, Z);
    partial_sum(c2.begin(), c2.begin() + X + Y + 1, back_inserter(C), f);
    transform(B.begin() + Z, B.end(), C.rbegin(), back_inserter(A), plus<>());
    cout << *max_element(A.begin(), A.end()) + ans << endl;
}

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

int main()
{
	int R;
	cin >> R;
	if ( R < 1200 ) {
		cout << "ABC" << endl;
	} else if ( R < 2800 ) {
		cout << "ARC" << endl;
	} else {
		cout << "AGC" << endl;
	}
	return ( 0 );
}


Measured memory_bytes: 256
//verma_ankit484

#include<bits/stdc++.h>

typedef long long ll;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const ll mod = (ll) 1e9+7;

using namespace std;

int main()
{
  IOS
  #ifdef AV
  freopen("int.txt", "r", stdin);
  #endif
  ll n;
  cin >> n;
  vector<ll> vc(n);
  for (ll i = 0; i < n; i++) cin >> vc[i];
  ll ans = 0;
  ll p = 0;
  for (ll i = 0; i < n-1; i++) {
    if(vc[i] < vc[i+1]) {
      ans = max(ans, p);
      p = 0;
    }
    else p++;
  }
  ans = max(ans, p);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
n=int(input())
a=list(map(int, input().split()))
a=[0]+a
b=[0]*(n+1)

for i in range(n,0,-1):
  sum=0
  for j in range(i+i,n+1,i):
    sum^=b[j]
  b[i]=sum^a[i]
ans=[]
for i in range(1,len(b)):
  if b[i]:
    ans.append(i)
print(len(ans))
print(*ans)

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

int main()
{
    int n;
    cin>>n;
    int *a=new int[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int dp[n+1];
    dp[0]=0;
    int ans1,ans2;
    for(int i=1;i<n;i++)
    {
        ans1=INT_MAX;
        ans2=INT_MAX;
        if(i-1>=0)
        {
            ans1=abs(a[i]-a[i-1])+dp[i-1];
        }
        if(i-2>=0)
        {
           ans2=abs(a[i]-a[i-2])+dp[i-2];
        }
        dp[i]=min(ans1,ans2);
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
N, K = map(int, input().split())
xlist = list(map(int, input().split()))
ans = []
for i in range(N - K + 1):
    left = xlist[i]
    right = xlist[i + K - 1]
    if left < 0 and right > 0 or left > 0 and right < 0:
        ans.append(min(abs(left), abs(right)) * 2 + max(abs(left), abs(right)))
    elif left == 0 or right == 0:
        ans.append(abs(left) + abs(right))
    else:
        ans.append(max(abs(left), abs(right)))
print(min(ans))


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

int h, w;
int wa[19][19];
signed main() {
	cin >> h >> w;
	rep(i, 10)rep(j, 10) {
		cin >> wa[i][j];
	}
	rep(i, 10)rep(j, 10)rep(k, 10) {
		wa[j][k] = min(wa[j][k], wa[j][i] + wa[i][k]);
	}
	int ans = 0;
	rep(i, h)rep(j, w) {
		int a; cin >> a; if (a != -1) {
			ans += wa[a][1];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
int INF = INT_MAX / 2;
double EPS = 1e-10;
 
void unko(bool x) {
	if (x) cout << "unko" << endl;
}
 
int main() {
    int N, M; cin >> N >> M;
    vector<int> K(N);
    vector<vector<int> > S(N), H(N);
	int sumK = 0;
    for (int i = 0; i < N; i++) {
        cin >> K[i];
		sumK += K[i];
        for (int k = 0; k < K[i]; k++) {
            int s, h; cin >> s >> h;
            S[i].push_back(s);
            H[i].push_back(h);
        }
    }
	unko(sumK >= 4000 * 0.75 && M >= 200 * 0.5);
    double maxi = 0;
    for (int t = 0; t < N; t++) {
        vector<int> dp(M + 1, -INF);
        dp[M] = 0;
        for (int i = 0; i < N - 1; i++) {
            vector<int> _dp = dp;
            for (int j = 0; j <= M; j++) {
                int h = 0, v = 0;
                for (int k = 0; k < K[i]; k++) {
                    h += H[i][k];
                    v += S[i][k] * H[i][k];
                    if (v > j) break;
                    _dp[j - v] = max(_dp[j - v], dp[j] + h);
                }
            }
            dp = _dp;
        }
        for (int j = 0; j <= M; j++) {
            double h = dp[j], v = j;
            for (int k = 0; k < K[N - 1]; k++) {
                double dh = min((double)H[N - 1][k], v / S[N - 1][k]);
                h += dh; v -= S[N - 1][k] * dh;
            }
            maxi = max(maxi, h);
        }
        rotate(K.begin(), K.begin() + 1, K.end());
        rotate(S.begin(), S.begin() + 1, S.end());
        rotate(H.begin(), H.begin() + 1, H.end());
    }
    printf("%.20f\n", maxi);
}

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

int main(){
  ll a, b;
  cin >> a >> b;
  
  ll c = -1;
  for(int i=1; i<INF; i++){
    if(a*i%b==0){
      c = a*i;
      break;
    }
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 256
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;

int n;

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

    cin >> n;
    cout << 360 / __gcd(n, 360) << endl;
}

Measured memory_bytes: 3612
X = int(input())
Ahashtable = {}
Bhashtable = {}
i = 0

while True:
    x = i ** 5
    Ahashtable[x - X] = i
    Bhashtable[x + X] = i
    Bhashtable[-x + X] = -i
    if x in Ahashtable:
        print(Ahashtable[x], i)
        break
    if -x in Ahashtable:
        print(Ahashtable[-x], -i)
        break
    if x in Bhashtable:
        print(i, Bhashtable[x])
        break
    if -x in Bhashtable:
        print(i, Bhashtable[-x])
        break
    i += 1

Measured memory_bytes: 9144
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int N = in.nextInt();
            String str = in.next();
            char[] S = str.toCharArray();
            HashSet<Character> hs1 = new HashSet<Character>();
            HashSet<Character> hs2 = new HashSet<Character>();
            HashSet<Character> hs3 = new HashSet<Character>();

            int ans = 0;
            for (int i = 0; i < N; i++)
            {
                if (hs1.add(S[i]))
                {
                    hs2.clear();
                    for (int j = i + 1; j < N; j++)
                    {
                        if (hs2.add(S[j]))
                        {
                            hs3.clear();
                            for (int k = j + 1; k < N; k++)
                            {
                                hs3.add(S[k]);
                            }
                            ans += hs3.size();
                        }
                    }
                }
            }
            out.println(ans);
        }

    }
}



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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);

class Graph {
  protected:
    int vertex;

    Graph(int v) {
      vertex = v;
    }
};

struct Edge {
  int to;
  int cost;
};

class AdjacentListGraph : public Graph {
  protected:
    std::vector<std::vector<Edge> > list;
  public:
    AdjacentListGraph(int v): Graph(v) {
      list.resize(vertex);
    }

    virtual void push(int from, int to, int cost) = 0;
};

class SingleSourceGraph : public AdjacentListGraph {
  protected:
    int start;
    std::vector<long long> dist;
    std::vector<int> prev;

  public:
    long long inf = LLONG_MAX / 3;

    SingleSourceGraph(int v, int s);

    void dijkstra();

    std::vector<long long> get_dist();
    std::vector<int> get_path(int d);
};

SingleSourceGraph::SingleSourceGraph(int v, int s): AdjacentListGraph(v) {
  start = s;
  dist.resize(vertex);
  prev.resize(vertex);
  for (int i = 0; i < vertex; ++i) {
    dist[i] = inf;
    prev[i] = -1;
  }
  dist[start] = 0;
}

void SingleSourceGraph::dijkstra() {
  std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> > > pq;
  pq.push(std::make_pair(0, start));

  while (!pq.empty()) {
    int cost = pq.top().first;
    int v = pq.top().second;
    pq.pop();

    for (int i = 0; i < (int)list[v].size(); ++i) {
      Edge e = list[v][i];
      if (cost + e.cost < dist[e.to] ) {
        prev[e.to] = v;
        dist[e.to] = cost + e.cost;
        pq.push(std::make_pair(dist[e.to], e.to));
      }
    }
  }
}

std::vector<long long> SingleSourceGraph::get_dist() {
  return dist;
}

std::vector<int> SingleSourceGraph::get_path(int d) {
  std::vector<int> path;
  int v = d;
  while (v != start) {
    path.push_back(v);
    v = prev[v];
  }
  path.push_back(v);
  std::reverse(path.begin(), path.end());
  return path;
}

class SingleSourceDirectedGraph : public SingleSourceGraph {
  using SingleSourceGraph::SingleSourceGraph;

  public:
  void push(int from, int to, int cost) {
    Edge e;
    e.to = to;
    e.cost = cost;
    list[from].push_back(e);
  }
};

class SingleSourceUndirectedGraph : public SingleSourceGraph {
  using SingleSourceGraph::SingleSourceGraph;

  public:
  void push(int from, int to, int cost) {
    Edge e;
    e.to = to;
    e.cost = cost;
    list[from].push_back(e);

    e.to = from;
    list[to].push_back(e);
  }
};

int main(){
  
  int v;
  int e;
  int s;

  scanf("%d %d %d", &v, &e, &s);

  SingleSourceDirectedGraph g = SingleSourceDirectedGraph(v, s);

  int from, to, cost;

  for (int i = 0; i < e; i++) {
    scanf("%d %d %d", &from, &to, &cost);
    g.push(from, to, cost);
  }

  g.dijkstra();
  std::vector<long long> dist = g.get_dist();

  for (long long d: dist) {
    if (d == g.inf) printf("INF\n");
    else printf("%lld\n", d);
  }
}



Measured memory_bytes: 13836
#include<iostream>
#include<string>
#include<set>

using namespace std;

int main() {
  set<string> d;
  int n, a;
  string o, b;
  cin >> n;
  for (a = 1; a <= n; a++) {
    cin >> o >> b;
    if (o == "insert") {
      d.insert(b);
    } else if (d.find(b) != d.end()) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }
return 0;
}


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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

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;}

struct Pos{
    int x,y;
    Pos(int x,int y):x(x),y(y){}
};

int H,W;
string field[25];
int d[25][25];

void init(){
    for(int i=0;i<25;++i)for(int j=0;j<25;++j)d[i][j]=INF;
}

int bfs(Pos s,Pos e){
    init();
    queue<Pos> que;
    que.push(Pos(s.x,s.y));
    d[s.y][s.x]=0;
    while(que.size()){
        Pos p=que.front();
        que.pop();
        for(int i=0;i<4;++i){
            int nx=p.x+dx[i],ny=p.y+dy[i];
            if(nx<0||nx>=W||ny<0||ny>=H)continue;
            if(d[ny][nx]!=INF||field[ny][nx]=='#')continue;
            que.push(Pos(nx,ny));
            d[ny][nx]=d[p.y][p.x]+1;
        }
    }
    return d[e.y][e.x];
}

signed main(){
    cin>>H>>W;
    for(int i=0;i<H;++i)cin>>field[i];
    int ans=0;
    for(int sy=0;sy<H;++sy){
        for(int sx=0;sx<W;++sx){
            for(int ey=0;ey<H;++ey){
                for(int ex=0;ex<W;++ex){
                    if(field[sy][sx]=='#'||field[ey][ex]=='#')continue;
                    chmax(ans,bfs(Pos(sx,sy),Pos(ex,ey)));
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  string S; cin >> S;
  int ans = 0;
  REP(i, S.size()) ans += S[i]-'0';
  cout << ans << endl;
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
    map<int, int> no_remove;
    for (int i = 0; i < n; i++) {
        int no;
        cin >> no;
        if (no_remove.find(no) != no_remove.end()) {
            no_remove[no]++;
        }
        else {
            no_remove[no] = 1;
        }
    }
    int answer = 0;
    for (pair<int, int> kv : no_remove) {
        int key = kv.first;
        int val = kv.second;
        if (val >= key) {
            answer += val - key;
        }
        else {
            answer += val;
        }
    }
    cout << answer << '\n';
}

Measured memory_bytes: 8080
#include<bits/stdc++.h>
#define ll  long long  
#define pb push_back
#define fi first
#define se second
using namespace std;
ll mo=1e9+7;
ll i,j;
ll power(double p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p);
p=(p*p);
k>>=1;
}
return a;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 int tc=1;
//cin>>tc;
ll cas=1;
 while(tc--)
 {
	double x;
	cin>>x;
	//x-=100;
   double  y=1.01;
   double ans=100;
    for(i=1;i<=1000000;i++)
    {
		ll f=ans*1.01-ans;
		ans+=f;
		if((double)ans>=x)
		{
			cout<<i;
			break;
		}
		
	}
	cout<<"\n"; 
 } 
}
//10000000000000000001333333333


Measured memory_bytes: 3728
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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


int calc(int tmp,vint D){
	while(tmp>0){
		int num = tmp % 10;
		tmp /= 10;

		for (int i = 0; i < (int)D.size(); i++) {
			if(num==D[i]){
				//嫌い
				return 0;
			}
		}
	}
	//すき
	return 1;
}

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

	int N, K;
	int ans = 0;
	cin >> N >> K;
	vint D(K);

	for(int i = 0; i < K; i++)
	{
		cin >> D[i];
	}

	for (int i = N;; i++) {
		//嫌いな数字がない
		if(calc(i,D)){
			ans = i;
			break;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  vector<int> a(2*n);
  for(int i=0;i<2*n;i++){
    cin>>a.at(i);
  }
  int cnt=0;
  int flag=0;
  for(int i=0;i<n;i++){
    if(a.at(2*i)==a.at(2*i+1)){
      cnt++;
    }else{
      cnt=0;
    }
    if(cnt==3){
      flag=1;
    }
  }
  if(flag==1){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(int argc, char *argv[])
{
    char line[256];
    int a, b;

    if (!fgets(line, sizeof(line), stdin)) {
        fprintf(stderr, "error input val\n");
        return -1;
    }

    if (sscanf(line, "%d %d", &a, &b) != 2) {
        fprintf(stderr, "error input format\n");
        return -1;
    }

    if (!(1<=a)) {
        printf(stderr, "error val range\n");
        return -1;
    }
    if (!(b<=1000000000)) {
        fprintf(stderr, "error val range\n");
        return -1;
    }

    printf("%d %d %f\n", a/b, a%b, (double)a/(double)b);

    return 0;
}

Measured memory_bytes: 644
#include<bits/stdc++.h>
// five elements

#define ll long long
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rev(i, s, n) for (int i = s; i > n; i = i - 1)
using namespace std;
#define fr first
#define se second
#define pb push_back
#define mp make_pair
#define mv vector<ll>
#define vii vector<pair<ll, ll>>
// akane_psycho
#define fastio                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define c1(a) cout << a << endl;
#define c2(a, b) cout << a << " " << b << endl;
#define inf 1e18
#define mod 1000000007
#define ii pair<ll,ll>
#define sw(v)      cout << endl;                                                                \
  for(auto u:v) {cout << u << " ";}                                     \
  cout << endl;
  
  /*
  ll ml(ll a, ll b){
  	return ( (a%mod)*(b%mod) )%mod;
  }
ll fp(ll num,ll g)
{
    if(g==0)return 1;
    if(g%2==1)return ml(num,fp(ml(num,num) ,g/2) );
    return fp( ml(num,num),g/2);
}
ll d(ll a, ll b) {//a/b
	return a*fp(b, mod - 2) % mod;
}
ll pm(ll f[] , ll n, ll r){
	return d(  f[n] , f[n-r] );
}
ll cm(ll f[] , ll n , ll r ){
		return d( f[n] , ml( f[r],f[n-r] ) );
	}
*/

int main(){
	ll n;cin>>n;
	ll y=100,i=0;
	while(y<n){
		y+=y/100;
		i++;
	}
	c1(i)
}


Measured memory_bytes: 3676
N = int(input())
ac=0
wa=0
tle=0
re=0
for i in range(N):
    check = input()
    if check == "AC":
        ac+=1
    elif check == "WA":
        wa+=1
    elif check == "TLE":
        tle+=1
    else:
        re+=1
print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))

Measured memory_bytes: 9204
#include <stdio.h>
#include <math.h>
#define A (a%3)
#define B ((a+1)%3)
#define C ((a+2)%3)

/*
(x1,y1),(x2,y2)ðñ¾¼üF
	a=(y2-y1)/(x2-x1)
	b=y1-a*x1

ªÌ¼ñªüF
	a=(x1-x2)/(y2-y1)
	b=(y1+y2)/2-a*(x1+x2)/2
	
QÂÌ¼üax+bÆcx=dÌð_F
	ax+b=cx+dðð¢Ä
	x=(d-b)/(a-c)
	y=ax+b
*/

int main(void){
	double l[2], m[2], x[3], xp, y[3], yp, r; int a, N;
	
	scanf("%d",&N);
	
	for(;N--;){
		scanf("%lf %lf %lf %lf %lf %lf",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2]);

		/* ÇÌQ¼üðg¤©iX«³ÀÉÈé_ðð¯éj */
		a=0;
		if(y[0]==y[1]) a=1;
		else if(y[1]==y[2]) a=2;

		/* ¼ñªü */
		l[0]=(x[A]-x[B])/(y[B]-y[A]), l[1]=(y[A]+y[B])/2-l[0]*(x[A]+x[B])/2;
		m[0]=(x[B]-x[C])/(y[C]-y[B]), m[1]=(y[B]+y[C])/2-m[0]*(x[B]+x[C])/2;
		
		/* ð_ */
		xp=(m[1]-l[1])/(l[0]-m[0]);
		yp=l[0]*xp+l[1];
		
		/* ¼a */
		r=sqrt(pow(xp-x[0],2)+pow(yp-y[0],2));
		
		printf("%.3lf %.3lf %.3lf\n",xp,yp,r);
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int a, b;
	cin >> a >> b;
	if ((a + b) % 2)
		cout << "IMPOSSIBLE" << endl;
	else
		cout << (a + b) / 2 << endl;
}

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

	solve();
}


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

typedef long long LL;

#define FOR(i, a, b) for (int i = (a), i##_END_ = (b); i <= i##_END_; i++)
#define DNF(i, a, b) for (int i = (a), i##_END_ = (b); i >= i##_END_; i--)

template <typename Tp> void in(Tp &x) {
	char ch = getchar(), f = 1; x = 0;
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') ch = getchar(), f = -1;
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= f;
}

template <typename Tp> void out(Tp x) {
	if (x > 9) out(x / 10);
	putchar(x % 10 + '0');
	return;
}

template <typename Tp> Tp Max(const Tp &x, const Tp &y) {return x > y ? x : y;}
template <typename Tp> Tp Min(const Tp &x, const Tp &y) {return x < y ? x : y;}
template <typename Tp> bool chkmax(Tp &x, Tp y) {return x >= y ? 0 : (x=y, 1);}
template <typename Tp> bool chkmin(Tp &x, Tp y) {return x <= y ? 0 : (x=y, 1);}

const int MAXN = 200010;

struct Obj {
	int L, R;
} num[MAXN];

int n, m;
int maxx[MAXN << 2], tag[MAXN << 2];

bool cmp(const Obj &x, const Obj &y) {return x.L < y.L;}

void build(int now, int l, int r)
{
	if (l == r) {
		maxx[now] = -(m - (l - 1) + 1);
		return;
	}
	int mid = (l + r) >> 1;
	build(now << 1, l, mid); build(now << 1 | 1, mid + 1, r);
	maxx[now] = Max(maxx[now << 1], maxx[now << 1 | 1]);
}

void pushdown(int now)
{
	if (!tag[now]) return;
	maxx[now << 1] += tag[now]; tag[now << 1] += tag[now];
	maxx[now << 1 | 1] += tag[now]; tag[now << 1 | 1] += tag[now];
	tag[now] = 0;
}

void modify(int now, int l, int r, int x, int y, int z)
{
	if (x <= l && r <= y) {
		maxx[now] += z; tag[now] += z; return;
	}
	pushdown(now);
	int mid = (l + r) >> 1;
	if (x <= mid) modify(now << 1, l, mid, x, y, z);
	if (mid < y) modify(now << 1 | 1, mid + 1, r, x, y, z);
	maxx[now] = Max(maxx[now << 1], maxx[now << 1 | 1]);
}

int query(int now, int l, int r, int x, int y)
{
	if (x <= l && r <= y) return maxx[now];
	pushdown(now);
	int mid = (l + r) >> 1;
	if (y <= mid) return query(now << 1, l, mid, x, y);
	if (mid < x) return query(now << 1 | 1, mid + 1, r, x, y);
	return Max(query(now << 1, l, mid, x, y), query(now << 1 | 1, mid + 1, r, x, y));
}

int main()
{
	in(n); in(m);
	FOR(i, 1, n) in(num[i].L), in(num[i].R);

	std::sort(num + 1, num + n + 1, cmp);

	build(1, 1, m + 2);

	int he = Max(0, n - m);
	
	FOR(i, 1, n) {
		modify(1, 1, m + 2, 1, num[i].R + 1, 1);
		chkmax(he, query(1, 1, m + 2, num[i].L + 2, num[i].R + 1) - num[i].L);
	}

	printf("%d\n", he);
	
	return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

const int maxN = 1024;

int n, m, i, x, y;
vector< pair<int, int> > to[maxN], from[maxN], list[maxN];
pair<int, int> rez[maxN * maxN];

bool way_back[maxN][maxN];
bool way_forw[maxN * maxN];
bool us[maxN];

void dfs_back(int node, int src) {
    way_back[src][node] = true;

    for (auto e : to[node])
        if (way_back[src][e.first] == false)
            dfs_back(e.first, src);
}

void dfs_forw(int node, int deny) {
    us[node] = true;
    for (auto e : to[node])
        if (us[e.first] == false && deny != e.first)
            dfs_forw(e.first, deny);
}

void solve_forw(int node) {
    int i;

    memset(us, 0, sizeof(us));
    for (auto y : to[node]) {
        if (us[y.first]) {
            way_forw[y.second] = true;
        } else {
            dfs_forw(y.first, node);
        }
    }

    memset(us, 0, sizeof(us));
    reverse(to[node].begin(), to[node].end());
    for (auto y : to[node]) {
        if (us[y.first]) {
            way_forw[y.second] = true;
        } else {
            dfs_forw(y.first, node);
        }
    }
}

int main()
{
   // freopen("test.in","r",stdin);

    cin >> n >> m;
    for (i = 1; i <= m; i++) {
        cin >> x >> y;
        rez[i] = mp(x, y);
        to[x].pb(mp(y, i));
        from[y].pb(mp(x, i));

        list[x].pb(mp(y, i));
        list[y].pb(mp(x, i));
    }

    for (i = 1; i <= n; i++)
        dfs_back(i, i);

    for (i = 1; i <= n; i++)
        solve_forw(i);

    for (i = 1; i <= m; i++) {
        x = rez[i].first;
        y = rez[i].second;

        if (way_back[y][x] == way_forw[i])
            cout << "same\n";
        else
            cout << "diff\n";
    }


    return 0;
}


Measured memory_bytes: 16512
fun main(args: Array<String>) = abc158e()

fun abc158e() {
    val (n, p) = readLine()!!.split(' ').map { it.toInt() }
    val s = readLine()!!.toCharArray().map { it.toString().toInt() }.toIntArray()

    var answer = 0L

    when (10 % p) {
        0 -> {
            for ((index, i) in s.withIndex()) {
                if (i % p == 0) answer += 1 + index
            }
        }
        else -> {
            val mods = IntArray(n + 1)
            var ten = 1
            for ((index, i) in s.reversed().withIndex()) {
                mods[index + 1] = (mods[index] + (i * ten % p)) % p
                ten *= 10
                ten %= p
            }

            val left = IntArray(p)
            for (m in mods) answer += left[m]++
        }
    }

    println(answer)
}


Measured memory_bytes: 45568
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;

    string ans = "No";

    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if (i*j == N){
                ans = "Yes";
                break;
            }
        }
        if (ans == "Yes") break;
    }

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

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

int main() {
	// your code goes here
	string s,t;
	cin>>s;
	cin>>t;
	for(int i = 0; t[i]!='\0'; i++)
	{
		cout<<t[i];
	}
	for(int i = 0; s[i]!='\0'; i++)
	{
		cout<<s[i];
	}
	return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    bool flag[100010];
    int cnt[100010];
    for(int i=0;i<100010;i++){
        flag[i]=false;
        cnt[i]=1;
    }
    flag[1]=true;
    long long ans=1;
    for(int i=0;i<m;i++){
        int x,y;
        cin >> x >> y;
        if(flag[x]==true){
            cnt[x]--;
            cnt[y]++;
            if(flag[y]==false){
                ans++;
            }
            flag[y] = true;
            if(cnt[x]==0){
                flag[x]=false;
                ans--;
            }
        }else{
            cnt[x]--;
            cnt[y]++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 768
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class Main
{

  public static void main
  (
    String[] args
  )
  {
    BufferedReader in_stream;
    String         in_str;
    String[]       in_str_split;

    long in_X;
    long in_Y;

    long cnt;
    long ans;
    long next;


    try
    {
      in_stream    = new BufferedReader(new InputStreamReader(System.in));
      in_str       = new String(in_stream.readLine());
      in_str_split = in_str.split(" ");

      in_X = Long.parseLong(in_str_split[0]);
      in_Y = Long.parseLong(in_str_split[1]);

      next = in_X;
      ans  = 0;
      for(cnt=1; next<=in_Y; cnt++)
      {
        ans++;
        next = in_X * ( (long)Math.pow(2, cnt) );
      }

      UtilLog.ans_ln("" + ans);
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }
}

class UtilLog
{
  private static boolean is_debug_mode = false;



  public static void ans_ln
  (
    String i_message
  )
  {
    System.out.println(i_message);
  }



  public static void ans_f
  (
    String i_message
  )
  {
    System.out.printf(i_message);
  }



  public static void inf_ln
  (
    String i_message
  )
  {
    StackTraceElement[] stack;


    if(is_debug_mode)
    {
    stack = new Throwable().getStackTrace();

    System.out.println
      (
        String.format
          (
            "[inf][%s:%s():%5d]",
            stack[1].getClassName(),
            stack[1].getMethodName(),
            stack[1].getLineNumber(),
            i_message
          )
      );
    }
  }
}


Measured memory_bytes: 22484
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

const int maxn = 100000;
int n, f[maxn];
vector<int> G[maxn];
int son[maxn];

void solve(int u, int p) {
	for(int i = 0; i < (int)G[u].size(); ++i) {
		int v = G[u][i];
		if(v != p) solve(v, u);
	}
	int child = 0;
	for(int i = 0; i < (int)G[u].size(); ++i) {
		int v = G[u][i];
		if(v != p) son[child++] = f[v];
	}
	sort(son, son + child);
	f[u] = 0;
	for(int i = 0; i < child; ++i) {
		f[u] = max(f[u], son[i]) + 1;
	}
}

int main(void) {
	scanf("%d", &n);
	for(int i = 1; i < n; ++i) {
		int p;
		scanf("%d", &p), --p;
		G[i].push_back(p);
		G[p].push_back(i);
	}
	solve(0, -1);
	printf("%d\n", f[0]);
}

Measured memory_bytes: 13952
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Bad":"Good")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    string s;
    cin >> s;
    yorn (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]);
    
    return 0;
}

Measured memory_bytes: 3524
#include <iostream>

using namespace std;


int main()
{
	string s1, s2;
	int idx = -1;
	cin >> s1 >> s2;

	for (int i = 0; i < s1.size() - s2.size() + 1; ++i)
	{
		bool ok = true;
		for (int j = 0; j < s2.size(); ++j)
		{
			if (s1[i + j] != s2[j] && s1[i + j] != '?')
			{	
				ok = false;
				break;
			}
		}
		if (ok)
			idx = max(idx, i);
	}
	if (idx == -1)
		cout << "UNRESTORABLE\n";
	else
	{
		for (int i = 0; i < s2.size(); ++i)
		{
			s1[idx + i] = s2[i];
		}
		for (int i = 0; i < s1.size(); ++i)
		{
			if (s1[i] == '?')
				s1[i] = 'a';
		}
		cout << s1;
	}
	return 0;
}

Measured memory_bytes: 256
/* **********************************JAI SAI RAM ************************************* */
//HELP IN CODEFORCES ROUND 641
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll P=1000000007;
ll MAX=1e15;
ll MIN=-1*(1e15);
ll a[3020],f[3020];
void  solve()
{
    ll n,i,j,k,l,m,o,q,r,t;
    cin>>n;
    map<string,ll> mp;
    for(i=0;i<n;i++)
    {
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
     cout<<"TLE x "<<mp["TLE"]<<endl;
      cout<<"RE x "<<mp["RE"]<<endl;
}
int main()
{
    ll t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}


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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#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 ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x)*(x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main() {
    int N, M, P;
    while (cin >> N >> M >> P, N|M|P) {
        M--;
        int cnt = 0;
        int win = 0;
        REP(i, N) {
            int a;
            cin >> a;
            cnt += a;
            if (i == M) win = a;
        }
        if (win > 0) {
            cout << floor((double)(100*cnt - P*cnt) / (double)win) << endl;
        } else {
            cout << 0 << endl;
        }
    }
}

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

const int MOD = 1e9+7;
using namespace std;

long long dp[10001][10001];

int main(){
    
    int n, m;
    cin >> n >> m;
    
    char temp;
    dp[0][1] = 1;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            cin >> temp;
            
            if(temp == '.')
                dp[i][j] = (dp[i][j-1] + dp[i-1][j]) % MOD;
            else
                dp[i][j] = 0;
        }
    }
    
 
    cout << dp[n][m] << endl;

}

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

typedef long long ll;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    cin >> n;
    vector<int> s(n);
    for (int i = 0;i < n;++i) cin >> s[i];
    ll ans = 0;
    for (int i = 1;i < n/2;++i) {
        ll ret = 0;
        int l = 0,r = n-1;
        for (int j = 0;j < n;++j) {
            l += i;
            r -= i;
            if (r < i || l == r || (l > r && (l-r)%i == 0)) break;
            ret += s[l]+s[r];
            ans = max(ans,ret);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <stdio.h>
#include <string>
#include <string>
#include <iomanip>
#include <stdlib.h>

using namespace std;

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


	int gg = 0;
	for (int i = 1; i < n + 1; i++)
	{
		int co = 0;
		if (i % 2 != 0)
		{
			for (int j = 1; j < n + 1; j++)
			{
				if (i % j == 0)
				{
					co++;
				}
			}
		}
		if (co == 8)
		{
			gg++;
		}
	}
	cout << gg << endl;
}


Measured memory_bytes: 256
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n;
  map<char,int> m;

  cin >> n;

  rep(i,n)
  {
    char c;
    cin >> c;
    m[c]++;
  }

  if(sz(m) == 4) cout << "Four" << endl;
  else cout << "Three" << endl;


  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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

int main(){
  int N;cin>>N;
  vector<int> H(N);
  for(int i=0;i<N;i++) cin>>H.at(i);
  vector<int> dp(N);
  dp.at(0)=0;
  dp.at(1)=abs(H.at(0)-H.at(1));
  for(int i=2;i<N;i++){
    int X=dp.at(i-1)+abs(H.at(i-1)-H.at(i));
    int Y=dp.at(i-2)+abs(H.at(i-2)-H.at(i));
    dp.at(i)=(X>Y?Y:X);
  }
  cout<<dp.at(N-1)<<endl;
}

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

int main() 
{
  long long N,D; cin>>N>>D;
  int ans=0;
  for(int i=0;i<N;i++){
    long long X,Y; cin>>X>>Y;
    if(X*X+Y*Y<=D*D) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;

#define MAX 17
#define f first
#define s second
typedef pair<int, int> P;

int X, Y;
int field[MAX][MAX];
int dp[MAX][MAX];

int solve(){
  for(int i = 0 ; i < Y ; i++){
    for(int j = 0 ; j <= X ; j++){
      if(field[i][j] == 0){
	for(int dx = -1 ; dx <= 1 ; dx++){
	  if(field[i+1][j+dx] != 1 && (field[i+1][j+dx] == 0 || dx == 0)){
	    dp[i+1][j+dx] += dp[i][j];
	  }
	}
      }
      else if(field[i][j] == 2 && field[i+2][j] != 1){
	dp[i+2][j] += dp[i][j];
      }
    }
  }

  int res = 0;
  for(int i = 0 ; i <= X ; i++){
    res += dp[Y][i] + dp[Y+1][i];
  }
  return res;
}

void init(){
  memset(dp, 0, sizeof(dp));
  for(int i = 0 ; i <= X ; i++){
    if(field[0][i] == 0) dp[0][i] = 1;
  }
}

int main(){
  while(cin >> X >> Y, X && Y) {
    X--, Y--;
    for(int i = 0 ; i <= Y ; i++) {
      for(int j = 0 ; j <= X ; j++) {
	cin >> field[i][j];
      }
    }
    
    init();
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

template<class T> inline void chmin(T& a, T b) { if(b < a) a = b; }

map<int, int> convert_table, reverse_table;

int convert(int x) {
	if(convert_table.count(x))
		return convert_table[x];

	convert_table.insert(make_pair(x, convert_table.size()));
	reverse_table.insert(make_pair(convert_table.size() - 1, x));
	return convert_table.size() - 1;
}

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

	const int INF = 0xfffffff;

	for(int n; cin >> n, n;) {
		vector<vector<int> > dist(10, vector<int>(10, INF));
		for(int i = 0; i < dist.size(); ++i)
			dist[i][i] = 0;

		convert_table.clear();
		reverse_table.clear();
		for(int i = 0; i < n; ++i) {
			int a, b, c;
			cin >> a >> b >> c;

			a = convert(a);
			b = convert(b);

			dist[a][b] = dist[b][a] = c;
		}

		int m = convert_table.size();
		for(int k = 0; k < m; ++k)
			for(int i = 0; i < m; ++i)
				for(int j = 0; j < m; ++j)
					chmin(dist[i][j], dist[i][k] + dist[k][j]);

		int city = INT_MAX, ans = INT_MAX;
		for(int i = 0; i < m; ++i) {
			int sum = 0;
			for(int j = 0; j < m; ++j)
				sum += dist[i][j];

			if(ans > sum || (ans == sum && reverse_table[i] < city)) {
				ans = sum;
				city = reverse_table[i];
			}
		}

		cout << city << " " << ans << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1220
#include <stdio.h>
  
int main(void){
   
int n, i, k;
   
scanf("%d", &n);
   
int l[n][3];
   
for(i=0; i<n; i++)
scanf("%d %d %d", &l[i][0], &l[i][1], &l[i][2]);
   
for(i=0; i<n; i++){
   
for(k=0; k<2; k++){
   
if(l[i][0]>l[i][1]){
int temp;
temp=l[i][0];
l[i][0]=l[i][1];
l[i][1]=temp;
}
   
if(l[i][1]>l[i][2]){
int temp;
temp=l[i][1];
l[i][1]=l[i][2];
l[i][2]=temp;
}
   
}
}
   
for(i=0; i<n; i++){ 
if((l[i][0])*(l[i][0])+(l[i][1])*(l[i][1])==(l[i][2])*(l[i][2]))
printf("YES\n");
else
printf("NO\n");
} 
  
return 0;
   
}

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

int main() {
  string S, T;
  cin >> S >> T;

  vector<int> Sr(S.size() + 1), Tr(T.size() + 1);
  for (int i = 0; i < S.size(); ++i) {
    if (S[i] == 'A') Sr[i + 1]++;
  }
  for (int i = 0; i < T.size(); ++i) {
    if (T[i] == 'A') Tr[i + 1]++;
  }

  for (int i = 1; i <= S.size(); ++i) {
    Sr[i] += Sr[i - 1];
  }
  for (int i = 1; i <= T.size(); ++i) {
    Tr[i] += Tr[i - 1];
  }

  int q;
  cin >> q;
  while (q--) {
    int SL, SR, TL, TR;
    cin >> SL >> SR >> TL >> TR;
    SL--;
    TL--;

    int SA = (Sr[SR] - Sr[SL]), SB = (SR - SL) - SA;
    int TA = (Tr[TR] - Tr[TL]), TB = (TR - TL) - TA;

    if (((SA % 3) - (SB % 3) + 3) % 3 == ((TA % 3) - (TB % 3) + 3) % 3)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if(A + B > C + D){
    cout << "Left" << endl;
  }
  else if(A + B == C + D){
    cout << "Balanced" << endl;
  }
  
  else{
    cout << "Right" << endl;
  }
  return 0;
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int n, k;
  scanf("%d %d", &n, &k);

  vector<int> v(n);
  REP (i, n) {
    scanf("%d", &v[i]);
  }

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

  int res = INT_MAX;
  REP (i, n - k + 1) {
    int tmp = v[i + k - 1] - v[i];
    res = min(res, tmp);
  }

  cout << res << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include <algorithm>
#include<string>
#include <numeric>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int x,y;
    cin>>x>>y;
    if((x)%3==0)cout<<"Possible"<<endl;
    else if((y)%3==0)cout<<"Possible"<<endl;
    else if((x+y)%3==0)cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;

}


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

using namespace std;

//#define FILE_IO

int N, M;
char s[2005][2005];
int a[2005][2005];
int up[2005], lft[2005], rgt[2005];
stack<int> stv;

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

    scanf("%d%d\n", &N, &M);
    for(int i = 1; i <= N; i++)
        scanf("%s", s[i] + 1);

    for(int i = 1; i < N; i++)
        for(int j = 1; j < M; j++)
            a[i][j] = ( (s[i][j] == '.') + (s[i + 1][j] == '.') + (s[i + 1][j + 1] == '.') + (s[i][j + 1] == '.') ) & 1;

    int ans = max(N, M);
    for(int i = 1; i < N; i++)
    {
        for(int j = 1; j < M; j++)
        {
            up[j]++;
            if(a[i][j] == 1)  up[j] = 0;
        }

        while(!stv.empty()) stv.pop();
        for(int j = 1; j < M; j++)
        {
            while(!stv.empty() && up[j] <= up[stv.top()]) stv.pop();

            if(stv.empty()) lft[j] = 1;
            else    lft[j] = stv.top() + 1;

            stv.push(j);
        }

        while(!stv.empty()) stv.pop();
        for(int j = M - 1; j > 0; j--)
        {
            while(!stv.empty() && up[j] <= up[stv.top()]) stv.pop();

            if(stv.empty()) rgt[j] = M - 1;
            else    rgt[j] = stv.top() - 1;

            stv.push(j);
        }

        for(int j = 1; j < M; j++)
            ans = max(ans, (up[j] + 1) * (rgt[j] - lft[j] + 1 + 1));
    }

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


    return 0;
}


Measured memory_bytes: 19840